Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

URL Patterns - Trying to understand wildcards

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 11
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic