Re: [Struts2] How to get instance of ActionSupport class after redirect?

2007-04-07 Thread Ted Husted

On 4/6/07, Neil Aggarwal [EMAIL PROTECTED] wrote:

I can probably use a session variable to temporarily
hold the ActionSupport instance, but it seems there
should be a more Struts-centric way to get it.


So long as the Action is utilizing SessionAware, then using the
session this way is Struts-centric.

* http://struts.apache.org/2.0.6/docs/how-do-we-get-access-to-the-session.html

The trick is to use the Session without becoming coupled to the
HttpSession, which SessionAware does nicely.

HTH, Ted.
http://husted.com/ted/blog/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [Struts2] How to get instance of ActionSupport class after redirect?

2007-04-07 Thread Neil Aggarwal
Ted:

Thanks for the advice.  I think that is the best approach
to use.

Thanks, 
Neil 

--
Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ted
Husted
Sent: Saturday, April 07, 2007 7:13 AM
To: Struts Users Mailing List
Subject: Re: [Struts2] How to get instance of ActionSupport class after
redirect?

So long as the Action is utilizing SessionAware, then using the
session this way is Struts-centric.

*
http://struts.apache.org/2.0.6/docs/how-do-we-get-access-to-the-session.html

The trick is to use the Session without becoming coupled to the
HttpSession, which SessionAware does nicely.

HTH, Ted.
http://husted.com/ted/blog/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Struts2] How to get instance of ActionSupport class after redirect?

2007-04-06 Thread Laurie Harper

Neil Aggarwal wrote:

Hello:

I have this scenario:

I have a form in a jsp file that submits to an
ActionSupport class.

The ActionSupport class captures the submitted
data and validates the input.  If the data is valid,
it sends the user back a redirect to a servlet url
to give them the data file generated for their
input (It is a CSV file).

Right now, I am taking all of the fields from the
ActionSupport class and appending them manually to
the redirect url so I can have their values in the
servlet.

This becomes tedious if there are many fields in the
ActionSupport class.

Is there a way to grab the instance of the ActionSupport
class from the servlet?  If so, I could eliminate the
need to append the fields.

I can probably use a session variable to temporarily
hold the ActionSupport instance, but it seems there
should be a more Struts-centric way to get it.

Any suggestions?


My first suggestion would be to get rid of the redirect to a separate 
servlet and serve the CSV response directly from the action. Is there a 
reason you can't do that?


There's no way your servlet can get the action class instance, since 
action instances are request scoped; the instance no longer exists in 
the new request the servlet receives.


Your options in this case (or any other case where you want to use data 
from one request in a subsequent request) are pretty much limited to 
either including the data in the redirect URL's query parameters, as you 
are doing, storing them in the user's session, as you suggested, or 
persisting them somewhere else, such as a database.


L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [Struts2] How to get instance of ActionSupport class after redirect?

2007-04-06 Thread Neil Aggarwal
Laurie: 

I alyways use a redirect after a form post to avoid
the stupid page expired warning if the user hits the
reload button.

I think we will save the ActionSupport instance in the
session and get it back from there.

Thanks,
Neil


--
Neil Aggarwal, (214)986-3533, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
Sent: Friday, April 06, 2007 5:30 PM
To: user@struts.apache.org
Subject: Re: [Struts2] How to get instance of ActionSupport class after
redirect?

Neil Aggarwal wrote:
 Hello:
 
 I have this scenario:
 
 I have a form in a jsp file that submits to an
 ActionSupport class.
 
 The ActionSupport class captures the submitted
 data and validates the input.  If the data is valid,
 it sends the user back a redirect to a servlet url
 to give them the data file generated for their
 input (It is a CSV file).

My first suggestion would be to get rid of the redirect to a separate 
servlet and serve the CSV response directly from the action. Is there a 
reason you can't do that?

There's no way your servlet can get the action class instance, since 
action instances are request scoped; the instance no longer exists in 
the new request the servlet receives.

Your options in this case (or any other case where you want to use data 
from one request in a subsequent request) are pretty much limited to 
either including the data in the redirect URL's query parameters, as you 
are doing, storing them in the user's session, as you suggested, or 
persisting them somewhere else, such as a database.

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]