aspose file tools*
The moose likes JSP and the fly likes JSP EL not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP EL not working" Watch "JSP EL not working" New topic
Author

JSP EL not working

kasthala shyam
Greenhorn

Joined: Jun 14, 2008
Posts: 3
Hi all,

I have written a simple jsp custom application.
I am getting the value of username when i use scripting but not getting the value of username when i try this ${username} in my JSP.
I am using tomcat 5.0 and jstl (jakarta-taglibs-standard-1.1.2).
Please let me know where i am going wrong.
Thanks in advance.
Following are my files in the webapp:

HelloTag.jsp
------------
<%@ page language="java" contentType="text/html" %>
<%@ taglib uri="WEB-INF/lib/mytags.tld" prefix="mytag" %>

<html>
<head><title>Custom Tag Demo</title></head>
<body>
<form name="myform" method="post">
username:<input type="text" name="username">
<input type="submit">
</form>
Here is custom content: <mytag:hello user="${username}"/>
</body>
</html>

mytags.tld
----------
<?xml version="1.0" encoding="ISO-8859-1"?>

<taglib 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-jsptaglibrary_2_0.xsd" version="2.0">

<tlib-version>1.0</tlib-version>
<short-name>mytagslib</short-name>
<uri>randomThings</uri>
<tag>
<description>My Custom Tags Library</description>
<name>hello</name>
<tag-class>mytags.HelloTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>user</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

web.xml
-------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<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">

<servlet>
<servlet-name>HelloTag</servlet-name>
<servlet-class>mytags.HelloTag</servlet-class>
</servlet>

<taglib>
<taglib-uri>randomThings</taglib-uri>
<taglib-location>WEB-INF/lib/mytags.tld</taglib-location>
</taglib>

</web-app>

HelloTag.java
-------------
package mytags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class HelloTag extends TagSupport
{
public String user;
public void setUser(String user) {
this.user = user;
}
public int doStartTag()
{
try
{
JspWriter out = pageContext.getOut();
out.print("Hello from custom tag!");
out.print("Hello" + user + "<br>");
}
catch (IOException err)
{
System.out.println("Error:" + err);
}
return (SKIP_BODY);
}
}
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Web.xml you have is pointing to 2.3.dtd.
Try changing to 2.4 spec

like this


SCJP 1.4 SCWCD 1.4 SCDJWS 1.4
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61587
    
  67


You are using both the 2.3 DOCTYPE and the 2.4 schema declaration. Use only one: the 2.4 schema.
[ June 14, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP EL not working