aspose file tools*
The moose likes Servlets and the fly likes web.xml url-pattern wildcards? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web.xml url-pattern wildcards?" Watch "web.xml url-pattern wildcards?" New topic
Author

web.xml url-pattern wildcards?

James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
My current servlet url is:
http://localhost:8080/MyWebApp/en/pp/login.html

How should I change my web.xml file so replacing "en" with any value would work? E.g.,
http://localhost:8080/MyWebApp/hk/pp/login.html
http://localhost:8080/MyWebApp/es/pp/login.html
etc.

My current web.xml snippet:


Have tried the "*" wildcard, but with no success. If it's not possible, what other method can I use?

Thanks in advance,
James
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30894
    
158

James,
Besides listing them all? Can you change URLs to one of:
http://localhost:8080/MyWebApp/lang/en/pp/login.html
http://localhost:8080/MyWebApp/pp/en/login.html

[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
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Hiya Jeanne,

Yes, I could change it to either of those. Do you have a solution based on that?

Thank you,
James
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61596
    
  67

Just map the prefix to a servlet, and within the servlet, use getPathInfo() to get the rest of the URL.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Thanks. Like...

with urls http://localhost:8080/MyWebApp/pp/Login/hk.html and http://localhost:8080/MyWebApp/pp/Login/hk.wml

It works, but will be a pain changing all the dynamic link code...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61596
    
  67

Yeah, the Servlet specification doesn't give us a whole lot of leeway in creating URL patterns with wildcards. We essentially get the choice of a trailing wildcard, or a filename wildcard.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web.xml url-pattern wildcards?