File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet mapping

 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<servlet-mapping>
<servlet-name>accountServlet</servlet-name>
<url-pattern>/myaccount/*</url-pattern>
</servlet-mapping>

what is the reason for using " /* " in the url pattern place.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: What does a * usually signify in a pattern?
 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this code i found in on of the servlet book.
but i don't understand what is they use " /* " for url mapping

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the quote again with the important part highlighted:
Whenever the container receives a request URL that starts with
<webapp name>/account or <webapp name>/myaccount, it will send that
request to accountServlet.


Think about how would the above statement need to change if the "/*" were left off?
 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" if i used
<url-pattern>/myaccount</url-pattern>.

and
<url-pattern>/account</url-pattern>.

the if url pattern accout or myaccount it matches the both request to the accountServlet.
but my question is why they use " /* " after them. "
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aruna sameera wrote:the if url pattern accout or myaccount it matches the both request to the accountServlet.
but my question is why they use " /* " after them. "


You might want to look at this in your post.

A string beginning with a / and ending with the /* characters is used for determining
a servlet path mapping. We will discuss servlet paths in section 5.2.4.


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aruna ... i hope still you have the confusion. better try it out yourself with all combinations
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic