2017-10-15 28 views
0

以下は私の.jspの一部です。JSP - HTTPステータス500 - 内部サーバーエラー

<%User user = (User) (session.getAttribute("user"));%> 
<b>Welcome <%= user.getFirstName() + " " + user.getLastName()%></b> 
<br/> 

そして、私はエラーの下に取得しています:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message An exception occurred processing [/home.jsp] at line [20]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception org.apache.jasper.JasperException: An exception occurred processing [/home.jsp] at line [20]

17: This is added information page
18: <%=new Date()%> 19: <%User user = (User) (session.getAttribute("user"));%> 20: Welcome <%= user.getFirstName() + " " + user.getLastName()%> 21:
22: 23: Logout

Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:593) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:482) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause java.lang.NullPointerException org.apache.jsp.home_jsp._jspService(home_jsp.java:139) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Note The full stack trace of the root cause is available in the server logs.

Apache Tomcat/9.0.1

誰かがplsは助けることはできますか?エラーは行20にあります。user(= session.getAttribute("user"))がnullであるため、

+0

[NullPointerExceptionとは何か、それを修正するにはどうすればいいですか?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix -それ) –

答えて

0

NullPointerExceptionがスローされます。

少なくとも、if (user != null) { ...を追加する必要があります。

関連する問題