Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes URL Mapping : Default Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "URL Mapping : Default Servlet " Watch "URL Mapping : Default Servlet " New topic
Author

URL Mapping : Default Servlet

N S Raju
Greenhorn

Joined: Apr 23, 2004
Posts: 6
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

Joined: Sep 23, 2000
Posts: 3254
    
    2
Can you post your web.xml here?


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
N S Raju
Greenhorn

Joined: Apr 23, 2004
Posts: 6
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

Joined: Mar 14, 2002
Posts: 17
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.


Regards<br />Bala<br />SCJP 1.2, SCWCD 1.4
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
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?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: URL Mapping : Default Servlet
 
Similar Threads
JSP Not able to Identify the JS, CSS file path
The requested resource is not available
need help: .jsp to .jspf mapping
specify a default servlet in DD
my servlet says its unavailable in IE