Carcleo 4 Denunciar post Postado Julho 18, 2015 Alguém pode me ajudar? A idéia aqui é validar na classe a existência de uma variável de sessão criada em um servlet Meu jsp <%@ page import="java.util.*" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <jsp:useBean id="validaAdmin" class="dao.admin.TestaLoginAdmin" /> <c:set var="admin" value="${validaAdmin.testaLogin(request)}" /> <c:set var="redireciona" value="${validaAdmin.redireciona(request)}" /> <c:choose> <c:when test="${admin != null}"> ${admin.nome}; </c:when> <c:otherwise> ${redireciona}; </c:otherwise> </c:choose> Minha classe package dao.admin; import model.Admin; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class TestaLoginAdmin { public Admin testaLogin(HttpServletRequest request) throws ServletException, IOException { HttpSession sessao = request.getSession(); Admin admin = (Admin) sessao.getAttribute("admin"); if(admin != null) { return admin; } return null; } public void redireciona(HttpServletResponse response) throws ServletException, IOException { response.sendRedirect("index.jsp"); } } Erro: HTTP Status 500 - org.apache.jasper.JasperException: An exception occurred processing JSP page /_global/testaAdmin.jsp at line 5 type Exception report message org.apache.jasper.JasperException: An exception occurred processing JSP page /_global/testaAdmin.jsp at line 5 description The server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: org.apache.jasper.JasperException: An exception occurred processing JSP page /_global/testaAdmin.jsp at line 5 2: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 3: 4: <jsp:useBean id="validaAdmin" class="dao.admin.TestaLoginAdmin" /> 5: <c:set var="admin" value="${validaAdmin.testaLogin(request)}" /> 6: <c:set var="redireciona" value="${validaAdmin.redireciona(request)}" /> 7: 8: <c:choose> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause org.apache.jasper.JasperException: An exception occurred processing JSP page /_global/testaAdmin.jsp at line 5 2: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 3: 4: <jsp:useBean id="validaAdmin" class="dao.admin.TestaLoginAdmin" /> 5: <c:set var="admin" value="${validaAdmin.testaLogin(request)}" /> 6: <c:set var="redireciona" value="${validaAdmin.redireciona(request)}" /> 7: 8: <c:choose> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:934) org.apache.jsp.admin.principal_jsp._jspService(principal_jsp.java:89) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause org.apache.jasper.el.JspELException: /_global/testaAdmin.jsp(5,0) '${validaAdmin.testaLogin(request)}' java.lang.NullPointerException org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:123) org.apache.jsp._005fglobal.testaAdmin_jsp._jspx_meth_c_005fset_005f0(testaAdmin_jsp.java:161) org.apache.jsp._005fglobal.testaAdmin_jsp._jspService(testaAdmin_jsp.java:121) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:934) org.apache.jsp.admin.principal_jsp._jspService(principal_jsp.java:89) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause java.lang.NullPointerException dao.admin.TestaLoginAdmin.testaLogin(TestaLoginAdmin.java:13) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) javax.el.BeanELResolver.invoke(BeanELResolver.java:165) org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:147) org.apache.el.parser.AstValue.getValue(AstValue.java:159) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:115) org.apache.jsp._005fglobal.testaAdmin_jsp._jspx_meth_c_005fset_005f0(testaAdmin_jsp.java:161) org.apache.jsp._005fglobal.testaAdmin_jsp._jspService(testaAdmin_jsp.java:121) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:934) org.apache.jsp.admin.principal_jsp._jspService(principal_jsp.java:89) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/8.0.22 logs. Apache Tomcat/8.0.22 Alguém pode me ajudar? Pessoal, ainda não consegui resolver essa! Alguém pode me ajudar? Compartilhar este post Link para o post Compartilhar em outros sites