我打算做一个简单的登录,根据用户的情况向您显示附加给您的账单。 。 。如果一个企业的成员正在尝试,我只需用equals验证他/她(“admin”,“jefearea”,“almacenero”)。 。 。问题是,当我成功登录非商业用户时,我得到了各自的账单,但当我点击“查看”按钮时,它给了我一个错误,这是我的页面
按下任何“查看”按钮后出现以下错误,即使我只是将其输出.println(“点击”)
HTTP Status 500 - Internal Server Error
这是我的日志
Advertencia: StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.PaginaUsuario_jsp._jspService(PaginaUsuario_jsp.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
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:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
这是我的代码
<body>
<%
Entrada_DAO objDAO = null;
ArrayList<BoletaBean> listabBOL = null;
%>
<form name="form1">
<table>
<tr>
<th>Boleta N°</th>
<th>Fecha</th>
<th>Estado</th>
<th>Total</th>
<th></th>
</tr>
<tr>
<%
String usu = request.getParameter("txtUsu");
String pas = request.getParameter("txtPas");
objDAO = new Entrada_DAO();
int estado = objDAO.GetSesionUsu(usu, pas);
if(usu.equalsIgnoreCase("admin") && pas.equalsIgnoreCase("admin"))
{
response.sendRedirect("Administrador.jsp");
}
else if(usu.equalsIgnoreCase("jefearea") && pas.equalsIgnoreCase("jefearea"))
{
response.sendRedirect("JefeDeArea.jsp");
}
else if(usu.equalsIgnoreCase("almacenero") && pas.equalsIgnoreCase("almacenero"))
{
response.sendRedirect("Almacenero.jsp");
}
else
{
if(estado == 0)
{
response.sendRedirect("EntradaSistema.jsp");
out.println("Credenciales incorrectas");
}
else if(estado == 1)
{
int codigo = 0;
codigo = objDAO.GetCodigoSocio(usu);
listabBOL = objDAO.DetalleBol(codigo);%>
<%
try
{
for (BoletaBean objOCBEAN: listabBOL)
{%>
<td> <%=objOCBEAN.getCodigoBOL()%> </td>
<td> <%=objOCBEAN.getFecha()%> </td>
<td> <%=objOCBEAN.getEstado()%> </td>
<td> <%=objOCBEAN.getMonto()%> </td>
<td> <input type="submit" name="btnHola" value="View"> </td>
</tr>
<%}
}
catch(Exception exc)
{
System.out.println("Error: ");
System.out.println(exc.toString());
}
}
if(request.getParameter("btnHola") != null)
{
out.println("Clicked");
}
}%>
</table>
</form>
</body>
我已经阅读了主题“什么是NullPointerException,以及如何修复它?”,并尝试自行修复它,但失败了,我会帮助我知道错误。
答案 0 :(得分:0)
很难说NPE来自哪里因为你没有提供代码。
但是我通常会做的事情(因为它很难调试jsp)只是把out.println("step xxx");
放在这里和那里看看成功传递了哪些jsp行。
您还可以输出一些您怀疑的变量
out.println(usu);