Matt RaibleMatt Raible is a Web Developer and Java Champion. 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.

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 in Java at Jul 17 2003, 01:27:01 PM MDT 5 Comments
Comments:

can somebody send me a sample web.xml file that replaces the 2.3 dtd with the 2.4? Thanks David

Posted by David on July 28, 2003 at 10:46 AM MDT #

Replace your DTD and <web-app> element with the following:
<web-app version="2.4" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd">

Posted by Matt Raible on July 28, 2003 at 11:34 AM MDT #

Nice idea but <c:out> is not obsolete. Plain EL-Expressions are not escaped. Welcome scripting attacks.

Posted by Matthias on April 09, 2004 at 09:42 AM MDT #

Hi Iam still getting this problem can any one help me out

Posted by 125.17.97.162 on April 05, 2008 at 04:09 AM MDT #

very helpful post! thank ya

Posted by Stefan on December 25, 2008 at 02:57 PM MST #

Post a Comment:
  • HTML Syntax: Allowed