You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by je...@abbott.com on 2002/08/01 18:13:30 UTC

OT: howto avoid overuse of session object?

This is sort of off-topic, but I don't know of a better forum targeting Java
web/servlet programming.  If anyone does know of one, could you let me know?

I'm basically wondering if others have found effective ways to avoid the
tempting but bad practice of loading up the session with all sorts of
attributes.  I often find myself needing some Bean or other object for maybe 2
or 3 requests, and, rack my brains as I may for an elegant way of passing the
object along without putting it in the session, I usually end up with nothing
more than a headache and 1 more attribute in my session.  :(  I'm developing
with an MVC approach, with Struts for more recently developed apps and a
similar custom framework for our older apps, but I just can't seem to see a
way to get around this problem.  I would love it if there were an object like
a thisRequestAndTheNextOne object, where attributes would stick around for the
current request and subsequent request, and then the controller could get
objects from the previous request and determine if it should put them in the
new thisRequestAndTheNextOne object for the current request.  I don't know if
that makes sense to anyone else, but, nevertheless, does anyone have any ideas
to do what I'm trying to do?

Does anyone else feel my pain?  ;)

Thanks,
-Jeff


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OT: howto avoid overuse of session object?

Posted by Jacob Kjome <ho...@visi.com>.
Hello jeff,

The Barracuda project contains classes that allow for exactly this
ability: to allow an object to be passed from one request to the next
without the use of the session.

Check it out at:  http://barracuda.enhydra.org/

The classes that you should specifically concern yourself with are
ObjectRepository.java and ObjectRepositoryAssembler.java in the
org.enhydra.barracuda.core.util.data package.

Note that you are not required to use Barracuda in order to use this.
the core.util.* package of Barracuda is built into a separate .jar
file called "plankton.jar" which can be used as general utility
classes for any project.  There are also some other mechanisms that
allow you to do stuff like this, but depend on using Barracuda's event
model (which can also be used separately from the component and view
models).

The best documentation for ObjectRepository is in the javadoc and
here:
http://barracuda.enhydra.org/cvs_source/Barracuda/docs/SimpleLoginApp/simple_login_app.html#Passing_State


Also, look at the following messages in the Barracuda list archive:

Primary emails to read explaining the ObjectRepository:
http://barracuda.enhydra.org/project/mailingLists/barracuda/msg03113.html
http://barracuda.enhydra.org/project/mailingLists/barracuda/msg03250.html


all emails discussing the ObjectRepository:
http://barracuda.enhydra.org/project/mailingLists/barracuda/list.search?q=objectrepository&Search=+Search%21+&t=barracuda&ul=%2Fproject%2FmailingLists


Note that the server hosting barracuda.enhydra.org has been a bit
flaky this morning.  If you get a "Server Error", just try again a bit
later.

Jake

Thursday, August 01, 2002, 11:13:30 AM, you wrote:

jgac> This is sort of off-topic, but I don't know of a better forum targeting Java
jgac> web/servlet programming.  If anyone does know of one, could you let me know?

jgac> I'm basically wondering if others have found effective ways to avoid the
jgac> tempting but bad practice of loading up the session with all sorts of
jgac> attributes.  I often find myself needing some Bean or other object for maybe 2
jgac> or 3 requests, and, rack my brains as I may for an elegant way of passing the
jgac> object along without putting it in the session, I usually end up with nothing
jgac> more than a headache and 1 more attribute in my session.  :(  I'm developing
jgac> with an MVC approach, with Struts for more recently developed apps and a
jgac> similar custom framework for our older apps, but I just can't seem to see a
jgac> way to get around this problem.  I would love it if there were an object like
jgac> a thisRequestAndTheNextOne object, where attributes would stick around for the
jgac> current request and subsequent request, and then the controller could get
jgac> objects from the previous request and determine if it should put them in the
jgac> new thisRequestAndTheNextOne object for the current request.  I don't know if
jgac> that makes sense to anyone else, but, nevertheless, does anyone have any ideas
jgac> to do what I'm trying to do?

jgac> Does anyone else feel my pain?  ;)

jgac> Thanks,
jgac> -Jeff


jgac> --
jgac> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
jgac> For additional commands, e-mail: <ma...@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OT: howto avoid overuse of session object?

Posted by peter lin <pe...@labs.gte.com>.
what about writing a central controller, which is initiated when tomcat
starts up?

if you write a class that implements ServletContextListener and add it
to your web.xml, it will load your application. You can then set it in
the application context. Each request can then get to the application by
doing pageContext.findAttribute(string).

the ServletContextListener simply listens for
contextInitialized(ServletContextEvent). From the event, you get a
handle to the serveltcontext. once your controller is created, you
simply call servletcontext.setAttribute().


peter lin

jeff.guttadauro@abbott.com wrote:
> 
> This is sort of off-topic, but I don't know of a better forum targeting Java
> web/servlet programming.  If anyone does know of one, could you let me know?
> 
> I'm basically wondering if others have found effective ways to avoid the
> tempting but bad practice of loading up the session with all sorts of
> attributes.  I often find myself needing some Bean or other object for maybe 2
> or 3 requests, and, rack my brains as I may for an elegant way of passing the
> object along without putting it in the session, I usually end up with nothing
> more than a headache and 1 more attribute in my session.  :(  I'm developing
> with an MVC approach, with Struts for more recently developed apps and a
> similar custom framework for our older apps, but I just can't seem to see a
> way to get around this problem.  I would love it if there were an object like
> a thisRequestAndTheNextOne object, where attributes would stick around for the
> current request and subsequent request, and then the controller could get
> objects from the previous request and determine if it should put them in the
> new thisRequestAndTheNextOne object for the current request.  I don't know if
> that makes sense to anyone else, but, nevertheless, does anyone have any ideas
> to do what I'm trying to do?
> 
> Does anyone else feel my pain?  ;)
> 
> Thanks,
> -Jeff
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: howto avoid overuse of session object?

Posted by Cédric Viaud <ce...@matrasi-tls.fr>.
Hi,

FIRST

For non-specific Tomcat questions, it exists :
SERVLET-INTEREST@JAVA.SUN.COM
There's also an other one wich is JSP oriented.

SECOND

All best practice i know says that you must minimize the ammount of data
stored in the session. So, the traditional approach of this problem is to
only store the user-id (simple type) in the session. All over session
informations (a class containing all required informations) are stored in
the servlet context.

Praticaly, on the request you get the user id from the user session. Next
you use this Id to get the "user information obect" from the servlet
context.

This is certainly deceiving, but this is the way ...

Maybe someone knows better practice ?

Regards,

    Cédric

----- Original Message -----
From: <je...@abbott.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, August 01, 2002 6:13 PM
Subject: OT: howto avoid overuse of session object?


> This is sort of off-topic, but I don't know of a better forum targeting
Java
> web/servlet programming.  If anyone does know of one, could you let me
know?
>
> I'm basically wondering if others have found effective ways to avoid the
> tempting but bad practice of loading up the session with all sorts of
> attributes.  I often find myself needing some Bean or other object for
maybe 2
> or 3 requests, and, rack my brains as I may for an elegant way of passing
the
> object along without putting it in the session, I usually end up with
nothing
> more than a headache and 1 more attribute in my session.  :(  I'm
developing
> with an MVC approach, with Struts for more recently developed apps and a
> similar custom framework for our older apps, but I just can't seem to see
a
> way to get around this problem.  I would love it if there were an object
like
> a thisRequestAndTheNextOne object, where attributes would stick around for
the
> current request and subsequent request, and then the controller could get
> objects from the previous request and determine if it should put them in
the
> new thisRequestAndTheNextOne object for the current request.  I don't know
if
> that makes sense to anyone else, but, nevertheless, does anyone have any
ideas
> to do what I'm trying to do?
>
> Does anyone else feel my pain?  ;)
>
> Thanks,
> -Jeff
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>