Hi,
I am trying to use JSTL in my JSP.
My class is like this:
package myclasses;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class MyJstl extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
String[] music = {"1","2","3","4","5"};
req.setAttribute("music",music);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/MyJstlJsp.jsp");
rd.forward(req,res);
}
}
And Jsp is
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><body>
<c:forEach var=arr items=${music} scope="session">
<tr>
<td>
${arr}
</td>
</tr>
</c:forEach>
</body></html>
And DD is like this:
<servlet>
<servlet-name>MyJstl</servlet-name>
<servlet-class>myclasses.MyJstl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyJstl</servlet-name>
<url-pattern>/MyJstl.do</url-pattern>
</servlet-mapping>
But when i Try to call the Servlet with servletcontext/MyJstl.do
I get 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
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:365)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:151)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:351)
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:171)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:455)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:516)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1564)
at org.apache.jasper.compiler.Parser.parse(Parser.java:173)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:251)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:152)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:139)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:288)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:756)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:524)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:452)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:361)
at myclasses.MyJstl.doGet(MyJstl.java:11)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:288)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:562)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:930)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:183)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:562)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:930)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2735)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:177)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:562)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:930)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:562)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:930)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:203)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:637)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:463)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:568)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:631)
at java.lang.Thread.run(Thread.java:536)
I have already added the jstl.jar inside the lib folder under WEB-INF.
Please help