Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URL Patterns - Trying to understand wildcards  RSS feed

 
J.C. Bustamante
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

According to the java servlet specification, the '*' wildcard only works through an implicit mapping (*.jsp) or at the end of a path mapping (/folder/*). Please see the following web.xml entry



The folders are organized by country (India, US, Mexico) and each of them has an articles folder within them. I want to be able to write a single entry so that it do not have to have a filter mapping for Canada, Mexico, and India and any other country that I choose to add. I tried /*/articles/* but that didn't work because the servlet specification doesn't allow for that kind of entry. I have also tried *.jsp, but I don't want filter 2 to execute for every request. Is there any other way to achieve this that doesn't involve multiple filter mappings?

Thanks,

Juan
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say that your URLs aren't set up in the best order as you have more specific info before less specific.

So rather than /country/articles, I'd have /articles/country. That way, you can map /articles/* and catch all article URLs.
 
Paul Bartels
Greenhorn
Posts: 11
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a situation where you have users, images and thumbnails. So you might have a structure like...

USERS/22/
where 22 is the user's id. Inside this folder you might have an IMAGES folder and a THUMBNAILS folder as well as a whole lot of other relatively static user info DOCUMENTS VIDEO, whatever. It seems to make more sense to organize these by USER.

Later, I might want to use a filter to block some access while allowing thumbnail access, so I would try a USERS/*/THUMBNAILS url-pattern to allow this folder for all users. Of course Tomcat doesn't allow this.

Do we really have to arrange our data

USERS/THUMBNAILS/*
USERS/IMAGES/*

etc...
to get this to work?

If so, then one user's data is 'scattered' across a whole lot of directories, instead of being gathered under the roof of their user number.

Is there another way to do it than employ this counter-intuitive directory structure?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!