Solved

How to make a servlet "default page" in Tomca

Posted on 2002-06-07
4
233 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 200 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
A solution for Fortify Path Manipulation.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

632 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