You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brad Taylor <bt...@western-metal-supply.com> on 2004/09/01 21:16:49 UTC

How do I make my servlet the welcome page

I am running tomcat 5.0.9.  I currently enter a url like
http://localhost:8080/myapp.  This causes a "redirect" page to be
briefly displayed followed by my servlet getting invoked and serving the
"real" page.  I would like to bypass this redirect, but can not seem to
get it to work.  I have tried changing my welcome-file-list to mypage.do
and I have tried creating a servlet-mapping specifying index.html.

Content of ....\conf\Catalina\localhost\myapp.xml

<Context path="/myapp"
    docBase="C:\eclipse\workspace\com.mycom\myapp\ui.html"
    debug="0"
    privileged="true"/>

Index.html exists in the above directory

This is the essential contents of WEB-INF\web.xm in above directory

<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app>
  <display-name>Myapp</display-name>
  <description>Myapp desc</description>
  <welcome-file-list>index.html</welcome-file-list>
  <!--
  Define myservlet
  -->
  <servlet>
    <servlet-name>myapp</servlet-name>
    <servlet-class>com.myapp.ui.MyServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>myapp</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

Contents of index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
  <meta http-equiv="refresh" content="0;url=mypage.do"/>
    <title>My page</title>
  </head>
  <body>
   Redirecting to actual navigation page
  </body>
</html>

Any help appreciated


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: How do I make my servlet the welcome page - resolved

Posted by Brad Taylor <bt...@western-metal-supply.com>.
After trying both suggestions (moving welcome file list to end of
web.xml and adding the 2.4 schema to the web tag), it still did not
work.  I tried changing the web.xml in the tomcat\conf directory, it
still did not work.  I removed index.html from my directory and it
started displaying the directory.  Finally I had the idea of creating an
empty file called mypage.do (same name as my welcome file) and things
started to work.  I then reset everything back to how it started,
welcome-file-list at top of web.xml & not 2.4 schema, and it still
works.  

So in a nutshell in order for welcome page mechanism to server up a
servlet, a file must exist in the directory, even thou it is never used.
I don't know enough about security to comment on Jonathans concern.

Thanx for y'alls help, I appreciate it.

Thanx 
brad


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: How do I make my servlet the welcome page

Posted by Jonathan Eric Miller <je...@uchicago.edu>.
The problem that I found with doing it this way is that I had a 
security-constraint on my application and it wasn't being enforced when I 
tried to do that. So, I created an index page that redirects to the 
application.

Jon

----- Original Message ----- 
From: "QM" <qm...@brandxdev.net>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, September 01, 2004 2:26 PM
Subject: Re: How do I make my servlet the welcome page


> On Wed, Sep 01, 2004 at 02:16:49PM -0500, Brad Taylor wrote:
> : I am running tomcat 5.0.9.  I currently enter a url like
> : http://localhost:8080/myapp.  This causes a "redirect" page to be
> : briefly displayed followed by my servlet getting invoked and serving the
> : "real" page.  I would like to bypass this redirect, but can not seem to
> : get it to work.  I have tried changing my welcome-file-list to mypage.do
> : and I have tried creating a servlet-mapping specifying index.html.
>
> Change your web.xml to specify the new 2.4 schema , aka:
>
> <web-app
>        xmlns="http://java.sun.com/xml/ns/j2ee"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>        version="2.4"
>>
>
> Then add your servlet's mapping to <welcome-file-list>.
>
>
> [for the archives: using servlets as welcome files is supported as of
> servlet spec 2.4, which Tomcat 5.x implements]
>
> -QM
>
> -- 
>
> software  -- http://www.brandxdev.net
> tech news -- http://www.RoarNetworX.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: How do I make my servlet the welcome page

Posted by QM <qm...@brandxdev.net>.
On Wed, Sep 01, 2004 at 02:16:49PM -0500, Brad Taylor wrote:
: I am running tomcat 5.0.9.  I currently enter a url like
: http://localhost:8080/myapp.  This causes a "redirect" page to be
: briefly displayed followed by my servlet getting invoked and serving the
: "real" page.  I would like to bypass this redirect, but can not seem to
: get it to work.  I have tried changing my welcome-file-list to mypage.do
: and I have tried creating a servlet-mapping specifying index.html.

Change your web.xml to specify the new 2.4 schema , aka:

<web-app
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4"
>

Then add your servlet's mapping to <welcome-file-list>.


[for the archives: using servlets as welcome files is supported as of
servlet spec 2.4, which Tomcat 5.x implements]

-QM

-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org