|
A web-application is a collection of resources such as jsps, servlets,
html files, images, etc. which are mapped to a specific "URI" prefix.
For example, all the resources related to baseball can be assembled into
a "baseball" directory and correspondingly all the requests that start
with "/baseball" can be mapped to this application.
A new application can be added to Tomcat by editing server.xml file.
To add "baseball" application you can make the following additions to
the file (at the appropriate place):
<Context
path="/baseball"
docBase="baseball"
defaultSessionTimeOut="30"
isWARExpanded="true"
isWARValidated="false"
isInvokerEnabled="true"
isWorkDirPersistent="false
/>;
Please read "server.xml" for more details.
a) To install servlets within a web-application, you can do the following:
- Once a servlet has been compiled, it can be added to Tomcat by:
determine which "web application" context you'd like to add the servlet
to add the servlet class file to the WEBAPP/WEB-INF/classes directory
- In order to define a name and init params for the newly installed
servlet you need to also:
- register the servlet with a element in the WEBAPP/WEB-INF/web.xml
file
- you can optionally map your servlet to uri requests relative
to the context within it is located by adding a
element in the WEBAPP/WEB-INF/web.xml file
- And finally restart the server
You can access your new servlet via a URI similiar to the following:
If you've associated a URI path mapping to your servlet you can access
it via a URI similiar to the following:
b) To install jsps and beans within a web-application you can do the
following:
- Put the jsp sources in any directory under /WEBAPP.
- Make sure that the compiled beans are in the CLASSPATH. This can
be done either by setting the CLASSPATH manually or by editing the
startup script.
- And finally restart the server.
You can invoke your new jsp via a URI similar to the following:
http://localhost:8080/WEBAPP/yourfile.jsp
|