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.

[ANN] AppFuse Light 1.0 - a.k.a. Equinox

For those of you looking for an AppFuse Light, I have good news for you. I've actually been sitting on it for several months now, but now I'm prepared to release it. It's name is Equinox and it's much, much simpler than AppFuse. Equinox has only one build-time dependency (CATALINA_HOME being set for the servlet-api.jar). There's no code generation and no features - not even security. However, it supports building, testing and deploying from Ant, and even has support for managing Tomcat out-of-the-box.

To get started with Equinox, you can download the QuickStart Chapter from Spring Live. This chapter shows you how to develop a simple webapp using Struts, Spring and Hibernate - which talks to an HSQL database. Struts and Spring are integrated using the ContextLoaderPlugin and all tests are designed to be run out-of-container using JUnit and StrutsTestCase. Equinox ships with project files for both Eclipse and IDEA so you can develop and run the tests in either of these top-notch IDEs. There's also a demo available. Thanks to Boér Attila for the kick-ass CSS.

If you like what you see in the QuickStart Chapter, there's much more in the other ERP chapters of Spring Live - now available for download. Too see what's in the other chapters, checkout the Chapter Summaries.

This is a nice milestone - feels good to have made it this far. Have a good weekend!

Posted in Java at Jul 09 2004, 04:38:01 PM MDT 34 Comments

Jetty and WebSphere suck, JRun and Tomcat rule the pack

I've been looking for an app server performance comparison for some time now. Maybe those folks that say Tomcat sucks and Jetty rules will change their tune. Via Lasse Koskela:

Web Performance Inc. has published a very interesting report, which included a couple of surprises. Jetty pretty much sucked, JRun was one of the top guns, and Tomcat wasn't too far behind JRun.

Anyone know of any similar (recent) comparisons?

Posted in Java at Jul 02 2004, 02:59:21 PM MDT 9 Comments

Maven's ibiblio repository: nicely out of date

I have a feeling that Maven and I will never quite get along. I live on the bleeding edge, because you have to if you want to keep up with open source. I'm using Hibernate, Spring and JSTL in my Maven sample app. Hibernate is pretty up to date - ibiblio has 2.1.3 and 2.1.4 is the latest. Spring's JARs aren't too bad - 1.0.1 vs. 1.0.2 being the latest release. So much for getting spring-mock.jar quick and easy - since it's part of 1.0.2. JSTL is one version behind too.

Lesson learned: if you want to stay on the bleeding edge, don't use Maven. I suppose another option is to become the guy who uploads these new versions. That job looks rather complicated though. I'm guessing that most folks are simply maintaining their own repositories (or staying away from the bleeding edge).

Posted in Java at Jun 25 2004, 09:41:31 AM MDT 8 Comments

Using JAAS with Tomcat

Want to use JAAS with Tomcat? If so, you might want to checkout this Using Tomcat with JAAS tutorial.

Although it is possible to use JAAS within Tomcat as an authentication mechanism (JAASRealm), the flexibility of the JAAS framework is lost once the user is authenticated. This is because the principals are used to denote the concepts of "user" and "role", and are no longer available in the security context in which the webapp is executed. The result of the authentication is available only through request.getRemoteUser() and request.isUserInRole().

This reduces the JAAS framework for authorization purposes to a simple user/role system that loses its connection with the Java Security Policy. This tutorial's purpose is to put a full-blown JAAS authorisation implementation in place, using a few tricks to deal with some of Tomcat's idiosyncrasies.

Personally, request.isUserInRole() usually does everything I need. If I need something more than that, it's usually pretty easy to add some custom logic. Of course, if I ever need anything super robust, I'll probably use the Acegi Security System for Spring.

Posted in Java at Jun 03 2004, 10:30:27 AM MDT 3 Comments

How do you make your source tree Eclipse/JUnit friendly?

I've never had a problem getting builds and unit tests to work with Ant. However, unit tests run faster in an IDE, so I'm trying to refactor some code to allow for testing in the IDE. My current directory structure looks like this:

-- project
   - web
     - WEB-INF
       - classes

I need both "WEB-INF" and "WEB-INF/classes" in my classpath. There's XML files under WEB-INF for Spring and Commons Validator, and there's a log4j.xml under WEB-INF/classes for log4j. These files are all in their natural locations as far as all the projects I've seen. However, Eclipse won't allow me to nest classpaths - so it's virtually impossible (as far as I know) to add both directories to my classpath. Any ideas how to workaround this Eclipse "feature" are appreciated.

For those "IDEA is better" folks - I agree. IDEA allows me to add web, web/WEB-INF and web/WEB-INF/classes to my classpath with no issues.

Posted in Java at Jun 02 2004, 12:46:10 AM MDT 6 Comments

Converting AppFuse to use Spring for MVC

It's been a long and painful week - with 3 or 4 nights where I was up to 4 or 5 in the morning. Last night I was up until 4:30 and Abbie woke me up promptly at 7:30. Ugh, sleeping more is probably a good idea. I started on the Spring MVC layer for AppFuse on Thursday night and it took me almost 2 days to convert everything. There's still a few kinks and workarounds - but if you're running it through a browser, everything works the same as it did with the Struts version. The hardest part about it was writing the unit tests. With Struts, it's rather easy b/c I use StrutsTestCase, which provides a very simple API for testing Actions. I'm sure Spring will soon have this same capability with its Servlet API Mocks, but I was definitely banging my head against the wall a few times. I did manage to convert the LabelTag to recognize required fields and error messages. The JSP conversion was a slight pain - but mostly because you have to type a lot more for input fields than you do for Struts. I'm looking forward to WebWork which requires one line to do the whole table row. It has Velocity templates for its tags and they write the <tr>, <label> and the <input>. Pretty slick IMO - less typing is always attractive to me.

I'd like to write-up a detailed entry on "migrating from Struts to Spring" on JRoller, but it's been flakey over there for a few days now - so I might just do it here. We'll see - the lack of sleep is draining my motivation to write. I hope to do the Ant-based installation for Spring in the next couple of days - then I'll release 1.5 beta. My main reason for the beta is because the Spring stuff can probably be cleaned up a lot, as well as it gives me time to write documentation before the final release.

Posted in Java at May 02 2004, 09:17:54 AM MDT 5 Comments

Populate your drop-downs with listeners and allow for refreshing

Most webapps have drop-downs (a.k.a. pick lists) that users select from when filling in forms. Spring has a nice referenceData method on its Controllers that you can use to populate these, but I prefer a different way. In AppFuse, I populate these using a ServletContextListener. However, one of the problems with using this is that your drop-downs won't get refreshed unless you have admins screens or a way to reload the attributes set in the listener.

In short, I think it's a good idea to load drop-down options in a listener and also have an action or servlet to refresh these options. For examples, see StartupListener.java and ReloadAction.java. Got a better way? I'm interested...

Posted in Java at Apr 29 2004, 04:50:55 PM MDT 4 Comments

Weather.com: WebSphere to Tomcat and Oracle to MySQL

At my current client we're going to migrate our application from Tomcat to WebSphere 5 in May. I'm dreading the move and really don't see the point, but alas - the client is always right. However, since my client reads this website, I thought maybe they'd be interested to see that Weather.com recently migrated from WebSphere to Tomcat.

"It was hard to run WebSphere and an IDE [integrated development environment] because of all the resources WebSphere took," recalls Jeff Cunningham, who leads the Internet application development team at Weather.com. "You had to run an instance of DB2 on your machine because WebSphere stored its configurations in DB2, so you had to have all that overhead. It was just really slow. I just started using Tomcat for development because it was so much faster."

The article goes on to say that they evaluated other app servers as well, but chose Tomcat because of the team's preference. They also discovered that Tomcat served up pages significantly faster than WebSphere.

Weather.com is also working on swapping out its Oracle database for the open-source MySQL.
...
"Now when I talk to senior management about moving from Oracle to MySQL they don't ask me, 'Are you sure?'" he says. "They ask me, 'When?'"

It's a great time to be an Open Source Consultant. ;-)

Posted in Java at Apr 29 2004, 11:05:57 AM MDT 16 Comments

What should we do with Tiles?

There's some discussions taking place on the Struts Developer Mailing List about what to do with Tiles. Tiles is gaining popularity in frameworks other than Struts - i.e. Spring and JSF. Personally, I don't mind that Tiles is buried deep inside struts.jar b/c it's basically the difference between a 500 KB JAR and a 100 KB JAR - and disc space is cheap! However, an advantage of extracting Tiles from Struts is that it then has the opportunity to become friendlier to other web frameworks. I'd even like to see a Sitemesh-like Filter so you could do Sitemesh stuff with Tiles. Or maybe just bundle Sitemesh with Tiles as a kick-ass templating engine.

So the question is: What should we do with it? Should it become a Jakarta Commons project or a Jakarta Project? Or even a java.net project? Tiles Users - we need your feedback!

Posted in Java at Apr 28 2004, 11:35:00 AM MDT 16 Comments

Logout your users automatically after their session times out

One of the common issues I see in webapps is a user leaves their computer, their session times out, and when they come back to do something - the app throws errors b/c their session is null. There are several easy ways to fix this. If you use Container Managed Authentication, the user will likely be prompted to do login and can continue as before. If you're using a slick Remember Me feature (like AppFuse has), the user won't even notice. However, you might not have these options available to you. For those circumstances, I recommend you put a meta-refresh in your app to automatically show the uses a timeout message when their session expires. It's as simple as the following:

<meta http-equiv="Refresh" 
  content="${pageContext.session.maxInactiveInterval}; url=timeout.jsp"/>

I used JSP 2.0's EL in this example for simplification. If you're using a JSP 1.2 container - you'll have to wrap that expression with a <c:out> tag.

Posted in Java at Apr 24 2004, 07:33:10 AM MDT 8 Comments