aspose file tools*
The moose likes Servlets and the fly likes Servlet mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet mapping" Watch "Servlet mapping" New topic
Author

Servlet mapping

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
<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

Joined: Jan 10, 2002
Posts: 61769
    
  67

Hint: What does a * usually signify in a pattern?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Nov 25, 2008
Posts: 1225
" 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

Joined: Mar 24, 2008
Posts: 3860

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

Joined: Jan 28, 2008
Posts: 5575

aruna ... i hope still you have the confusion. better try it out yourself with all combinations
 
jQuery in Action, 2nd edition
 
subject: Servlet mapping