You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steve Haines <sh...@ipnet-solutions.com> on 2000/05/11 19:57:32 UTC

from a servlet

I have a servlet that sets an attribute in the request object containing a
bean:

...
MyBean bean = new MyBean( mydata );
req.setAttribute( "mybean", bean );
...

And that gets forwarded to my JSP page:

...
RequestDispatcher dispatcher;
dispatcher = req.getRequestDispatcher( "/myjsppage.jsp" );
dispatcher.forward( req, res );
...

On the JSP page I unsuccessfully attempt to retrieve the bean using the
<jsp:useBean> tag, as follows:

myjsppage.jsp:
<jsp:useBean id="mybean" class="com.mypackage.MyBean" scope="request" />


It gives me the following error:

javax.servlet.ServletException: No bean "mybean" available for  tag.

Now, if I use JSP scriptlets to retrieve and display the bean, it is there:

<%
MyBean bean = ( MyBean )request.getAttribute( "mybean" );
bean.doSomething();
%>


Do you have any idea why the JSP page cannot implicitly load the bean from
the request??  From my understanding as long as the id of the bean matches
the name of the request parameter (and it is of the proper type), specifying
scope="request" should load the bean into my JSP page bean..

I am using JDK 1.2.2 and Tomcat 3.1 (release)..

Thanks!
Steve