0

I'm doing a web app.

I want to use an input value in one jsp from another jsp.

What am I doing wrong? Thank you.

Error: https://i.stack.imgur.com/8TlGs.jpg

HTTP Status 500 – Internal Server Error
Type Exception Report

Message An exception occurred processing [/jsp/editar.jsp] at line [43]

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

Exception

org.apache.jasper.JasperException: An exception occurred processing [/jsp/editar.jsp] at line [43]

40:               <th>TIPO DE PÓLEN</th>
41:             </tr>
42:             
43:             <%  for(int i = 0; i < dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).size(); i ++){
44:                     %>
45:             <tr>
46:                 <td><%out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getIdpollocal()); %></td>


Stacktrace:
                org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:625)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:514)
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.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:542)
java.lang.Integer.parseInt(Integer.java:615)
org.apache.jsp.jsp.editar_jsp._jspService(editar_jsp.java:174)
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:476)
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.

index.jsp:

<form action="loginServlet">

            <table style="font-family: Corbel">
                <tr>
                    <td><label for="username">
                username</label></td>
                    <td><input type="number" name="username"></td>
                </tr>
 .....

editar.jsp:

<jsp:include page="index.jsp" >
<jsp:param name="username" value=""/>
</jsp:include>
....
<%  for(int i = 0; i < dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).size(); i ++){
                %>
<tr>
            <td><%out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getIdpollocal()); %></td>
             <td><%out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getData()); %></td>
             <td><%out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getNome()); %></td>
             <td><% out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getLat()); %></td>
             <td><% out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getLongi()); %></td>
             <td><% out.print(dados.getEntradasUser(Integer.parseInt(request.getParameter("username"))).get(i).getDescri()); %></td>

              <%
            }
                %>

        </tr>

(where dados.getEntradasUser(iduser) receives an int to search for things of that user only, iduser is user's username)

curious
  • 11
  • 1
  • 7

0 Answers0