• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use filters to change the jsp file called by a servlet?

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I was wondering; is it possible to have a filter know the jsp file that a servlet has forwarded the request to?

I am working on a project where from my servlet I have the following code to forward the request to a jsp file.



What I want is to be able to know which the value of myjsppage from a post processing filter.
The reason I need this is so that I can change this according to its value.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your filter is not going to see the response until after the servlet and JSP have finished, right? So how could you change the JSP? - or do you have something else in mind.

Bill


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like this is a decision that should be made in the servlet itself. Do you have a good reason for moving this logic somewhere other than where it makes the most sense?
 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is that I want to be able to keep all the servlet code but change the called jsp pages depending on the device from where the request has been made (ex: mobile). If there is another solution let me know The one I thought of was to create a filter that if request is coming from a mobile then this filter would change the jsp page to the mobile one. If I continue down this line, the other option I have is to change code in every servlet so that these forward depending on from where the request has originated (not a problem, just a bigger change, and most probably more clean).

EDIT:
Just to be more clear my plan was that if servlet forwards request to hello.jsp, then the filter would change this forward (do another forward) to hello_mobile.jsp. As I said, if anyone knows of a better solution let me know.

reply
    Bookmark Topic Watch Topic
  • New Topic