The Web Application - JSP

There is also a predefined folder structure for a Web application.That structure is shown in Figure

The Web Application

The main aspects of a Web application are as follows:

  • The Root folder—This folder is the top-level folder for the Web application. It contains the entire structure of the Web application. If deployed as is, in Tomcat, that would mean putting the folder in the <tomcat-home>webapps folder; the name of this folder is case-sensitive. It is worth pointing out that the entire contents of this folder can be placed into a JAR file, given the extension, .war, and then deployed in Tomcat by simply placing the .war file in the <tomcat-home>webapps folder.
  • The WEB-INF folder—This folder contains the configuration information for the application, and is the location for the folders containing any relevant JAR files and classes.The configuration information is located within the file web.xml.Tag Library Definition (TLD) files (discussed in Chapter ,“The JSP Standard Tag Library”) are also typically located in this folder.
  • web.xml—This file contains the configuration information for the Web application.This includes initialization parameters ;for example, security constraints, references to EJBs, and so forth.You’ll see many further examples of the elements that can be placed in this file as you proceed through the book.
  • WEB-INFclasses—This folder contains all the classes that are used within this application.
  • WEB-INFlib—This folder contains any JAR files required by the application.
  • JSPs, HTML files and any content folders—Any files and folders and files within the root directory apart from the WEB-INF directory are available to clients using HTTP requests.These files, which will make up the content of the Web application, can be arranged as desired by the Web developer into files and folders as you would for any Web site.There does not have to be any JSPs, HTML pages or content folders. If a Web application only contains servlets, for example, there may be nothing more than the WEB-INF folder with the servlet classes and a web.xml configuration file.

It is worth commenting about the location of your class and JAR files at this point.You can put classes into the classes folder and JARs into the lib folder, as referred to earlier, but there are reasons for not putting them in those locations for certain specific situations. The benefit of putting them in those locations is that the Web application becomes self-contained, in that all the required classes and libraries are within the application. The reality is, however, that on some occasions they need to be placed within the classpath for the Web container itself.

The reasons for using these global locations for JAR files include

  • Classes and libraries can be shared across multiple Web applications without the need for repeating them in each application.
  • If you are using Tomcat 4 or lower, classes starting with the package name javax are not read when placed within individual Web applications.This is an issue when using the Apache Axis Web services engine.
  • After an application has been built, a number of deployment methods exist

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JSP Topics