aspose file tools*
The moose likes Servlets and the fly likes Filter mapping based on query string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filter mapping based on query string" Watch "Filter mapping based on query string" New topic
Author

Filter mapping based on query string

siva kumar
Ranch Hand

Joined: May 02, 2004
Posts: 120
Hi Friends,

Can you please clarify on the below

1.) can I do a filter mapping based on query string something like

<Filter-mapping>/servletname?s=1</Filter-mapping>

2.) In the response header can I get the servlet name which has generated this response.

Thanks
Kumar
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

Kumar,
I don't think you can match on parameters in the filter mapping. It seems simple enough to try though. What happens when you try it?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

1. No, it won't work. I don't know how the container will react, but it's not a valid url pattern. By the way, you don't put url patterns directly in the filter-mapping tag, but in the url-pattern tag of the filter-mapping tag. What you could try is :

and check if s=1 in the filter.


[My Blog]
All roads lead to JavaRanch
siva kumar
Ranch Hand

Joined: May 02, 2004
Posts: 120
Hi,

Sorry I typed the tags wrongly, Yes you are right I couldnt do it in tomcat

I think it is not possible.

Thanks for your response anyway
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can't map it according to querystring variables but you can read the variables from within your filter and branch accordingly.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
siva kumar
Ranch Hand

Joined: May 02, 2004
Posts: 120
Thanks Ben,

I am done with my filter development.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filter mapping based on query string