Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than one url-pattern alternatives

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I'm busy looking at filter-mapping which has the property url-pattern.

I had read a lot of the forums here on this subject but I can't seem to find out if there is a way to list more than one url-pattern in a filter-mapping inside a single declaration.

For example, at the moment I have this



and ideally I would prefer something like this



or



Can anyone tell me if this is at all possible?

Many thanks,
Rachel
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rachel,

no, you can't. But why should you want the other syntax?
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mirko

In the application there are 5 filters that get applied. Originally there was only one url pattern that we were applying the filters to, but now we are putting in friendly urls (it's a tapestry application) and for every friendly url we are having to copy every filter declaration.

So while we started with 5 declarations (one per filter) there are now 15 (as there are now 3 url patterns).

The only other option is to use /* as the pattern but I have read that this could lead to complications with malformed url's.

Do you have any link to documentation that shows that it can't be done? I can see from the many, *many* examples that it doesn't look possible, but I always like to see documentation so that I can understand why.

Thank you for your reply,
Kind regards,
Rachel
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for anyone else following, I found in the servlet 2.5 spec the following:

Previous versions of the servlet schema allows only a single url-pattern in a filter
mapping. For filters mapped to multiple URLs this results in needless repetition of
whole mapping clauses.


So I assume that means in the 2.3 that I'm using that I need to declare only one pattern per filter per declaration.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rachel,


So I assume that means in the 2.3 that I'm using that I need to declare only one pattern per filter per declaration


I think you are right. Not sure of 2.5 Spec. Shall check and get back.
 
Karina Schmidt
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Has anyone further looked into this?
I am currently working with Netbeans 6.5 and servlet spec 2.5 and if I have

Netbeans complains the web.xml is invalid BUT filter works kindof OK and I have no deployment errors in Glassfish.

If I have

Netbeans doesn't complain, deployment is fine but filter isn't processed anymore for the first pattern.

I am currently duplication the <filter-mapping> tag but would be glad about another option.

Thank you,
Karina

 
Wilmer Sarmiento
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karina,

Can you post your <web-app> element? I want to double check the attribute xsi:schemaLocation. I upgrade my servlet specification from 2.3 to 2.5 and my IDE (MyEclipse) complains about the schema. However, I change these atributtes and is working fine on my app server and on MyEclipse:

2.3:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.3" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd">


2.5:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wilmer, that post is over a year old and Karina has a single post. I doubt she's still here looking for an answer.
 
Wilmer Sarmiento
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WOW! Right! I'm still on 2009.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

P.S. I still keep writing 2009 in my notebook...
 
Bert Meijers
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, welcome to Javaranch !! :-)

Allready 2011? Ahhh time flies when you're having fun...

Anyway, I just googled on the same issue: multiple occurrences of the <url-pattern> inside <filter-mapping>
Just curious about it, I did some trying and my Eclipse-Beer-application accepted it without hesitation.

Just wondering (without specifying any version-numbers etcetera..) is it still likely to be very vendor-specific?
Or is it nowadays part of in the official specs?

I know, this time I didn't much research myself, tomorrow is my exam-day, so for now I prefer to do some
freewheeling through the exam-stuff.

Can't believe I learned all that.....

Greetz
Bert

Ah.. and maybe I did not ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic