我调用了Java函数,并在JSP中找到了具有根​​本原因的Stacktrace:]

时间:2018-09-04 10:09:31

标签: java jsp

早上好,我想问你一个问题。 我对Java和JSP有点新手,我正在学习,所以请不要杀死我:D

在我的代码的两部分中,我有一个类似的问题,在第一个部分: modificaprofilo.jsp

<div id="modinfopersonali" class="div1 tabcontent">
        <% User u=(User)session.getAttribute("User");%>
        <p>Email: <input type="email" value="<%= u.getEmail()%>" disabled></p>
        <p>Nome: <input type="text" oninput="this.className = ''" value="<%=u.getFirstname() %>" ></p>
        <p>Cognome: <input type="text" oninput="this.className = ''" value="<%= u.getLastname() %>"></p>
        <p>Luogo di Nascita: <input type="text" oninput="this.className = ''" value="<%= u.getLuogodinascita() %>"></p>
        <p>Indirizzo: <input type="text" oninput="this.className = ''" value="<%= u.getIndirizzo() %>"></p>

        <button class="button" onclick="modificaInformazioni()">Modifica </button>
    </div>

ModificaProfilo.java

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session=request.getSession();
    String mod=request.getParameter("mod");
    Database db=Database.getDatabase();
    if(mod!=null) {
        if(mod.equals("Profilo")) {
            String login=request.getParameter("login");
            String firstname=request.getParameter("firstname");
            String lastname=request.getParameter("lastname");
            String luogodinascita=request.getParameter("luogodinascita");
            String indirizzo=request.getParameter("indirizzo");

            User u = new User((String)session.getAttribute("Email"),login, firstname, lastname, luogodinascita, indirizzo);
            try {
                if(db.modificaProfilo(u)==true) {
                    session.removeAttribute("User");
                    session.setAttribute("User",u);
                    response.getWriter().write("true");
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }}  

}

*我添加了文件java,那么您(和我)可以更好地理解*

我在Email行收到一个错误,但如果我对此行发表评论,则在Nome行出现错误,然后在其他行出现。

我在以下地方发现的相同错误:

<div class="row">
        <div class=" column infouser1">
        <h3>Informazioni Personali </h3><hr>
        <p>Nome: <%=u.getFirstname()%></p>
        <p>Cognome: <%= u.getLastname() %></p>
        <p>Luogo di Nascita : <%= u.getLuogodinascita() %></p>
        <p>Indirizzo : <%=u.getIndirizzo() %></p>
        </div>
    </div>

在Nome行中,Cognome ...

我不明白为什么,我认为问题出在函数u.getEmail,但我认为这是正确的。

这是第一种情况下的错误

GRAVE: Servlet.service() for servlet [jsp] in context with path [/Reservation] threw exception [An exception occurred processing [/modificaprofilo.jsp] at line [22]

19:     </div>
20:     <div id="modinfopersonali" class="div1 tabcontent">
21:         <% User u=(User)session.getAttribute("User");%>
22:         <p>Email: <input type="email" value="<%= u.getEmail()%>" disabled></p>
23:         <p>Nome: <input type="text" oninput="this.className = ''" value="<%=u.getFirstname() %>" ></p>
24:         <p>Cognome: <input type="text" oninput="this.className = ''" value="<%= u.getLastname() %>"></p>
25:         <p>Luogo di Nascita: <input type="text" oninput="this.className = ''" value="<%= u.getLuogodinascita() %>"></p>


Stacktrace:] with root cause
java.lang.NullPointerException
    at org.apache.jsp.modificaprofilo_jsp._jspService(modificaprofilo_jsp.java:143)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:412)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1385)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

0 个答案:

没有答案