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

Servlet in welcome-file-list

Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
Hi
Is it possible to invoke a servlet as welcome-file .
I tried placing servlet in DD , in many ways:
<welcome-file-list>
<welcome-file>Servlet</welcome-file>
</welcome-file-list>
but Tomcat wont recongnize.
So , CAN we use servlet as welcome file or not?

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .


Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
satish kolli
Greenhorn

Joined: Sep 21, 2001
Posts: 24
I guess you can give your URL-PATTERN Which you gave in SERVLET-MAPPING.
For ex: If /servletToJsp is the url-pattern in my servlet mapping to my actual servlet
<welcome-file-list>
<welcome-file>/servletToJsp</welcome-file>
</welcome-file-list>
Thanks!
Satish Kolli, SCJP2
Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
Thankx satish !
I tried ur solution , but it do not work , at least not with Tomcat4.0.1 . Which web-container u r using ?
Any other idea? anyone
------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
Tim Duncan
Ranch Hand

Joined: Aug 20, 2001
Posts: 150
Well it does say <welcome-file>, so I guess it's not surprising.
You could use HTML/Javascript trickery to achieve your aim. Your welcome file would be a minimal file like the following, which redirects to the servlet URL (the refresh is there in case Javascript is disabled).

<HTML>
<HEAD>
<META HTTP-EQUIV="refresh" CONTENT="5;
URL="http://localhost:8080/servlet/Test">
</HEAD>
<BODY>
<SCRIPT>
window.location.href =
"http://localhost:8080/servlet/Test/";
</SCRIPT>
</BODY>
</HTML>

[This message has been edited by Tim Duncan (edited November 02, 2001).]
Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
Thankx Tim
Nice tweak , and it works very fine .
But so is it final now that "we can NOT directly place servlet as a welcome-file " , right?

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
Stefan Stefansson
Greenhorn

Joined: Dec 08, 2002
Posts: 1
Hi!
I simply use a servlet mapping to / for that.
Here's a sample web.xml that defines one servlet and maps that to the root of the context:
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
The Servlet 2.4 spec allows a servlet as a welcome file.
http://www.onjava.com/pub/a/onjava/2004/02/11/jspcookbook.html
If you are using Tomcat 5.x, you can take advantage of this feature.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet in welcome-file-list