wood burning stoves 2.0*
The moose likes Servlets and the fly likes URL-Pattern Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL-Pattern Issue" Watch "URL-Pattern Issue" New topic
Author

URL-Pattern Issue

Michael Cropper
Ranch Hand

Joined: Sep 30, 2009
Posts: 137
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

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.

    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Michael Cropper
    Ranch Hand

    Joined: Sep 30, 2009
    Posts: 137
    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
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60766
        
      65

    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

    Joined: Sep 30, 2009
    Posts: 137
    Ok, I will take a look and see what I can find

    Thanks for the speeds response!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: URL-Pattern Issue
     
    Similar Threads
    Why getInitParameter( ) return null?
    HTTP Status 404
    servlet-mapping tag of deployment descriptor
    Help with EJB DI
    Servlet Not working