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

Servlets 2.4: Mapping the root path exclusively?

Andreas Schildbach
Ranch Hand

Joined: Jan 22, 2003
Posts: 34
Hello everybody,

this is a rather basic question:

How can I map the root path of my web application (http:/myserver/myapp/) - and only the root path - to a specific servlet? If I use <url-pattern>/</url-pattern>, everything beginning with a / seems to be mapped.

Servlet Spec is 2.4, container is Tomcat 5.0/5.5. What would be the correct pattern?

Regards,

Andreas
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

http://simple.souther.us has two projects that show how to make welcome files out of servlets.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
anupa oru
Ranch Hand

Joined: Jan 15, 2005
Posts: 118
Hi,
u can go through this link which explain the issue

http://www.whizlabs.com/tutorial/scwcd/j-scwcd-3-6.html
Thanks
Andreas Schildbach
Ranch Hand

Joined: Jan 22, 2003
Posts: 34
Thanks for your help. Unfortunately, these tutorials don't explain why _everything_ is mapped to my Servlet with <url-pattern>/</url-pattern>.

However, I tried to use a welcome file:

<servlet>
<description></description>
<display-name>test</display-name>
<servlet-name>test</servlet-name>
<servlet-class>Test</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

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

Unfortunately this does not work either. My servlet receives all requests ending on .html, but not any "directory" URLs like "http://mydomain/myapp/directory/". These requests, are answered with an 404 error instead.

Why does the above not work?

Regards,

Andreas
 
Don't get me started about those stupid light bulbs.
 
subject: Servlets 2.4: Mapping the root path exclusively?