aspose file tools*
The moose likes Tomcat and the fly likes  web.xml andf default webapplication folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark " web.xml andf default webapplication folder " Watch " web.xml andf default webapplication folder " New topic
Author

web.xml andf default webapplication folder

may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
Two questions:

1. Where to define my own web application folder? Tomcat 4.1.30 default application folder is /webapp/examples/, I found in /conf/server.xml :
<Host>
<Context path="/examples" docBase="examples" debug="0"

reloadable="true" crossContext="true"/>
</Host>

Can I just add my webapplication here inside the same <host> tag like

<Host ....>
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true"/>
<Context path="/myappliction" docBase="myapplication" debug="0"
reloadable="true" crossContext="true"/>
</Host>

After I can put my stufll like
/webapp/myapplication/WEB-INF/classes/*.class
/webapp/myapplication/WEB-INF/jsp/*.jsp
/webapp/myapplication/WEB-INF/web.xml

2. I learn to edit /webapp/examples/WEB-INF/web.xml, replace the one with a simple version as the followings to test. Not working when I try http://localhost/examples/servlet/HelloServlet

<?xml version="1.0" encoding="ISO-8859-1"?>


<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<web-app>
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Maybe we should have a headline on this forum: don't use /servlet/ - see the Invoker FAQ
Bill
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

1)

A) The tomcat 4.1.30 "default application folder" is *not* /webapp/examples/

The 'default' webapp is the one that is configured to respond to a request URI path of "" (empty). So you should see one that looks like...

<Context path="" docBase="ROOT" debug="0" ...>

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html
read up on the path attribute.

b) Where to define my own web application folder?

Anywhere you want.
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/context.html
read up on the docBase attribute. Note that it doesn't have to be under webapps. What it *MUST* have is a WEB-INF folder with a web.xml file in it. The web.xml file can be empty, aside from <web-app></web-app> tags.

c)Can I just add my webapplication here inside the same <host>
Yes.

2)
If you configured your 'myapplication' application to use the web.xml and server.xml snippets you posted, then calling it through /examples will not work!
http://localhost:8080/myapplication/HelloServlet

Please, please... forget you ever saw the invoker servlet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web.xml andf default webapplication folder