• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

web.xml url-pattern wildcards?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
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
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic