• 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

how to get jstl working

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ref page 437 example from HFSJ. My output is just movielist and no movies listed after that. can someone please help me.

Here is my code from the servlet

public class cforeach extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{


String[] movieList = {"Amelie", "Return of the king", "Mean Girls"};
request.setAttribute("movieList", movieList);

RequestDispatcher view = request.getRequestDispatcher("testjstl.jsp");
view.forward(request, response);

}

}

My code from the JSP is

<%@ taglib prefix ="c" uri = "http://java.sun.com/jsp/jstl/core" %>

<html>

<body>
<%@ page isELIgnored="false" %>

<strong> Movie List </strong>
<br> <br>

<table>

<c:forEach var="movie" items="${movieList}">

<tr>

<td>${movie}</td>

</tr>
</c:forEach>

</table>

</body></html>
 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried out your code as it as and it works for me.

Output:
Movie List

Amelie
Return of the king
Mean Girls

I dont see anything wrong with the code.
 
Harish Yerneni
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Amit. Instead of accessing the servlet from the browser, I was accessing the jsp directly. Thats why, the browser could not see the request object.

Thanks,

Harish
reply
    Bookmark Topic Watch Topic
  • New Topic