• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is probably a cleaner solution if you did this in a servlet filter
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic