页面不是重定向

时间:2011-04-29 07:09:03

标签: java jsp servlets

org.apache.jasper.JasperException:JSP中的异常:/views/header.jsp:14

11:         <a href="<%=request.getContextPath()%>">Home</a> | 
12:         <% String username=(String)session.getAttribute("formdata");
13:         String admin="admin";
14:         if(username.equals(" ")){
15:             
16:             String logout="http://localhost:8080/NewsBank/logout.do";
17:             response.sendRedirect(logout);

堆栈跟踪:

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.lang.NullPointerException
    org.apache.jsp.views.addStory_jsp._jspService(addStory_jsp.java:93)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

1 个答案:

答案 0 :(得分:3)

username对我来说似乎null

检查无效

if(username != null || "".equals(userName)){
//your code
}

<强>建议:

  • 我们有Filter这个(身份验证检查)目的为什么破坏jsp?

  • Avoid在JSP上编写javacode


另见