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.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Aug 02, 2003
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
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 -->
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-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.
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
Joined: Aug 02, 2003
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.