Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL is not working with JSTL

 
suja changanam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EL is not working with JSTL

My Application config. is:

Servlet Engine: 2.4
JSP Engine: 2.0
Application Server: Apache Tomcat/5.5.27

The servlet is :
//com\MyServlet.java

package com;
import javax.servlet.ServletException;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

public class MyServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
String username="suja";
request.setAttribute("username1",username);
RequestDispatcher view=request.getRequestDispatcher("/result.jsp");
view.forward(request,response);
}
}

The Jsp is:
result.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:out value="${username1}" default="hello" />
</body>
</html>

The xml file is :
web.xml
<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/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>MyJsp</servlet-name>
<jsp-file>/result.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>MyJsp</servlet-name>
<url-pattern>/show</url-pattern>
</servlet-mapping>
</web-app>

My web application name is jstl4 and tomcat/webapps contains

webapps->jstl4->result.jsp
webapps->jstl4->WEB-INF->classes->com->MyServlet.class
webapps->jstl4->WEB-INF->web.xml
webapps->jstl4->WEB-INF->lib->jstl.jar
webapps->jstl4->WEB-INF->lib>standard.jar


when i run the application,the browser shows the output : hello
It seems the EL is not working .
can you please suggest me where is wrong
Thanks
Suja


 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suja. EL is working. The problem is you are not sending request to servlet(MyServlet).
 
suja changanam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Chinmaya for you reply.

I changed the <jsp-file> to <servlet-class>
Now it's working.

Thank you
Suja
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic