aspose file tools*
The moose likes Servlets and the fly likes What is meant by URL mapping? Can you provide example? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What is meant by URL mapping? Can you provide example?" Watch "What is meant by URL mapping? Can you provide example?" New topic
Author

What is meant by URL mapping? Can you provide example?

Kayla Richard
Greenhorn

Joined: Jan 20, 2003
Posts: 29
I would like to know what is URL mapping. I see it often and also an example would be helpful, please.
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
Kayla
Servlet mapping elements are defined in the deployment descriptor and basically determine which URL pattern will be handled by the servlet.
For instance:

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>

will ensure that MyServlet services requests where the request URI contains the suffix ".jsp", eg:

This is a very simple example. There are a a few rules of precedence that the container follows in determining the appropriate servlet/url mapping.
Kayla Richard
Greenhorn

Joined: Jan 20, 2003
Posts: 29
Thanks again Mark, that's what I initially thought.
Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
Hi Mark, i'm sorry but i think you wanted to say :
http://localhost:8080/MyWebApp/WebService.jsp
without '/servlet' because it's a mapping.
Thanks.
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
Thanks Engin
Cut and paste typo, you know how it goes
[ January 28, 2003: Message edited by: mark howard ]
Kayla Richard
Greenhorn

Joined: Jan 20, 2003
Posts: 29
Thanks Engin and Mark, this is helpful.
 
 
subject: What is meant by URL mapping? Can you provide example?