"Pieck, Michael" wrote:
>
> I'm creating a java bean inside my servlet and storing it on the request
> using the setAttribute command.
>
> If my servlet then forwards my request onto a simple jsp page
> (DefineGroups.jsp) I can access then bean without a problem using:
>
> <jsp:useBean id="viewBuilder"
> class="com.gs.fw.pl.ebs.page.views.CustomViewBuilder" scope="request"/>
>
> If, instead, my servlet forward the request onto a jsp page which is nothing
> but a frameset:
>
> <html>
> <head><title>Define Groups</title></head>
> <frameset rows="100%, 0%" border=0 frameborder="no">
> <frame src="DefineGroups.jsp" name="definer">
> <frame name="storer">
> </frameset>
> </html>
>
> my attempt to access the bean in DefineGroups.jsp doesn't find the bean I
> stored in the request, but instead creates a new, blank bean.
>
> What is the correct way to do this if I'd like to use frames?
> Is there a correct way?

An object in the request scope (request attribute) is only available
during the processing of the same request. When you forward to the
DefineGroups.jsp page directly, this page is processing the same
request as the servlet, so it works fine.

However, when you forward to the JSP page that builds a frameset,
the browser gets the frameset and makes a new request for each
frame. So in this case, DefineGroups.jsp is *not* processing the
same request, and the object is therefore not available.

One way around this is to let the servlet store the bean in the
session scope instead, and let the JSP page remove it from the
session when it's done with it (to avoid keeping too much stuff
in the session). A draw back with this approach is that it can
cause problems if the user submits requests to the servlet from
two browser windows (sharing the same session).

Another way is to use the bean in the JSP page with the frameset,
and let it add all relevant data to the DefineGroups.jsp URL as
query string parameters that the DefineGroups.jsp page can access.
This works fine for small amounts of string data, but not for
more complex data.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to