Reg Sherwood wrote:
> Q. Is it possible to maintain the state of a bean for a particular
> client for use in a JSP page. I have tried placing the bean instance I
> wish to save on the session object in the hopes of later retrieving it
> via a get method in the servlet. After reviewing docs I think it may be
> possible to do something along the lines of:
>
> SERVLET:
> HttpSession session = request.getSession(true);
> session.putValue("theBean", myBean);
>
> JSP PAGE:
> <jsp:useBean id="theBean" scope="session" class="..." />
>
> Now in the JSP page I wish to retrieve values on the bean instance from
> a specified method. So,
>
> JSP PAGE:
> <% int x = theBean.getSize(); %>
>
> But when I try this the above fails as it does not know what the
> variable "theBean" is, even though I named it in the id portion with the
> jsp:useBean tag. Any thoughts? Thanks
>
This is exactly the way it is supposed to work, as long as your <jsp:useBean>
directive comes *before* the scriptlet in your page. What JSP system are you
using? What is the exact compile error that you get?
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html