Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url-mapping and directory

 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a servlet-mapping as below :-

<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/jstl/*</url-pattern>
</servlet-mapping>

and also if I have a directory called /wcd1/jstl which contains (index.html), what will happen for this request :-

http://localhost:8080/wcd1/jstl/

Will it pick up the index.html file or will it map to the servlet ???.
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giju,

My answer would be that the web container directs the request to the servlet.

 
Abhishek Mahanty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request will be handled by the TestServlet
(Assuming that the name of your web app is "wcd1").

Had you not mapped the url-pattern "/jstl/*" to the TestServlet, then the container would have despatched the request to a resource mapped under your web.xml file's <welcome-file-list>. So index.html will be displayed if you had the following in your web.xml.

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

NOTE:
The welcome file gets executed only when a mapped resource for a request uri is not found.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic