Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kayla Richard
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Mark, that's what I initially thought.
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Engin
Cut and paste typo, you know how it goes
[ January 28, 2003: Message edited by: mark howard ]
 
Kayla Richard
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Engin and Mark, this is helpful.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic