struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Villalba Arias, Fredy [BILBOMATICA]" <fvilla...@mailext.com>
Subject RE: Accessing ActionForm from Servlet (was: Pajes + Struts)
Date Tue, 03 Feb 2004 18:20:28 GMT
Hi Hubert, thanx for answering!

Read below.

>Not sure this would be possible.  The actual ActionForm in use depends on >the
>session, and sometimes even the particular request.  I doubt there's a way >to
>get to the form object actually in use by just specifying the action class.
>If it's the *class* of the ActionForm you want, check out the ActionMapping
>object for a particular mapping.

The doGet method receives the request and response objects. Correct me if
I'm wrong, but the request object is client-specific, and so are the
ActionForm objects, as you clearly mentioned above. Therefore, no matter
which client originated the request, through it you'd be able to access any
attribute stored on that specific request or even on the Session associated
to it. Being Struts already in charge of managing the life-cycle of the
ActionForm-s, I believe there shouldn't be a problem in trying to access the
ActionForm for a given Action (/client) from a separate Servlet, since the
latter won't be able to reach anything the former does not want it to.

This was actually the initial reasoning that led me to the tesis that it
should be absolutely feasible to accomplish this integration. Do u agree?

This said, my question remains: is there some Struts' class that
encapsulates the scope issue (and others as well) and, given a form bean's
name (and maybe the request / Session / something else...), returns it (if
exists)???

I sneaked through the tag libs classes (the source code) and saw something
more or less similar to what I'm looking for; the problem was that it did
additional stuff I don't want to get executed, plus it was tied to JSP (it
used pageContext and other stuff)...


> (3) How can I do it from an ordinary Servlet?

>request.getAttribute(formName);
>or 
>session.getAttribute(formName);
> depending on the scope of the form as declared in struts-config.

Would that be the formName as declared in struts-config?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 25/02/2003
 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message