• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

web.xml andf default webapplication folder

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe we should have a headline on this forum: don't use /servlet/ - see the Invoker FAQ
Bill
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic