• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing the default Page in Tomcat

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You might find an answer Here

Is this what you were looking for?


Cheers,
Swamy
[ December 15, 2004: Message edited by: Ramaswamy Srinivasan ]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Tomcat forum...
 
Sivaraman Lakshmanan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic