This can be achieved by manipulating the configuration of the web.xml file
for that particular web application. This implies a Tomcat web application
configuration, and does not require servlet code.
I have attached a sample of the web.xml
<!--starts web.xml-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- @author scott venter
@created 07 February 2001
@version 1.0.1, September 1, 1999
@info CellPoint Systems www.cellpoint.com
-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<!--I have set up the name for main servlet which will handle all webapp
traffic-->
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>webapp.Login</servlet-class>
<init-param>
<param-name>JDBCDriver</param-name>
<param-value>com.internetcds.jdbc.tds.Driver</param-value>
</init-param>
<init-param>
<param-name>JDBCURL</param-name>
<param-value>jdbc:freetds:sqlserver://sqlserver/webapp</param-value>
</init-param>
<init-param>
<param-name>Username</param-name>
<param-value>sa</param-value>
</init-param>
<init-param>
<param-name>Password</param-name>
<param-value>sa</param-value>
</init-param>
<init-param>
<param-name>MaxConnectionCount</param-name>
<param-value>10</param-value>
</init-param>
</servlet>
<!--Here I map the login servlet to the base context of the web app:
http://localhost:8080/webapp/ will now actually call the login
servlet -->
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--The above configuration negates the need for a welcome-file,
since we are directing a hit to the webapp base context directly to the
login servlet
<welcome-file-list>
<welcome-file>main.html</welcome-file>
</welcome-file-list>
-->
</web-app>
<!--ends web.xml-->
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Milt
Epstein
Sent: Friday, March 02, 2001 8:04 AM
To: [EMAIL PROTECTED]
Subject: Servlet as default "page" for web app
I just started using Tomcat, and hence the 2.2 servlet spec. But I
don't think this is anything specific to Tomcat, it seems like it just
has to do with what the 2.2 servlet spec allows.
What I'm trying to do is have a URL of the form:
http://some.domain.name/blah
go directly to a servlet, i.e. something that normally you'd get to
with a URL of the form:
http://some.domain.name/blah/servlet/blah
I've set up blah as a webapp (i.e. a context), and essentially I'd
like a servlet to be the default "page" of the webapp. The default
page can be a static html page (e.g. index.html) or a JSP
(e.g. index.jsp), so why not a servlet? But I've tried a few things
with the webapp's servlet names and servlet mappings in the web.xml
file, without success.
At jakarta.apache.org, I found a similar question in the FAQ-o-matic,
and it suggested having the default index page do a redirect, and/or
using Apache's mod_rewrite. I tried the former, both with a static
html page (and a META Refresh) and a JSP (and a RequestDispatcher
forward()), and while it works, it changes the Location: shown by the
browser to:
http://some.domain.name/blah/servlet/blah
which I'd like to avoid. I thought maybe there was something
available via the servlet spec (and/or Tomcat) that I was missing.
I'm looking into the mod_rewrite solution as well.
Thanks.
Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html