| | |
Problems with JSTL
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2005
Posts: 2
Reputation:
Solved Threads: 0
Hi I use the tag library and i have following Problem.
<c : out value="${nickname}"/>
Output of this statement is ${nickname} and not the value of the variable nickname. I have no clue what i m doing wrong. jar's and tld's are in the right directory.
Following is on the top of my jsp.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
using Tomcat 5.X
<c : out value="${nickname}"/>
Output of this statement is ${nickname} and not the value of the variable nickname. I have no clue what i m doing wrong. jar's and tld's are in the right directory.
Following is on the top of my jsp.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
using Tomcat 5.X
what variable 'nickname' are you trying to output?
JSTL will use any named attribute from the pagecontext, not something you created in a Java block on the JSP (in fact you should avoid those like the plague).
JSTL will use any named attribute from the pagecontext, not something you created in a Java block on the JSP (in fact you should avoid those like the plague).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Jun 2005
Posts: 7
Reputation:
Solved Threads: 0
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:
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.
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:
JSP Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app 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 http://java.sun.com/xml/ ns/j2ee/web-app_2_4.xsd" version="2.4">
•
•
•
•
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.
You need a 2.4 servlet container ONLY to use JSTL 1.1. The questions are clearly related to JSTL 1.0 which is part of the 2.3 spec (though may need separate installation of the JSTL jars depending on appserver in use).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
•
•
Originally Posted by bpk
This is a Tomcat-specific issue with the Apache JSTL implementation. If you don't use a 2.4 web.xml, the EL expressions don't get evaluated in the JSP.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- JSTL compare string (JSP)
- No time... bitch load of problems (Windows NT / 2000 / XP)
Other Threads in the JSP Forum
- Previous Thread: plz suggest me a online mini project topic
- Next Thread: Array String not working?
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






