| Author |
More than one url-pattern alternatives
|
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
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
Joined: May 14, 2007
Posts: 244
|
|
Hi Rachel, no, you can't. But why should you want the other syntax?
|
SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
|
 |
Rachel Swailes
Ranch Hand
Joined: May 18, 2004
Posts: 434
|
|
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
Joined: May 18, 2004
Posts: 434
|
|
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
Joined: Apr 20, 2006
Posts: 3327
|
|
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.
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
Karina Schmidt
Greenhorn
Joined: Jan 08, 2009
Posts: 1
|
|
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
Joined: Jan 21, 2010
Posts: 2
|
|
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
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Wilmer, that post is over a year old and Karina has a single post. I doubt she's still here looking for an answer.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Wilmer Sarmiento
Greenhorn
Joined: Jan 21, 2010
Posts: 2
|
|
WOW! Right! I'm still on 2009.
Thanks!
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
Welcome to the Ranch!
P.S. I still keep writing 2009 in my notebook...
|
 |
Bert Meijers
Greenhorn
Joined: Feb 06, 2011
Posts: 15
|
|
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 ...
|
 |
 |
|
|
subject: More than one url-pattern alternatives
|
|
|