Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • 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


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic