aspose file tools*
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
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: 1717
    
  25

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: 61658
        
      67

    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
     
    jQuery in Action, 2nd edition
     
    subject: web.xml servlet url-pattern mapping problem