Forums Register Login

getProperty of a java bean

+Pie Number of slices to send: Send
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

Please help

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>



<A HREF="/">Home</A>
</body>
</html>
+Pie Number of slices to send: Send
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".
+Pie Number of slices to send: Send
I think Sanjeev is right. Do you have an import statement in the example you've posted here that we're not seeing?

<%@ include file="SomeOtherPage.jsp" %>

If so, that file must also have the same <useBean> tag in it.
+Pie Number of slices to send: Send
Thank you for helping
rubbery bacon. crispy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 572 times.
Similar Threads
HTML:OPTIONS
Calling Java Bean from JSP
how to iterate.
ie and netscape!!
Attempted a bean operation on a null object.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:09:44.