You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Craig R. McClanahan" <cr...@apache.org> on 2002/12/02 02:38:29 UTC

Re: session form bean reuse


On Fri, 29 Nov 2002, Sven Frederik Pohl wrote:

> Date: Fri, 29 Nov 2002 15:10:41 +0100
> From: Sven Frederik Pohl <sv...@cmg.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: session form bean reuse
>
> Hello all,
>
> I got a simple question, but I could not find any answer on the net:
> Could a session scope form bean get reused by another session if the session ends?
> Or is it garanteed, that a session scope form bean instance is only used by a *single* session?
>

Struts will not itself reuse form bean instances across sessions (although
your application could copy one if it really wanted to).

> Thanks in advance,
>
> Sven Pohl

Craig


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


Re: session form bean reuse

Posted by Mark Lepkowski <Ma...@lmco.com>.
> > How do you get session A information available to session B without persisting it somehow (the HttpSessionContext interface is depracated in Java Servlet API v2.1for security reasons...)?
(snip)
> >
> 
> Use servlet context attributes to share information between all the
> sessions in your webapp.

Thanks for the info.  I knew there had to be something in the servlet scope, but didn't know quite where to find it.  The following works in any of our classes that extend Action:

servlet.getServletContext().setAttribute( "myAttribute", myAttribute );

and likewise

MyAttribute myAttribute = (MyAttribute)servlet.getServletContext().getAttribute( "myAttribute" );

I noticed that:
- "servlet" is declared a protected "transient" ActionServlet in ActionServletWrapper, 
- ActionForm has the getter method for the wrapper,
- RequestUtils.populate() calls the getter,
- ActionServlet calls RequestUtils.populate()

What I don't follow is how the servlet object is exposed in the Action subclasses.



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


Re: session form bean reuse

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 2 Dec 2002, Mark Lepkowski wrote:

> Date: Mon, 02 Dec 2002 09:21:42 -0500
> From: Mark Lepkowski <Ma...@lmco.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: session form bean reuse
>
> How do you get session A information available to session B without persisting it somehow (the HttpSessionContext interface is depracated in Java Servlet API v2.1for security reasons...)?
>   Struts will not itself reuse form bean instances across sessions (although
>   your application could copy one if it really wanted to).
>
>

Use servlet context attributes to share information between all the
sessions in your webapp.

Craig



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


Re: session form bean reuse

Posted by Mark Lepkowski <Ma...@lmco.com>.
How do you get session A information available to session B without persisting it somehow (the HttpSessionContext interface is depracated in Java Servlet API v2.1for security reasons...)?
  Struts will not itself reuse form bean instances across sessions (although
  your application could copy one if it really wanted to).