JSP - sendRedirect不起作用

时间:2011-07-01 13:16:36

标签: jsp redirect glassfish-3

我有一个简单的jsp文件:

  String url ="";

    if(aController.find(Integer.parseInt(request.getParameter("id"))) != (null))
   {
        url += request.getParameter("name") + "&id="+request.getParameter("id") + "&__locale=" + LocaleUtil.setLocaleStringMail(request, response);
        url += "&__overwrite=true";
        System.out.println("this report has not been deleted");
        response.sendRedirect(url);
    }
    else{
     url += "error.rptdesign&__locale=" + LocaleUtil.setLocaleStringMail(request, response) + "&user="+report.getCreatorName();
        System.out.println("this report has been deleted");
        response.sendRedirect(url);
    }

进入第一个条件,系统输出并发送重定向。但是它不会进入其他地方并抛出异常:

[#|2011-07-01T16:29:08.595+0300|WARNING|glassfishv3.0|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=29;_ThreadName=Thread-1;|StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.user.report_005fredirect_jsp._jspService(report_005fredirect_jsp.java from :74)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at com.labristeknoloji.lcas.client.filters.SingleSignOutNameAddFilter.doFilter(SingleSignOutNameAddFilter.java:56)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:40)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:50)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at com.labristeknoloji.lcas.client.filters.LCASAuthenticationFilter.doFilter(LCASAuthenticationFilter.java:111)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:104)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at com.labristeknoloji.lrms.web.filter.LocaleFilter.doFilter(LocaleFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:329)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:229)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:334)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:814)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:743)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:936)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:682)
    at java.lang.Thread.run(Thread.java:619)

您对此有何看法? 提前谢谢。

1 个答案:

答案 0 :(得分:1)

这就是在JSP中编写scriptlet的美妙之处。你无法弄清楚在哪一行发生了什么。可能是您的aController为空。只是一个猜测。