I have a framework you may like to look at.

At any rate, if the Vector will NEVER be used again, put it in the request
scope. However, in the MVC framework, generally you would put a reference to
the Vector in a bean, then on the JSP page use that bean (which is session
scope) to get the Vector. Here is the problem. If you display that Vector as
a list of items that can be selected from, once a user submits their
selection back to the server how will you know what items the selected ones
represent unless you get the vector filled in again? In other words, if its
ONLY to display it and it can change dynamically..so each subsequent request
needs to list it, then use Request scope. But if it is to be used as a
possible "option" list for a user to not only see, but maybe select
something from, you'll want to store it at Session scope.

One of the ideas in MVC is to make sure you clean up your resources when
your done with them. Make sure you only reference objects in one
place..mainly the javabean (that holds state information during a single or
multi-page transaction), then upon the final page being done..clean up the
resources. Set the references to null, or remove the bean from the
HttpSession (which should be the only thing that has a reference to the
bean) which will allow the GC to clean it up when it gets around to it.

Lastly, we came across one problem with this on our site..the problem being,
if in a multi-page "wizard" like setup where one page may be built depending
on input from the previous page, what happens if the user half-way through
(or for that matter on any page other than the last one that cleans things
up) goes off to another site, or another page on our site? The resources
(the javabean and any references it holds) are still in memory but are not
used. So, what I did is..each "module" creates a stateless logic class
instance per request (eventually..when I move it to EJB the EJB container
will be able to handle stateless ejb session bean instances for me..so it
won't create them on every request but get them from a pool as need be),
call methods to do the logic, set the properties in the bean for results
given back by the logic, then forward to the JSP page which uses the bean.
But..before a stateless logic class is created, in any given module I know
specifically what HttpSession objects should exist. Therefore, I clear out
ALL objects except the ones that are needed for that module (and any others
that may be needed throughout the existence of a user session...such as
their profile info that may be displayed or edited on say any page). The
only thing to keep in mind when doing this..is to make sure you don't clear
out any objects needed elsewhere.

Anyways..let me know if you want more info on a simple MVC framework. If you
want a more robust one, Struts is a good one to look at.


> -----Original Message-----
> From: julian sitkewich [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 18, 2001 1:35 PM
> To: [EMAIL PROTECTED]
> Subject: Re: MVC Architecture and JSP
>
>
> It should last to the next page where it will be displayed. Would a
> "request" be the best choice?
>
> What if I wanted to persist my results for more than one
> user, to save the
> round trips to the all the way back to the webserver->EJB->database?
>
> julian
>
>
> >From: Kevin Jones <[EMAIL PROTECTED]>
> >Reply-To: A mailing list about Java Server Pages specification and
> >     reference <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: MVC Architecture and JSP
> >Date: Thu, 18 Jan 2001 21:02:03 -0000
> >
> >How long should the data last?
> >Is it used only by one user or multiple users?
> >Could you put it into a database?
> >
> >Kevin Jones
> >DevelopMentor
> >www.develop.com
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages
> specification and reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of julian sitkewich
> > > Sent: 18 January 2001 19:58
> > > To: [EMAIL PROTECTED]
> > > Subject: MVC Architecture and JSP
> > >
> > >
> > > I pose a question, in the MVC (Model-View-Controller) architecture
> > > information is commonly passed between servlet and JSP
> via session. This
> > > seems to go against certain principles of server overhead
> and memory
> > > consumption. My example is this: A servlet creates a HUGE Vector
> > > object of a
> > > company department directory list. The request is
> forwarded to the JSP
> >to
> > > list the contents of the Vector. Is there a better way
> than to store my
> > > large Vector in the user Session??
> > >
> > > Regards,
> > >
> > > Julian
> > > _________________________________________________________________
> > > Get your FREE download of MSN Explorer at http://explorer.msn.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
> >
> >=============================================================
> ==============
> >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
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.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
>

===========================================================================
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