Matt RaibleMatt Raible is a writer with a passion for software. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.
You searched this site for "servlet". 226 entries found.

You can also try this same search on Google.

Integrating JSP/JSF and XML/XSLT: The Best of Both Worlds

I saw this nugget a few minutes ago on the struts-user mailing list. Maybe I'll even read it... ;-)

For those of you wondering how JSP technologies, including JSP 2.0, JSTL, Struts and the upcoming JavaServer Faces (JSF) 1.0, can work together with XML and XSLT, there is a new article at TheServerSide.com about this subject.

http://www.theserverside.com/resources/article.jsp?l=BestBothWorlds

The article presents the natural evolution of server-side Java programming from basic servlet programming to JSP 2.0 with JSTL and JSF, shows the limitations of the current JSF rendering architecture and how XML technologies can solve them.

The article comes with sample code that shows how to hookup an XSLT transformer with a JSP filter, and includes an experimental XML renderer for JSF.

Posted in Java at Feb 12 2003, 12:40:53 PM MST 1 Comment

Deploying to Tomcat using Ant

If you're using Tomcat 4.1.x, did you know you can deploy using an Ant task that ships with Tomcat. You'll need to add $CATALINA_HOME/server/lib/catalina-ant.jar to your classpath, but then you can configure your ant task as follows:

<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>

<deploy url="${manager.url}"
         username="${manager.username}"
         password="${manager.password}"
         path="/${name}"
         war="file:/${dist.dir}/${name}.war" />

I haven't tried it, but it looks cool. Right now I use a simple copy task that works pretty well for me, so no need to change at this point.

<target name="deploy" depends="package-web" if="tomcat.home"
    description="unwar into the servlet container's deployment directory">
          
    <unwar src="${webapp.dist}/${webapp.war}" 
        dest="${tomcat.home}/webapps/${webapp.name}"/>
    
</target>

If you know of any advantages to using Tomcat's deploy task, or you'd like to share your experience using it - please post a comment.

Posted in Java at Feb 07 2003, 06:58:04 AM MST 12 Comments

A bit of Tomcat History - the names

I got this nugget of information off the tomcat-user list this morning.

I talked to the original Tomcat author, James Duncan Davidson, about the 
name choice. He gave me a surprising answer. Here's a bit of history...

Tomcat was born in response to the need for an independant servlet 
specification implementation. James wrote it hoping that it would 
eventually be open sourced. He figured that since most open source 
projects had O'reilly books about them that he should name it after an 
animal. Essentially he was thinking of an animal that would go on the 
cover of an O'reilly book. He came up with "Tomcat" since the animal 
represented something that could take care of itself and fend for 
itself. That's how he came up with the name.

And Craig McClanahan tells us why he named the Catalina Engine so:

Using "Catalina" was my idea, because I
wrote most of the original code that became it.  The reasons are mundane,
but here they are for the record:

* Even though I don't live in Southern CA, I've always liked
  what I've read and seen of Catalina Island.

* One of the towns on the island is Avalon, and we were (at the
  beginning) considering using the Avalon Framework
  (http://jakarta.apache.org/avalon/) for the internal architecture.
  It would have been a cute tie-in, but alas it didn't happen
  that way.

* When I'm coding, I regularly have one or more cats wandering
  around my lap and adding to the whitespace when they don't
  think I put enough (you don't need fingers to press the space bar :-).

Another "code name" you'll hear in the Tomcat world is Jasper -- that's
the name of the JSP page compiler part of Tomcat.  That name was carried
over from even before my time, but I'm sure it probabbly came from the
alliteration (JaSPer).

Posted in Java at Feb 04 2003, 05:43:56 AM MST Add a Comment

[SOLVED] Connection Timeout using Oracle with Tomcat

I finally solved the problem I was having where the DBCP Connection Pool in Tomcat kept getting closed. At first, I thought it was happening every 24 hours. After we configured connection logging in Oracle, we discovered it was happening every 2 hours. After posting numerous (likely annoying) messages to tomcat-user and struts-user (with no resolution), I looked up my local Oracle user-group mailing list and fired off a message.

The first (and only) response solved my problem. It said I should check and see if there is a connection timeout on the firewall. Sure 'nuff, 90 minutes. So I wrote a DBPingServlet, coupled with an Ant task to make an HTTP Request to get the servlet, and scheduled it as a cron job. Whalla - the problem is fixed! Thank God - it was annoying to restart Tomcat every 2 hours! Of course, if folks where actually using our application - this would've never been an issue... ;-)

Posted in Java at Jan 30 2003, 03:17:35 PM MST 1 Comment

The History of JSP

Erik tipped me off that the JSP 2.0 Proposed Final Draft 2 was released. Too bad they don't show a diff of what changed between Draft 1 and Draft 2, or do they? Let me know if you know of such a feature. I did, however, find a little history on Java Server Pages that might be of interest. This excerpt below is from the PDF.

Historical Note

The following individuals were pioneers who did ground-breaking work on the Java platform areas related to this specification. James Gosling’s work on a Web Server in Java in 1994/1995 became the foundation for servlets. A larger project emerged in 1996 with Pavani Diwanji as lead engineer and with many other key members listed below. From this project came Sun’s Java Web Server product.

Things started to move quickly in 1999. The servlet expert group, with James Davidson as lead, delivered the Servlet 2.1 specification in January and the Servlet 2.2 specification in December, while the JSP group, with Larry Cable and Eduardo Pelegri-Llopart as leads, delivered JSP 1.0 in June and JSP 1.1 in December.

The year 2000 saw a lot of activity, with many implementations of containers, tools, books, and training that target JSP 1.1, Servlet 2.2, and the Java 2 Platform, Enterprise Edition. Tag libraries were an area of intense development, as were varying approaches to organizing all these features together. The adoption of JSP technology has continued in the year 2001, with many talks at the "Web, Services and beyond" track at JavaOne being dedicated to the technology.

The JSP 1.2 specification went final in 2001. JSP 1.2 provided a number of fine-tunings of the spec. It also added the ability for validating JSP pages through the XML views of a JSP page. JSP 1.2 also introduced a normative XML syntax for JSP pages, but its adoption was handicaped by several specification shortcomings.

JSP 2.0 is a major revision of the JSP language. Key new features include a simple Expression Language, tag files, substantial simplifications for writing tag handlers in Java and the notion of JSP fragments. JSP 2.0 also includes a revision of the XML syntax that addresses most of the problems in JSP 1.2. Tracking the industry in a printed document is at best difficult; the industry pages at the web site at http://java.sun.com/products/jsp do a better job.

Posted in Java at Jan 29 2003, 10:21:18 PM MST Add a Comment

Back From Florida

We all survived the Florida trip and we arrived home safely a couple of hours ago. Abbie was awesome on the plane(s) and only cried when she was hungry. I'll post pictures soon. Also, it was cool to find that there was FREE wireless Internet access at the Fort Lauderdale airport. That's where I discovered this site was down, and Keith fixed it over the course of the day. It turned out to be related to the Tomcat/MySQL Connection - which was preventing the AJP Apache/Tomcat connector from starting. Restarting MySQL fixed the problem.

BTW, if you're flying Delta on your next trip - didja know you can check-in online 6 hours before your flight? You just print out your boarding pass and show it at the gate. Very cool in my book.

Posted in General at Jan 27 2003, 08:00:40 PM MST Add a Comment

xPetstore v2.2 Released!

I haven't looked at it much or used it at all, but it sounds good.

xPetStore is a WODRA (Write Once, Deploy and Run Anywhere) implementation of Sun PetStore application based on the following opensource tools/framework:
- XDoclet
- Struts
- SiteMesh

If you're writing web applications (and you're using Struts or Webwork) and you're NOT using XDoclet (or one if it's derivatives - i.e. Middlegen), you're wasting your time (IMHO). Of course, I also believe that if you're not using Ant to build your java-based project, you're really wasting your time.

Hmmm, while over at the WebWork site, I stumbled upon this Eclipse + Resin + WebWork + Hibernate tutorial. I don't know if it's such a good idea to call your persistence layer directly from your servlets is it? Shouldn't that be in a Business Delegate - or am I losing focus of KISS and trying to follow too many patterns? Patterns give me more opportunities for Unit Testing. The only way to test this servlet would be something like Cactus, right? As always, to each his own... ;-)

Posted in Java at Jan 19 2003, 10:24:25 PM MST 1 Comment

Java-based Forums and Free Software

I've always thought that Jive was a great product, especially when I first found it. It was free then, now it costs $450. It it worth it - yes! But it's tough to recommend this to clients when there are free alternatives. Here's one courtesy of Mathias Bogaert:

Discovered mvnForum, a JSP 1.1/Servlet 2.2 based forum application (GPL), which looks kinda neat...check out their demo.

I have this same problem at work. I told my project manager that I knew of three Bug Tracking systems: Bugzilla, JIRA and Scarab. I currently use Bugzilla for a client and I'm familiar and happy with it. I also use JIRA for Roller and XDoclet, and think it's a great piece of software. Even though I've never used Scarab, I installed it thinking that it was better than Bugzilla, and also b/c the guys from Apache are moving to it. After wrestling with the setup a bit, I got it working. Scarab's main goal seems to be ease of setup - they should take some lessons from Atlassian. Actually, we all should - I had JIRA downloaded/installed/running in under 5 minutes. Anyway, back to the point - I showed Scarab to my project manager and he went off to investigate. An hour later he came back and said he just didn't get it. I didn't have the bandwidth to investigate, and since I've never used it - we're going to use Bugzilla. I prodded and poked and tried to get JIRA; I even downloaded and installed the 30 day trial. No joy, free is what they want.

Speaking of free software, I'm inspired to do some work on Roller - especially with all the stuff that Dave and Lance have done lately. Also, my RSS feed seems to refresh old stories in Radio's aggregator, so I'm due for an upgrade. I hope to add some of the following features over the next week or so (when do we release 0.9.7?):

  • Encypted password support - both programmatically and using Tomcat's Realm. The way I've done this in the past is to create a LoginServlet that my form-based authentication maps to. This servlet does the encryption and redirects to j_security_check. I'll also include an option for an SSL-based login. Both password encryption and SSL will be off by default - and changes will be allowed in web.xml.
  • Remember Me. You're gonna love this - I sure do.
  • Remember Me in Comments. It's definitely needed if you do a lot of commenting. The question is - do you automatically do it - or allow users to say "forget me." Auto is easiest.
  • Add support for e-mailing comments and subscribing to comments when posting a comment.
  • Dig into XDoclet and make the upgrade to 1.2 Beta 2 - fixing the bug we have with Castor. I hope I'm familiar enough with how XDoclet works to make this happen. I looked through the code today and it should be working from what I can tell.
  • Upgrade to Struts 1.1 Beta 3.

Sheez! I just created a whole bunch of work for myself didn't I? Hmmm, now how do I schedule all this and get it done in a week? A late night, an early morning, a weekend? I can't decide... Oooh, here's an idea - Julie and Abbie are leaving for Florida next Thursday (I'm joining them Friday) - I could do it next Thursday night. Hopefully I can get it done sooner, but hopefully a lot of this can wait until then.

Posted in Java at Jan 15 2003, 09:47:48 PM MST 1 Comment

Remember Me Rocks!

I have to thank Erik for the idea of implementing "remember me" functionality. I just implemented it this morning on my current project, and it's already saving me time. I used to have to re-login each time after I re-deployed. No more, just refresh!! I love it - thanks Erik!

BTW, I ended up fixing the saving-bad-password problem by adding another cookie to the mix. This one is called authenticated and is set by my ActionFilter servlet, which filters my protected resources. Good stuff - I'll be adding it to struts-resume, and possibly Roller (is this a good feature to add?).

Posted in Java at Jan 14 2003, 09:37:29 AM MST 1 Comment

Simple Intentions turn into Remember Me Login

I woke up this morning, and had the simple intention of blogging about one of my favorite tools, The Color Schemer. If you're a wanna-be designer like me, it's awesome. It helps you match "like" colors and also allows you to select any color on your screen. It's one of my most invaluable web design tools. Putting a tip about this was my only hope at 4:30 when I sat down at this computer. Now it's 5:39.

Why am I still here? I got caught up in reading the Colorado Bloggers mailing list - which actually got some traffic yesterday. This is one of the first times I've received a message from the list. One of the members pointed me to a another Photo Album for the web. It's called Gallery and she has an example setup. Looks like it runs on PHP. Well that shouldn't have taken me an hour, right?

The activity that's filled my last hour has been wrestling with Erik Hatcher's request for "remember me" functionality in a J2EE app, using container-managed security. The good news is that I did get it working - here's how:

  1. First, I added a checkbox called "rememberMe" to my login.jsp. When the user clicks "submit", I do some JavaScript logic. This logic entails saving the username and password as cookies - but only if the rememberMe checkbox is checked. If rememberMe is checked, a cookie is set called "rememberMe" with a value of "true."
  2. Using Roller's BreadCrumbFiler (maps to /*), I added some logic to check for the existence of the "rememberMe" cookie, and if it exists, to route the user to "j_security_check?j_username="+usernameCookie+"&j_password="+passwordCookie.

This all worked fine and dandy right off the bat - took me about 10 minutes to implement. The problem was that a user couldn't "logout." So I've spent the last hour (now it's been an hour and 1/2) with my own ignorance trying to delete cookies (and doing null checks and such) so users could logout. And I just got it working - fricken sweet! What a way to start the day! The only problem I could see now is if a user tries a username/password and selects "remember me", but then closes their browser. The BreadCrumbFilter will keep trying to authenticate them - yep, I just verified that that's a problem. It's also a problem when they enter an invalid password and select rememberMe.

One way to solve this is to not set the "rememberMe" and "password" cookies until someone has successfully authenticated. Maybe I could use the breadcrumbs in the BreadCrumbFilter to check the last URL accessed, and if it's already j_security_check, don't do the routing. Anyway, here's the code that does the heavy lifting in BreadCrumbFilter:

Cookie rememberMe = RequestUtil.getCookie(request, "rememberMe");
// check to see if the user is logging out, if so, remove the
// rememberMe cookie and password Cookie
if (request.getRequestURL().indexOf("logout") != -1 && 
	(rememberMe != null)) {
    if (log.isDebugEnabled()) {
        log.debug("deleting rememberMe-related cookies");
    }

    response =
        RequestUtil.deleteCookie(response,
                                 RequestUtil.getCookie(request,
                                                       "rememberMe"));
    response =
        RequestUtil.deleteCookie(response,
                                 RequestUtil.getCookie(request,
                                                       "password"));
}

if (request.getRequestURL().indexOf("login") != -1) {
    // container is routing user to login page, check for remember me cookie
    Cookie username = RequestUtil.getCookie(request, "username");
    Cookie password = RequestUtil.getCookie(request, "password");

    if ((rememberMe != null) && (password != null)) {
        // authenticate user without displaying login page
        String route =
            "j_security_check?j_username=" +
            RequestUtils.encodeURL(username.getValue()) +
            "&j_password=" +
            RequestUtils.encodeURL(password.getValue());

        if (log.isDebugEnabled()) {
            log.debug("I remember you '" + username.getValue() +
                      "', authenticating...");
        }

        response.sendRedirect(response.encodeRedirectURL(route));

        return;
    }
}

I can post the code for RequestUtil if you need it. The class RequestUtils (for encoding URLs) is a Struts class.

Posted in Java at Jan 14 2003, 06:07:21 AM MST 4 Comments