• 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

URL-Pattern Issue

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I must be missing something obvious here.

The URL pattern I am trying to use is;

<servlet>
<servlet-name>test</servlet-name>
<servlet-class>package.homepage</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/servlet/test.*</url-pattern>
</servlet-mapping>

Although the URL "http://localhost:8080/package/servlet/text.sometext" does not work, whilst the URL "http://localhost:8080/package/sevlet/text.*" does work.

So the * is being treated as a literal character and not as a wildcard.

I have had a look around and I can't seem to find an explanation for this odd behaviour. I am using Tomcat v6 as my container.

Any ideas?

Regards,
Michael
 
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

whilst the URL "http://localhost:8080/package/sevlet/text.*" does work.


I doubt that, as there are two typos in that URL. Please take better care when posting to avoid red herrings.

In any case, your pattern is not one of the supported wildcard forms. You can use one of:

  • /prefix/*

  • or

  • /*.suffix

  • Your pattern does not fit one of these supported patterns.
     
    Michael Cropper
    Ranch Hand
    Posts: 166
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    My bad on the typo

    Can you recommend a good website for me to gather further knowledge on other patterns? I would also like to learn about including regular expressions within these (if possible) too.

    I will look at fixing the current issue above with what you have suggested.

    Thanks
     
    Bear Bibeault
    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
    The Servlet Specification is the best place to go for any information on Servlets.

    But no, no other patterns, and certainly no regular expressions, are supported (at least by Servlets 2.x -- I haven't had a chance to really dive into Servlets 3.0 yet).
     
    Michael Cropper
    Ranch Hand
    Posts: 166
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok, I will take a look and see what I can find

    Thanks for the speeds response!
    reply
      Bookmark Topic Watch Topic
    • New Topic