File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Use filters to change the jsp file called by a servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Use filters to change the jsp file called by a servlet?" Watch "Use filters to change the jsp file called by a servlet?" New topic
Author

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

Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 99
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

Joined: Mar 22, 2000
Posts: 12682
    
    5
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



Java Resources at www.wbrogden.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 99
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Use filters to change the jsp file called by a servlet?
 
Similar Threads
Filtering
NullPointerException in AutoScrollPhaseListener
Filter not called
richfaces and problems with navigation
Web.xml question