• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Manuel Oetzi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is probably a cleaner solution if you did this in a servlet filter
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manuel Oetzi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic