Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web.xml andf default webapplication folder

 
may Lee
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13046
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe we should have a headline on this forum: don't use /servlet/ - see the Invoker FAQ
Bill
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic