?
Solved

How to make a servlet "default page" in Tomca

Posted on 2002-06-07
4
Medium Priority
?
234 Views
Last Modified: 2013-11-24

I want "www.mydomain.com" to invoke one of servlets,
which means a servlet is my dafaut page.
Conventionally, servlet is invoked by calling
www.mycomain.com/servlet/MyServlet.
Does anybody know how to configure??
I am using Tomcat only. I can use Apache if needed.
Please help.
0
Comment
Question by:jhy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 800 total points
ID: 7062457
in your web.xml put something like this:
    <servlet>
        <servlet-name>
            MyServlet
        </servlet-name>
        <servlet-class>
            com.package.MyServlet        
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>
            MyServlet
        </servlet-name>
        <url-pattern>
            index.html
        </url-pattern>
    </servlet-mapping>
0
 
LVL 35

Expert Comment

by:girionis
ID: 7062482
 It depends on what version of tomcat you are using. I am not sure about the latest Cataline one but in the older versions you can define it in your web.xml file:

<welcome-file-list>
    <welcome-file>default.html</welcome-file>
</welcome-file-list>

  You can redirect to the servlet from your default file.

  Additionally you can also use the <servlet-mapping> tag, but I have not used Tomcat for ages, so someone else might be able to help you more.

  Hope it helps.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7062488
the servlet mapping works on both tomcat 3.2.* and tomcat 4.0
0
 
LVL 35

Expert Comment

by:girionis
ID: 7062508
 I see... I have not used Tomcat since its 3.2 version... I know that Catalina is a completely new architecture so I was not sure if the <servlet-mapping> and <servlet> still work the same. To be honest I am not 100% sure even for the <welcome-file-list>.

  Kind regards
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question