• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get jstl working

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic