• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web.xml url-pattern wildcards?

 
James Hodgkiss
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33691
316
Eclipse IDE Java VI Editor
 
James Hodgkiss
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just map the prefix to a servlet, and within the servlet, use getPathInfo() to get the rest of the URL.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic