aspose file tools
The moose likes Servlets and the fly likes filtering a request Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "filtering a request" Watch "filtering a request" New topic
Author

filtering a request

Pawanpreet Singh
Ranch Hand

Joined: Jun 12, 2005
Posts: 264

Hi Everybody,

I need your help for writing a filter for changing the request path for a servlet. Suppose i pass a request

http://localhost:8080/periodicals/electronicsforyou/journal

instead of

http://localhost:8080/periodicals?param1=electronicsforyou¶m2=journal

I want that user type the first url with request path periodicals/electronicsforyou/journal and finally the filter convert that request path into ?param1=electronicsforyou¶m2=journal.

Is it possible. Could you please advise.

Sincerely,
Pawan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35237
    
    7
It this was an Apache httpd with mod_rewrite it would be so easy...


Android appsImageJ pluginsJava web charts
Pawanpreet Singh
Ranch Hand

Joined: Jun 12, 2005
Posts: 264

Can i use Servlet Filters in this case?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35237
    
    7
Yes you can, and there is a servlet filter clone of Apache mod_rewrite, which may do what you need done: Url Rewrite Filter
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
But you can also use a simple servlet to do that if you have only this url to rewrite!

In this servlet you just forward to the good url!
Ahmed Salah
Greenhorn

Joined: Jun 25, 2006
Posts: 7
you can add simple code in doGet method that tests for these QueryString variables if they are null redirect him to the second path
 
jQuery in Action, 2nd edition
 
subject: filtering a request
 
Similar Threads
passing a url paramter to a servlet
Passing values from Javascript to JSP application
Filters ! Request URL handling
problem retrieving from database
linking struts2 action to pre-existing pure Java servlet