尝试使用Parameters从servlet重定向到JSP页面时出错

时间:2014-01-24 10:10:12

标签: java jsp servlets

尝试使用Parameters:

从servlet重定向到JSP页面时出错

我的Servlet代码如下:

       String name = "Test";
       request.setAttribute("name", name);
       RequestDispatcher view = request.getRequestDispatcher("/page.jsp");
       view.forward(request, response);

JSP页面如下:

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2370960</title>
    </head>
    <body>
         <p>Message: ${name}</p>
    </body>
</html> 

我收到以下错误:

 Jan 24, 2014 12:05:35 PM org.apache.jasper.runtime.JspFactoryImpl internalGetPageContext
 SEVERE: Exception initializing page context
 java.lang.NoClassDefFoundError: javax/el/StaticFieldELResolver
 at        org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:172)
at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:123)
at org.apache.jsp.captcha_jsp._jspService(captcha_jsp.java:34)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
... 35 more

请协助。

1 个答案:

答案 0 :(得分:0)

安装新版TomCat

ServletContext context = getServletContext();
RequestDispatcher rd = context.getRequestDispatcher("/page.jsp");
rd.forward(request, response);

确保路径正确