You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jess Balint <jb...@gmail.com> on 2006/02/27 18:40:35 UTC

jsp:useBean and using the same bean in a page

Hi, I am working with an app that has a lot of jsp:useBean. I have come
across an error trying to use the same id multiple times in the same page. I
understand from the JSP syntax reference that this is valid and it should
just reference the original bean on any subsequent calls. Here is the
reference I am using:

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html

The error basically implies that I cannot use the same bean twice on a page.
I get the error key 'jsp.error.useBean.duplicate'. I check the code
org.apache.jasper.compiler.Validator:515. It uses the BeanRepository to do
'checkVariable', which has this code:

    public boolean checkVariable (String bean) {
	// XXX Not sure if this is the correct way.
	// After pageContext is finalised this will change.
	return (checkPageBean(bean) || checkSessionBean(bean) ||
		checkRequestBean(bean) || checkApplicationBean(bean));
    }

It doesn't seem to me that this is the correct way because I cannot use the
same bean twice in the same page. Please let me know if I am wrong about
this. Thanks.

Jess
(Please CC replies to me in 'cc' address as I am not on the list, thanks)

Stack trace:

org.apache.jasper.JasperException: /my.jsp(4,0) jsp.error.useBean.duplicate
	
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.
java:39)
	
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405
)
	
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:100
)
	
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:51
6)
	org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org