• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL Mapping : Default Servlet

 
N S Raju
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai !
When we use only "/" for url-pattern then the servlet is supposed to be the default servlet.
I have defined two servlets with url-pattern "/" but while deploying the web-app Tomcat( iam using v5.0) does not complain...
is this behaviour left to the container ... ??
thanks !
Surya
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3753
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your web.xml here?
 
N S Raju
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Paul !
Heres the web.xml snippet
<servlet>
<servlet-name>errortest</servlet-name>
<servlet-class>com.surya.servlet.ErrorTest</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>errortest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>httptest</servlet-name>
<servlet-class>com.surya.servlet.HelloWorld</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>httptest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

The servlet defined last as the default servlet is being picked up, but while deploying this servlet no errors are occuring(which I had expected).
thanks
Surya
P.S Iam using Tomcat 5.0(Servlets 2.4)

Originally posted by Paul Anil:
Can you post your web.xml here?
 
Balamurugan Muthiah
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems this works based on the container.
While Tomcat does not report any error and works fine taking the last servlet-mapping for "/" into account, websphere test environment in WSAD does throw error.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you folks agree that the best thing to do is create a <welcome-file> element in your deployment descriptors and have some JSP document just forward to the actual servlet that you're interested in?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic