I am trying to access a bean's property from a jsp. A servlet is used in the middle. when I try the getProperty I get this error and I don't know what it means:
Note: sun.tools.javac.Main has been deprecated. c:\ServletExec\Servlets\pagecompile\_projFourJSP_xjsp.java:42: Variable 'bean' is already defined in this method. Object bean = pageContext.findAttribute( "bean" ); ^ 1 error, 1 warning
Code for JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head> <title>Project Four JSP</title> <jsp:useBean id="bean" class="java146.project4.ProjectFourServlet" scope="application"/> </head> <body bgcolor = silver> <center><h1>Search Results For Project Four</h1></center> <table border = 2> <th> <tr> <td>Empoyee ID </td> <td>First Name </td> <td>Middle Name </td> <td>Last Name </td> <td>SSN </td> <td>Department </td> <td>Room</td> <td>Phone Ex.</td> </tr> </th> <I><jsp:getProperty name="bean" property="employeeTable" /></I> </table>
Defining, creating, accessing a bean, all these statements will become a part of jspService method. In one method you can define only one variable with a particular name. If you use the already defined variable, it will fail to compile.
From your JSP it appears that if this JSP is statically included in some another time at the time of compilation, and "bean" variable is also used there, then this error can come.
In static inclusion, contents of included JSP and including JSP will come in one translation unit.
Just check your code, if such scenario is occuring. Or try change the variable name e.g. "bean" to "employeeBean".