aspose file tools*
The moose likes Struts and the fly likes Setting request parameter from interceptor and accessing in ActionClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting request parameter from interceptor and accessing in ActionClass" Watch "Setting request parameter from interceptor and accessing in ActionClass" New topic
Author

Setting request parameter from interceptor and accessing in ActionClass

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 751
Hi,

I am setting parameters from my custom interceptor, and trying to access from my ActionClass but i am not able to get the parameter in My Action Class.



I think they are action parameter not request parameters.

Can i set request parameters from interceptors ?


Jigar Naik


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yes, using the request object.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 751


but there is no no method for setting request parameter. such as request.setParameter(..,..); I can setAttribute only.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()

In general it will almost always be quicker to do the research yourself.

(Hmm, that might be an immutable map though.)

Why do you want to do this, anyway? In general, S2 tries to remove dependencies on the request.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 751
Well, my requirement is as below..

I have my personal website,
in which i am trying to display google ads based on the content of the page.
And few pages requres authentication.
So i have created one super user for google ads,
and when the client user logs in, google user will also login with its username/password.
and will try to read the loginId of the client user from query string(requestParameters)
and google will get the same content which client user got,
and based on the content google ads will get displayed on client user's page.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh. I don't see any reason to (a) do that in an interceptor, or (b) modify any request parameters.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 751
Oh then how will google user get the id of currently logged in user
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting request parameter from interceptor and accessing in ActionClass
 
Similar Threads
Struts 2 Question
struts2 login interceptor not finding session attribute of user details.
ModelDriver Interceptor + not getting my object
Ideas Needed to insert Action execution time in DB !!
Struts 2 session writing efficiency / timing