aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet as a welcome file 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 "Servlet as a welcome file" Watch "Servlet as a welcome file" New topic
Author

Servlet as a welcome file

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Can a <welcome-file> be a servlet?

I tried it, but it didn't seem to work. Here is the relevant portion of the web.xml:


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

You need to use the mapped URL not the servlet name.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Bear Bibeault wrote:You need to use the mapped URL not the servlet name.


Hi Bear, do you mean the part that goes within the <url-pattern> tags?

I did change my web.xml to that (& restarted tomcat) but same result.

New DD:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

What version of Servlets?
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Bear Bibeault wrote:What version of Servlets?


I have Tomcat 6.0 & according to the documentation, that implements Servlet 2.5 and JavaServer Pages 2.1
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1717
    
  25

Hi Nidhi,

You should be able to define a Servlet as welcome file.

remove the "/" from
<welcome-file>/show.do</welcome-file>


and try again.

Regards,
Frits
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Hi Frits,

Yes your suggestion did work. I should have remembered that unlike url-pattern & error-page location, welcome files do not start with a forward slash.

Thanks so much,
Nidhi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Servlet as a welcome file