• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Url Pattern

 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
i saw a question in one of the mock exams. the question goes like this .
What could be the <Url Pattern> if you want ReportServlet to service only requests that contain /Report.

Answer is /Report/ReportServlet.

i thought answer would be /Report/*

please explain me why.


Thanks and Regards,
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, answer should be /Report/*
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But they have given explanation that says any request for /Report/abc.jsp will also be redirected to ReportServlet.

i am confused after reading this.

please help me out

Thanks and Regards,
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm!

In this case the url-pattern should be /Report but not /Report/ReportServlet.
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But they have given explanation that says any request for /Report/abc.jsp will also be redirected to ReportServlet.


Above statement is fine as ReportServlet is invoked for request /Report/abc.jsp .Anyway here request is containing /Report.

The answer is /Report/*

web.xml
----------------------------------------------------------------
<servlet>
<servlet-name>servlet1</servlet-name>
<servlet-class>com.xyz.web.ReportServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>servlet1</servlet-name>
<url-pattern>/Report/*</url-pattern>
</servlet-mapping>
----------------------------------------------------------------
ReportServlet will only service requests that contain /Report

Hope this clarifies!!
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are three types of url pattern -

1. exact - /Beer/BeerSelect.do ( any extension other ths 'do' is OK )
2. directory - /Beer.* ( handles all requests havin /Beer/ in the URL
3. extension - *.do , *.jsp etc

hth
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. exact - /Beer/BeerSelect.do ( any extension other ths 'do' is OK )
2. directory - /Beer.* ( handles all requests havin /Beer/ in the URL
3. extension - *.do , *.jsp etc


a smal correction to the above ,
2. directory - /Beer/* ( handles all requests havin /Beer/ in the URL
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic