Solved

How to make a servlet "default page" in Tomca

Posted on 2002-06-07
4
230 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert String matching to regex in java 4 33
hibernate jars 4 30
spring jars download 1 27
eclipse console opening separately 2 21
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

773 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