Hello,
I try to practice the c:forEach. But I got errors. Can anybody tell me what's wrong with my code?
Servlet code:
****************************************
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class JstlTest extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String[] movieList={"Gone with wind","Road home", "tiger", "good bye"};
request.setAttribute("movieList", movieList);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);
}
}
********************************************
JSP code:
----------------------------------------------------------------
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><body>
<strong>movie list:</strong>
<br><br>
<table>
<c:forEach var="movie" item="${movieList}">
<tr>
<td>${movie} </td>
</tr>
</c:forEach>
</table>
</body></html>
-------------------------------------------------------------
I put jstl.jar in the WEB-INF/lib/
when I called servlet I got the error:
org.apache.jasper.JasperException: The absolute uri:
http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:316)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:147)
org.apache.jasper.compiler.Parser.parseTaglibDirective
So what's wrong? Do I need tld file? How can I let this program run?
Thanks a lot.
Anna