Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic