aspose file tools*
The moose likes Struts and the fly likes How to add a parameter for the result within an interceptor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to add a parameter for the result within an interceptor?" Watch "How to add a parameter for the result within an interceptor?" New topic
Author

How to add a parameter for the result within an interceptor?

Manuel Oetzi
Greenhorn

Joined: Jun 23, 2011
Posts: 10
Hi all,

the background of my question is, that I want to analyse the current user agent within an interceptor and if the user is using a mobile browser I want to simply set a flag (usingMobilBrowser=true) which can be used within the result JSP to decide which css sheet is included.

Unfortunately I don't know how to add such a parameter within an interceptor. I tried different things with the actionInvocation object, but non of it was successful.

Could anyone give me a hint how to solve this issue?

Greetings,
oetzi
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

It is probably a cleaner solution if you did this in a servlet filter
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

you can identify the mobile user in interceptor. write a custom interceptor which is implementing parameterAware and make sure that interceptor order parameter interceptor <interceptor-ref name="params"/> followed by custom interceptor. Thank you.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Manuel Oetzi
Greenhorn

Joined: Jun 23, 2011
Posts: 10
Hello Mohana,

thanks for your comment, but my actual question was how I can set a new parameter within the interceptor so that I can use this parameter within my JSP page.
All my test failed so far



Greetings,
oetzi
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

you can identify the user through request parameters why do you need extra flag and it's not advisable getting parameters from actionContext. Use parameterAware interface.
Manuel Oetzi
Greenhorn

Joined: Jun 23, 2011
Posts: 10
Because I want to decide within the JSP whether I have to load a normal CSS file or the mobile version.
So:
1. check the user agent within the interceptor
2. set a flag (usingMobileBrowser) if it is a user agent of a mobile browser
3. use this flag within the JSP to load the respective CSS file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add a parameter for the result within an interceptor?