This week's book giveaways are in the Angular and TypeScript and Web Services forums.
We're giving away four copies each of Programming with Types and The Design of Web APIs and have the authors on-line!
See this thread and this one for details.
Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Tomcat Servlet path

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have installed Tomcat on a Win NT machine. Its working correctly. But I am little confused about the concept of "Contexts". One of the pre-defined contexts is :
"/examples" => "/webapps/examples/"
There is a file index.html in "/webapps/examples/servlets" which calls the example servlets as http://localhost:8080/example/servlet/helloworld
But there is no directory called "servlet" in the examples directory. Instead all class files are in "web-inf/classes"
How does Tomcat know that "web-inf/classes" => "servlet/" ??
Thanks in advance,
Anoop
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I�m not working with tomcat but usually this path web-inf/classes is mapped to servlet at some xml configuration file.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anoop:
This come with the (http://java.sun.com/products/servlet ?)
Servlet Specification.
Any app server confirming to the Specs from Sun will do this
mapping.
From Servlet Specs 2.2, Section 9.4


A special directory exists within the application hierarchy named �WEB-INF�. This directory
contains all things related to the application that aren�t in the document root of the application. It is
important to note that the WEB-INF node is not part of the public document tree of the application.
No file contained in the WEB-INF directory may be served directly to a client.
The contents of the WEB-INF directory are:
� /WEB-INF/web.xml deployment descriptor
� /WEB-INF/classes/* directory for servlet and utility classes. The classes in this directory
are used by the application class loader to load classes from.
� /WEB-INF/lib/*.jar area for Java ARchive files which contain servlets, beans, and other
utility classes useful to the web application. All such archive files are used by the web
application class loader to load classes from.


regds.
- satya
 
Nair Anoop
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your helpful response.
Anoop
 
Nair Anoop
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still unclear about one thing:
How does Web-Inf/classes map to "examples/servlet" ?
Is this specified in some XML descriptor file ?
Anoop
[This message has been edited by Nair Anoop (edited August 01, 2001).]
 
Saloon Keeper
Posts: 21437
143
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat is the same as most other web servers in that it allows you to build up a web site that contains "virtual directories". For example: "http://www.bogus.com/herbalviagra". In your webserver configuration (server.xml in tomcat's case), you map the virtual directory (web alias) to a real file directory using a context. So, for example, you can make requests against the "herbalviagra" directory come from "F:\GetRichQuick\scamoftheweek" by defining the context:
<context path="/herbalviagra" docBase="f:/GetRichQuick/scamoftheweek"/>
The most common context, is of course, the root one, so that would be context path "/". By default, that's mapped into the TOMCAT_ROOT/webapps directory.
Within the REAL directory (f:/GetRichQuick/scanoftheweek or TOMCAT_ROOT/webapps) you unpack your WAR to provide the WEB-INF/classes and other subdirectories as needed.
A complex setup may involve multiple contexts, some of which may be located in different virtual hosts. All of this is set up in server.xml.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!