Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EL is not working with JSTL

 
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


 
Ranch Hand
Posts: 437
Oracle Java
  • 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
 
bacon. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic