dinsdag 19 februari 2008

jstl el troubleshooting

A comprehensive troubleshooting guide handling some common jstl/el mistakes:


My experience

1. Download the yakarta taglibs from here: http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi and copy the standard.jar and jstl.jar towards the /WEB-INF/lib/ folder of your webapp.

2. make sure to have the right web.xml declaration, at least 2.4

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

3. In your jsp pages define the taglibs like this (only the ones you need):
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

At this point jstl and el should work without the need of adding any tld definitions in the web.xml definition. You can put a javabean on the request in your servlet by this code:

Note that a javabean should always have a no args ctor and public setters and getters for private properties.

A great toturial on the MVC part of jsp/servlets/javabeans is this: http://courses.coreservlets.com/Course-Materials/pdf/msajsp/0B-MVC-Review.pdf

Geen opmerkingen:

Een reactie plaatsen