Gotcha: JSP includes

This is related to my earlier post. When we fixed the issue in Servlet Filter in the JSP Web Application we were troubleshooting it went past the first page. We landed on a blank page this time!! We were testing in a mirror site that I had created. According to the developer, the original site work and the new mirror site was having this issue.

To cut the long story short, this was caused by a change developer added to a JSP file to invalidate session. This file was included in the main JSP page that was erroring out. After some digging, I found out that the original JSP wasn’t compiled in a while (See below). Bingo! I made it to recompile, and the original site also failed at the same place. This proved the invalidate() added to be culprit.

JSPs are just short hand notation for Java Servlet. It lets the developer/page designer to code the page using HTML like tags. The first time the user accesses the JSP file, the Servlet container automatically generates and recompiles a Java Servlet for the JSP file. After the first time, this step of generate/compile is skipped. In development we could make the Server to recompile each time the JSP file is changed. This works fine. The problem in our case was that an included file was changed and since the main JSP file itself did not change, the Server didn’t bother to regenerate the Servlet class.

The lesson learned is not to believe what you see or not see on a JSP page. Always make sure your JSP is compiled up-to-date. To do this, you could use the compiler that comes with the Server (Servlet container) software. Most Servers (for e.g., Apache Tomcat, IBM Websphere, Sybase EA Server) come with a command line script called jspc. Another approach is to clear the your Server’s work directory. See here for a discussion of this.

Advertisements

Comments, please?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s