HowTo: Upgrade your app to JSP 2.0
I did some more playing with Tomcat 5.0.4 today - and converted appfuse to a JSP 2.0 application. After accomplishing this task, I created a "jsp-2" task that can (optionally) be run at build time, and whalla, you've got a Servlet 2.4/JSP 2.0 application. I learned a number of things in the process.
1. The expression language in JSP 2.0 replaces in JSTL is <c:out>, that's it. I was under the impression that I could use <c:if> or <c:forEach> tags without declaring the tag library URI, etc. I was wrong, if you want to use JSTL tags, you must import the declare the taglibs, just like you do now in Tomcat 4.x.
2. The EL is turned off by default if you have a 2.3 DTD for your web.xml. If you have a 2.4 XSD in web.xml, the EL is turned on by default. This means that you can write ${param.foo} and it will be analyzed when the EL is on (when off, it's not analyzed).
3. You can replace <html:rewrite page=""/> with <c:url value=""/> and get the same effect. The only difference is that html:rewrite is context and module-sensitive, whereas c:url is only context-sensitive.
4. I had to replace the URI's for JSTL core and fmt with their run-time URIs - http://java.sun.com/jstl/core_rt vs.
http://java.sun.com/jstl/core. Otherwise, I would get something similar to the the following error.
According to TLD or attribute directive in tag file, attribute test does not accept any expressions
I figure upgrading to JSTL 1.1 might solve this issue, but since it hasn't been released, why bother? So to convert appfuse to be a JSP 2.0 webapp, here's what my Ant task does:
- Replaces URIs with their run-time equivalent.
- Removes <c:out> tags, leaving the value of the "value" attribute intact.
- Replaces 2.3 DTD in web.xml with 2.4 XSD.
I did some (rough) benchmarking of running my JSP tests, here are the results on a Pentium IV (2 GHz, 512 MB RAM).
start Tomcat, run tests, stop Tomcat:
Tomcat 4.1.24: 1 minute, 17 seconds
Tomcat 5.0.4: 1 minute, 7 seconds
Tomcat 5.0.4/JSP 2.0: 1 minute, 3 seconds
run tests, Tomcat already started:
Tomcat 4.1.24: 33 seconds
Tomcat 5.0.4: 22 seconds
Tomcat 5.0.4/JSP 2.0: 22 seconds
According to these numbers, Tomcat 5 is quite a bit faster than 4.1.x.
Posted by David on July 28, 2003 at 04:46 PM MDT #
Posted by Matt Raible on July 28, 2003 at 05:34 PM MDT #
Posted by Matthias on April 09, 2004 at 03:42 PM MDT #
Posted by 125.17.97.162 on April 05, 2008 at 10:09 AM MDT #
Posted by Stefan on December 25, 2008 at 08:57 PM MST #