This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet in welcome-file-list

 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
satish kolli
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!