id can not be resolved to a variable

0

I would like to know why these errors come out:

An error occurred at line: 383 in the jsp file: /cinema.jsp
id cannot be resolved to a variable
380: %>
381:    <tr>
382:     <td>
383:     <%=id%>
384:     </td>
385:     <td>
386:     <%=rs.getString(2)%>


An error occurred at line: 421 in the jsp file: /cinema.jsp
id cannot be resolved to a variable
418:     <%=rs.getString(8)%>
419:     </td>
420:     <td onmouseover="this.style.backgroundColor='yellow'"  onmouseout="this.style.backgroundColor='transparent'">
421:     <a href="cinema.jsp?mode=delete_film&id=<%=id%>">Óäàëèòü</a><br>
422:     <a href="cinema.jsp?mode=order_tickets&id=<%=id%>">Ïðîäàòü áèëåòû</a><br>
423:     </td>
424:    </tr>


An error occurred at line: 422 in the jsp file: /cinema.jsp
id cannot be resolved to a variable
419:     </td>
420:     <td onmouseover="this.style.backgroundColor='yellow'"  onmouseout="this.style.backgroundColor='transparent'">
421:     <a href="cinema.jsp?mode=delete_film&id=<%=id%>">Óäàëèòü</a><br>
422:     <a href="cinema.jsp?mode=order_tickets&id=<%=id%>">Ïðîäàòü áèëåòû</a><br>
423:     </td>
424:    </tr>
425: 


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:536)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:660)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

cinema.jsp

    
asked by Neon 04.06.2018 в 20:15
source

1 answer

0

The JSPs end up automatically converted into servlets , which are then compiled.

When you do

<%=id%>

It ends up being in the servlet

out.println(id); // out es una variable predefinida que es la salida del 'response'.

And the problem is, simply, that you have not defined any variable id . For example, if you did:

 <% int id = 42; %>
 <%=id%>

I would compile you already.

Of course, then you have to decide YOU what you want to mean id and how it gets its value.

    
answered by 04.06.2018 / 21:07
source