Earlier I introduced the Migrate to GlassFish project. Periodically, I will be taking examples to illustrate migrations to GlassFish. Here, I took the Tomcat example application and migrated it to GlassFish. Even though this is a simple example, it nonetheless illustrates a few of the deployment aspects of GlassFish.
First point to note is that no changes are necessary for the Tomcat sample application itself. Apache Tomcat version 6.0 implements the Servlet 2.5 and JavaServer Pages 2.1 specifications. GlassFish V2 implements which Java EE 5 which requires JSP 2.1 and Servlet 2.5. So you can can simply take the war file and deploy it as shown below:
Note that no other GlassFish server specific deployment descriptors (e.g. sun-web.xml ). The context root for the web application is derived from the war file name (in this case "sample"). You can acccess the sample application at http://localhost:8080/sample . If you access the URL, you should see "Hello World" application with two links to "JSP Page" and "Servlet" .
When deployed as shown above, the JSP in the sample application are compiled at runtime the first time the "JSP Page" link is accessed. However, it is possible to precompile JSP at deployment time as follows:
You will find the compiled JSP files can be found ingf-appserver-domain-dir/generated/jsp/j2ee-modules/sample . There are other ways to precompile JSP files. The above was just one way to do it.
Instead of war, you can deploy the sample application in an unpacked form. This is useful during development To do this:
I will be back with more examples.