jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

Question What is a web application (or "webapp")?
Topics Java:API:Servlets, Java:API:Servlets:Architecture and Design, Java:API:Servlets:Specification, Tools:AppServer:WebServer:Tomcat
Author Alex Chaffee PREMIUM
Created Aug 17, 2000 Modified Aug 18, 2000


Answer

A Web Application (or "webapp") is a concept that was introduced in the Servlet Specification version 2.2. [2.1?] You should definitely read the spec for the full story. From the spec (chapter 9):

A web application is a collection of servlets, html pages, classes, and other resources that can be bundled and run on multiple containers from multiple vendors. A web application is rooted at a specific path within a web server. For example, a catalog application could be located at http:// www.mycorp.com/catalog. All requests that start with this prefix will be routed to the ServletContext which represents the catalog application.

A servlet container can also establish rules for automatic generation of web applications. For example a ~user/ mapping could be used to map to a web application based at /home/user/ public_html/.

[...]

A web application exists as a structured hierarchy of directories. The root of this hierarchy serves as a document root for serving files that are part of this context. For example, for a web application located at /catalog in a web server, the index.html file located at the base of the web application hierarchy can be served to satisfy a request to /catalog/index.html.

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.

<h3>Sample Web Application Directory Structure</h3>

Illustrated here is a listing of all the files in a sample web application:

/index.html
/howto.jsp
/feedback.jsp
/images/banner.gif
/images/jumping.gif
/WEB-INF/web.xml
/WEB-INF/lib/jspbean.jar
/WEB-INF/classes/com/mycorp/servlets/MyServlet.class
/WEB-INF/classes/com/mycorp/util/MyUtils.class



Is this item helpful?  yes  no     Previous votes   Yes: 4  No: 0



Comments and alternative answers

Comment on this FAQ entry

JAVABEAN
SANJAY DESHPANDE, Apr 4, 2002  [replies:1]
In this dir structure where to store JavaBeans? i ve them in \WEB-INF\Classes but it s not working for me

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Re: JAVABEAN
Alessandro A. Garbagnati PREMIUM, Apr 4, 2002
Hi,
Java is a case sensitive language. "Classes" is different from "classes".

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Accessing images and HTML files within a web app
Thomas Sasala, Dec 5, 2002  [replies:1]
Our general policy is to access all images and HTML files using absolute paths. Thus, when the JSP or HTML file is moved to a different directory, the linked resource will still work (assuming it has not been moved). How does one accomplish this with a web app? The web application can be deployed to any context by the site administrator, so there is no way to know before hand what the absolute path would be during the coding phase. Does that mean images (and HTML files) have to be accessed using relative paths? I suppose you could map a servlet to /image and use the servlet to return the correct image, but that's not very efficient. -Tom

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Re: Accessing images and HTML files within a web app
Rama Sarma, Jan 20, 2005
Can you help me out with the following problem. It is, if I have to map images in a JSP or HTML from a remote location dynamically, how should i proceed further. I think i should go with a servlet in between. Can you explain the procedure of the same. Hope, you got my question.
Thanks n Regards,
Ram

Is this item helpful?  yes  no     Previous votes   Yes: 1  No: 0



Reply to this answer/comment  Help  


Ask A Question



 
Related Links

Servlets FAQ

Servlets Forum

Servlet-related resource list from Purple Technology

jGuru JSP FAQ

Sun Servlet Home Page

Tomcat FAQ

Tomcat Forum

Jakarta Project

Tomcat Documentation

jGuru JSP FAQ

jGuru Servlet FAQ

java.isavvix.com

Wish List
Features
About jGuru
Contact Us

 


Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers