当前位置: 首页 > 知识库问答 >
问题:

HTTP Status 500:org。阿帕奇。贾斯珀。JaspereException:java。lang.NullPointerException

杜俭
2023-03-14

我的jsp有一个代码:

<%if (session.getAttribute("login") == null) {%>
                    <div id="login">
                        <div class="loginContent">
                            <form action="connexion" method="POST" id="login_frm">
                                <label ><b>Username: </b></label>
                                <input class="field" type="text" id="log" name="login" value="" size="23" />
                                <label ><b>Password:</b></label>
                                <input class="field" type="password"  id="pwd" size="23" />
                                <input type="submit"  value="" class="button_login" />
                            </form>
                       <div class="left">
                           <label for="rememberme"><input name="rememberme" id="rememberme" class="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label></div>
                            <div class="right">Not a member? <a href="#">Register</a> | <a href="#">Lost your password?</a></div>
                      </div>
                      <div class="loginClose"><a href="#" id="closeLogin" onclick="closeForm()">Fermer panneau</a></div>
                    </div>
                 <% } else {%>
                 <h3><a href="Deconnecte">Déconnexion</a><br></h3>
                 <h3> Bonjour: <%= session.getAttribute("login")%></h3>
                 <%}%>

这是我的servlet:

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String login = request.getParameter("login")
    HttpSession session = request.getSession();
    session.setAttribute("login", login);
    System.out.println(session.getAttribute("login"));     getServletConfig().getServletContext().getRequestDispatcher("/recommandation.jsp").forward(request, response);
}

当我点击登录按钮时,我有一个错误。

INFO: appachito ATTENTION: ApplicationDispatcher[/RecommandationDefault] PWC1231: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.recommandation_jsp._jspService(recommandation_jsp.java from :300) 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:406) 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.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:822) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314) at package1.connexion.doPost(connexion.java:47) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) 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.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619)

ATTENTION: StandardWrapperValve[connexion]: PWC1406: Servlet.service() for servlet connexion threw exception java.lang.NullPointerException at org.apache.jsp.recommandation_jsp._jspService(recommandation_jsp.java from :300) 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:406) 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.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:822) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314) at package1.connexion.doPost(connexion.java:47) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) 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.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619)

提前谢谢

共有1个答案

申屠飞
2023-03-14

在Tomcat a中。java和。将为应用程序中的每个jsp文件创建类文件,并且可以从下面的路径中找到相同的文件,Apache Tomcat\work\Catalina\localhost\ApplicationName'\org\Apache\jsp\index\u jsp。java

在您的例子中,jsp名称是recommandation。所以路径应该是如下所示的Apache Tomcat\work\Catalina\localhost\ApplicationName'\org\Apache\jsp\recommendation\u jsp。java在第300行中,您试图访问一个空对象,这会导致空指针异常。

如果您使用的是Glassfish,您可以在这里找到编译好的jsp文件your domain dir/generated/jsp/j2ee modules\\YourModule/org/apache/jsp

在我的系统上,它是C:\glassfish-4.0\glassfish\domains\domain1\generated\jsp\WebApplication1\org\apache\jsp

 类似资料:
  • 我在生产服务器上部署了我的项目,并得到以下错误。 这是一个实时项目,所以,在出现错误后,我用运行良好的前一个版本替换了它,但现在它也抛出了相同的错误。请告诉我有什么问题? 错误: InExpage。jsp:

  • 我正在尝试从servlet(viewcurrentstock.java)检索一个属性到jsp(viewstock.jsp)。这里有一个例外提示:“org.apache.jasper.JasperException:java.lang.NullPointerException” 查看当前股票。JAVA viewstock.jsp 服务器日志:

  • 我为在线DVD商店创建了一个EJB应用程序。我使用Netbean 7.2.1和Glassfish 3.1.2当我运行index.jsp时,它的界面启动成功,如果我单击表单提交按钮,我会收到此错误: 在Netbean中,我得到了这个错误: 我创建了一个JavaEE企业应用程序。我有项目ejb和项目战争。因为我无法直接从ejb创建SessionBean,所以我创建了一个新的项目/Java库类,并在那里

  • 在我的jsp页面中,有一些纯java代码,即scriptlet。经过很长一段时间的刷新后,它就会抛出 有时不长时间也会抛出同样的异常。JSP页面显示的是空页面。因此,用户只有一个选择是注销。为了避免这种情况,把他重定向到错误页面。怎么做?

  • 在我部署在WebSphere 8.5上的java应用程序中,我遇到了这个错误,尽管我的maven依赖项低于log4j。 我确实运行了一个,我可以看到它正以 的形式被拉进来,这是我期望在树结果中看到的,这样我就可以确认它在类路径中。有什么想法吗?

  • Apache Kafka:分布式消息传递系统 Apache Storm:实时消息处理 我们如何在实时数据管道中使用这两种技术来处理事件数据? 在实时数据管道方面,我觉得两者做的工作是一样的。如何在数据管道上同时使用这两种技术?