File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Changing the default Page in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Changing the default Page in Tomcat" Watch "Changing the default Page in Tomcat" New topic
Author

Changing the default Page in Tomcat

Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
hi all,
How do I change the default page in the tomcat, ie when I type
http://localhost:8080/ it should route to my application say sampleweb inside the webapps directory and display my index.jsp. But it normally goes to ROOT dir in the webapps directory and displays the index.jsp in that folder.

Thanks in advance

Regards,
Sivaraman.L


Regards,
Sivaraman.L
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
Hi,

You might find an answer Here

Is this what you were looking for?


Cheers,
Swamy
[ December 15, 2004: Message edited by: Ramaswamy Srinivasan ]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Moving to the Tomcat forum...


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
hi all,
I can always put a index.jsp in the web-apps/ROOT folder which can just refresh my page, but I want to know where it is configured that by default tomcat request (on typing http://localhost:8080/) goes to web-apps/ROOT folders index.jsp

Regards,
Sivaraman.L
Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
Hi Sivaraman,
Since every web application invoked in Tomcat must based on its
WEB-INF/web.xml, so if you go to your local Tomcat's
web-apps/ROOT/WEB-INF, look for web.xml, you will see the following, (or similar stuff,
varies from TomCat's version):
<!-- JSPC servlet mappings start -->

<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>

<!-- JSPC servlet mappings end -->

Those are where when you type http://localhost:8080/ goes, The Tomcat
get this request, based on the web.xml, directly make your request go to
index.jsp, if you wanna move to your own page (instead of overwritting
index.jsp), you just need to do

<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>

<!-- <servlet-class>org.apache.jsp.index_jsp</servlet-class> -->
<jsp-file>/YourOwnJsp.jsp</jsp-file>
</servlet>
Then, restart server, it should go to your page when you type
http://localhost:8080/

All this relates to the Servlet mapping, there's a very good book to recommend, SCWCD exam study kit, if you go to SCWCD forum, you'll see this book is rated as "golden" book. Once you read the first 5 chapters, you'll havea great understanding for how servlet/jsp works.

I used to have the similar question as yours, after I read that book, everything is clear for me.

Hai



Originally posted by Sivaraman Lakshmanan:
hi all,
I can always put a index.jsp in the web-apps/ROOT folder which can
just refresh my page, but I want to know where it is configured that by
default tomcat request (on typing
http://localhost:8080/) goes to web-apps/ROOT folders index.jsp

Regards,
Sivaraman.L
Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi Hai Lin,
Thanks for your reply. My web-apps/ROOT/web.xml file does not contain a servlet mapping entry. It just contains the welcome file list. where I have made the changes but still I am not able to get the result.
Can you please tell me where can I get the SCWCD Exam kit. I am much eager to buy it since there is a lot good comments about the book in the forum as you said.


Regards,
Sivaraman.L
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing the default Page in Tomcat