This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes web.xml servlet url-pattern mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web.xml servlet url-pattern mapping problem" Watch "web.xml servlet url-pattern mapping problem" New topic
Author

web.xml servlet url-pattern mapping problem

Brian M Smith
Ranch Hand

Joined: Aug 13, 2009
Posts: 35
I'm not sure if I'm going to be able to do this, but figured I would ask.

I need to create a servlet to handle multiple URL patterns. My servlet needs to be able to handle a pattern that looks like this /*/leftNav/*

I'm not a I little confused by what the servlet 2.4 spec means by "A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping." Does this mean multiple wildcard characters may not be used when defining a url-pattern? When I attempt to load the url http://localhost:8080/test/leftNav/somethinghere.js, I'm getting a blank page returned to me. This shouldn't be happen as the servlet will output a test string on the page.

Any ideas?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1642
    
  23

Hi Brian,

Multiple wildcard characters in URL mapping is not allowed.

You have to options:
  • You either write all paths like: /test/leftnav/*
  • or
  • Use the default mapping "/" (as a last resort)

  • Regards,
    Frits
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60804
        
      65

    General wild-card patterns are not supported. So, no, the leading wild-card will not work.

    What are you really trying to accomplish?


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Brian M Smith
    Ranch Hand

    Joined: Aug 13, 2009
    Posts: 35
    Frits,

    Thank you for the reply. That is what I thought was going on. I will just come up with another solution.

    -Brian
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: web.xml servlet url-pattern mapping problem
     
    Similar Threads
    Tomcat/JSP help me
    How to store images into mysql using jsf and java coding
    url-pattern for servlets
    servlet mapping problem
    Wildcard mapping