Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

Saturday, December 1, 2012

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.

Tuesday, August 2, 2011

Java & I - My Java Development experience

Over the years I worked with various versions of Java through 1.6. But, Java was never my main bread & butter. Irrespective of the environment there was always some flavor of Java used in the development environment.

Java Swing, Applet etc
I started working with Java 1.0, many years ago. All those books and web sites with applet code with flashy animations made it look really interesting. (Real applet experience was totally different though!). Since then, I've worked in Java on and off. For a few years, I worked in a Java swing building Java applet (2MB jar!!) against a Forte Server. This included working with Visual Cafe, Visigenic CORBA, IDL files etc. Then I had chance to upgrade the application Java 1.2.

J2EE?!
Later, I got a chance to work on a J2EE application against Oracle. This ran in Apache and JBOSS. Java bean, EJB, Servlets, JSP and the whole nine-yards of typical Java developer's field. Then I got contracts to work on PB and VB. I kept in touch with Java though.

Java as a reporting tool
Couple of years ago, I got back into Java when I worked on a Java reporting package based around BIRT Java API for working with Excel files. (I think it's owned by Actuate now). The Java program was part of the batch environment on UNIX. We used it to generate Excel reports (with multiple worksheets) to be sent to users via e-mail. This was a challenging project.

Java Stored Procedures
Recently I got a change to work on yet another Java flavor. As mentioned elsewhere, where  I work currently, the environment is mainly in Powerbuilder and Oracle. Every now and then we find some surprises (in the last 18 months I've learned to expect there). There are a lot of Java packages/programs built around the PB application. These run on EA Server's Java container and use CORBA layer to talk to the PB application. The one I worked recently was slightly different. It was not the usual JDBC application, but a Java Stored procedure(s) that runs inside Oracle. I ended up in cleaning up the code, setting up a development environment around Eclipse and Ant and setting standards for other developers.

Java JSP, Coldfusion
We also have a lot of JSP pages that use CORBA to talk to our PB application through IIOP/CORBA. Recently we started building Coldfusion pages. While trying to help the developers to interface with our PB application, I realized that Coldfusion has been completely rewritten in Java. Coldfusion server was running on a Linux box. To get this to work with our Powerbuilder (EA) server, we needed a Visigenic product. (I eventually wrote a Java class that interfaces with the CORBA thus isolating Coldfusion from CORBA thus saving money for the company).

So many places, so many flavors. I've been having fun with Java. I hope to share some of these experiences here. In the coming posts, I will go into more detail about these Java experiences, hoping it would benefit some newcomers.