View Single Post
Join Date: Jun 2005
Posts: 7
Reputation: bpk is an unknown quantity at this point 
Solved Threads: 0
bpk bpk is offline Offline
Newbie Poster

Re: Problems with JSTL

 
0
  #4
Jul 8th, 2005
When you reference ${nickname} from JSTL, what the JSP is doing is looking in either the request object for a nickname attribute or the session object [i.e., request.getAttribute("nickname")]. So if you want to use ${nickname} from JSTL but set it in your servlet, then do request.setAttribute("nickname", "My Nickname");

If you want to set values in the JSP, then use the <c:set> JSTL tag.

The most important thing about getting JSTL to work, and is documented almost no where, is you have to use a Servlet 2.4 style web.xml instead of a Servlet 2.3 style web.xml.

To do this, make sure the top of your web.xml looks like this:

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/
  5. ns/j2ee/web-app_2_4.xsd"
  6. version="2.4">
From the sound of things, this might actually be your problem, because if you're using a 2.3 style web.xml, then I don't think it will recognize the EL expressions. ${nickname} is an EL expression.
Reply With Quote