Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in JSTL  RSS feed

 
paramasivam Ramu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
I worked a example in HFSJ.


servlet program:

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class Movie extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String movielist1[]={"amelie","return of the king"};
ArrayList AL=new ArrayList();
AL.add(movielist1);


request.setAttribute("moviename",AL);

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



JSTL coding:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<strong>Movie List</strong>
<table>
<c:forEach var="movie1" items="${moviename}">
<tr>
<td>${movie1}</td>
</tr>
</c:forEach>
</table>
</html>



In the book the output is given:
amelie
return of the king

but i got the output the object of the ArrayList.

what is the wrong in the coding?
plz explain.

regards,
P.Ramu
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you have ArrayList of Array.
$movie1 is array of String
Try
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!