Configuring Tomcat for a Web Application



Similar documents
Controlling Web Application Behavior

Web Application Architecture (based J2EE 1.4 Tutorial)

Hello World RESTful web service tutorial

SSC - Web applications and development Introduction and Java Servlet (II)

In this chapter, we lay the foundation for all our further discussions. We start

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

5- Web application deployment

Application Security

Volume 1: Core Technologies Marty Hall Larry Brown. An Overview of Servlet & JSP Technology

PowerTier Web Development Tools 4

Supplemental Material - Deployment.pdf

CONTROLLING WEB APPLICATION BEHAVIOR WITH

Struts 2 - Practical examples

Connecting Custom Services to the YAWL Engine. Beta 7 Release

On-campus Tomcat Deployment Client

CREATE A CUSTOM THEME WEBSPHERE PORTAL

Web Applications. Originals of Slides and Source Code for Examples:

Adding Content to the Tomcat Server

Web Service Development Using CXF. - Praveen Kumar Jayaram

The Compatible One Application and Platform Service 1 (COAPS) API User Guide

JWIG Yet Another Framework for Maintainable and Secure Web Applications

An Overview of Servlet & JSP Technology

BAPI. Business Application Programming Interface. Compiled by Y R Nagesh 1

BIRT Application and BIRT Report Deployment Functional Specification

Installing and Deploying the Hot Fix that Enables Webdoc to Display PDF Files with Adobe Acrobat Reader

SSO Plugin. Integration for BMC MyIT and SmartIT. J System Solutions. Version 4.0

Novell Identity Manager

Internet Technologies

Controller annotati. con Spring MVC 2.5

In this chapter the concept of Servlets, not the entire Servlet specification, is

Server Setup and Configuration

LDAPLogin Module Configuration. LDAPLogin Module Configuration for Tomcat 5.x on Linux & Windows

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

Working with Oracle Database XE. Create New User Account Using SQL Run Script Files PL/SQL Objects PL/SQL Server Pages

Web Application Development Using Borland JBuilder 8 WebLogic Edition

Template Development Guide Jahia EE v6.1

2. Follow the installation directions and install the server on ccc

CS412 Interactive Lab Creating a Simple Web Form

Java Servlet 3.0. Rajiv Mordani Spec Lead

Sample HP OO Web Application

Oracle WebLogic Server

Recommended readings. Lecture 11 - Securing Web. Applications. Security. Declarative Security

Getting Started Guide. Version 1.8

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

JBoss Portlet Container. User Guide. Release 2.0

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

Simplify Your Web App Development Using the Spring MVC Framework

HP OpenView Service Desk Version 3.0

Configuring IBM WebSphere Application Server 7.0 for Web Authentication with SAS 9.3 Web Applications

LICENSE4J AUTO LICENSE GENERATION AND ACTIVATION SERVER USER GUIDE

Ch-03 Web Applications

JSR 289: SIP Servlet 1.1 Provides Significant Benefits for SIP Application Developers

Further web design: HTML forms

Securing a Web Service

<Insert Picture Here>

Spectrum Technology Platform

Contents. 2 Alfresco API Version 1.0

JMETER - WEBSERVICE TEST PLAN

2- Forms and JavaScript Course: Developing web- based applica<ons

XHTML BASICS. Institute of Finance Management CIT Department Herman Mandari

SSO Plugin. Integration for Jasper Server. J System Solutions. Version 3.6

Integration of Shibboleth and (Web) Applications

The Server.xml File. Containers APPENDIX A. The Server Container

SAP's Integrated Development Environment for Java. Karl Kessler, SAP AG

Java Web Services Developer Pack. Copyright 2003 David A. Wilson. All rights reserved.

Web Applications. For live Java training, please see training courses at

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

Baidu: Webmaster Tools Overview and Guidelines

WIRIS quizzes web services Getting started with PHP and Java

Creating Java EE Applications and Servlets with IntelliJ IDEA

Apache Configuration

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Arjun V. Bala Page 20

HTML Basics(w3schools.com, 2013)

Tutorial: Using PHP, SOAP and WSDL Technology to access a public web service.

HTML, CSS, XML, and XSL

ICT 6012: Web Programming

BizFlow 9.0 BizCoves BluePrint

Java Web Programming. Student Workbook

HTML Forms and CONTROLS

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

Crawl Proxy Installation and Configuration Guide

Developing XML Solutions with JavaServer Pages Technology

Exam Prep. Sun Certified Web Component Developer (SCWCD) for J2EE Platform

Advanced OpenEdge REST/Mobile Security

SSO Plugin. HP Service Request Catalog. J System Solutions. Version 3.6

Oracle Fusion Middleware

Working with forms in PHP

Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server c (12.1.3)

Command-Line Tool for View Manager View Manager 4.0

Building Web Applications, Servlets, JSP and JDBC

Web Design with Dreamweaver Lesson 4 Handout

Transcription:

Configuring Tomcat for a Web Application In order to configure Tomcat for a web application, files must be put into the proper places and the web.xml file should be edited to tell Tomcat where the servlet files are. You can create a new subfolder under the webapps folder. This folder can be the root of your application. Under this folder you will need a WEB-INF folder to contain the web.xml file and under that a classes file to hold the servlet class files. As an example, consider a web application that concerns a delicatessen. The folder can be called deli, and the files can be stored in it. See the directory picture from Windows Explorer below. From this you can see that the classes folder contains subfolders, manage, orders, produce, and view that are the names of the package files for the servlets. Anything in the deli folder is available to clients on the web, but any files in the WEB-INF folder and below are not. This provides a level of security for your development files. Also note that in the grocery folder there are several html files, including one called index.html. It is the main web file for the application. If the web.xml file contains a welcome-file-list, it can be accessed using the URL http://localhost/deli or http://localhost:8080/deli.

Other html and xml files can also be stored in this folder. Web.xml file The web.xml file is the web application deployment descriptor. It contains the information needed for the server to load and initialize the web application. It lists the servlets that are in the application and also contains patterns for finding them. The first thing in the file is the information about the XML Schema used to define the web.xml document. Because this is part of Tomcat, the xml elements are determined and must be written exactly as given. The elements in the file that we will use (in the order they should be included) are: display-name, description, context-param, servlet, servlet-mapping, welcome-file-list, and error-page. They must be contained between the tags, <web-app></web-app> and are each listed below with examples. We will add several more when we add security to the application. display-name gives a name for the application that can be used by management tools. <display-name>deli Application</display-name> description is used to store a description of the application. <description> A delicatessen application that can access a database of fruits and vegetables. Clients will be able to display, find, delete, and add products, and also to change prices. </description> context-param is used to provide initialization parameters for the application. <context-param> <param-name>author</param-name> <param-value>carol Wolf</param-value> <description>pace University</description> </context-param> servlet contains information about the logical names and class names of all the servlets in the application. One example is shown here. <servlet-class>produce.displayservlet</servlet-class> <load-on-startup>10</load-on-startup> The servlet-name is the name of the java file and the servlet-class is the full name of the class file. Note that it includes the package name. The load-on-startup tag tells the server to load this file when the application is started and give it priority 10. If that is the lowest priority level, it will be loaded first. Servlets are loaded in the order of the load-on-startup number. The first two tags are required, but the third is optional. servlet-mapping is used to create a pattern that can be used to reference the servlet. It provides a shorthand way to name the servlet. <url-pattern>/display/*</url-pattern>

In the example above, whenever a request begins with display, this servlet will be started. So if in an html file we have <form method = "get" action="../deli/display">, the server will know to start the DisplayServlet program, and the servlet section above says it is in produce.displayservlet. welcome-file-list is used to list the files that are to be used when the directory is called for. <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> In this example, when the URL requested is http://localhost/deli, the index.html file in the deli folder will be sent to the client. error-page provides a page to be used when the server encounters an error, either a file missing or an exception. <error-page> <error-code>404</error-code> <location>/notfound.html</location> </error-page> This example says that when code 404, file not found, is returned, send the notfound.html page to the client. There are other elements that can be part of web.xml. Some of these are used for filtering data that is sent back and forth to the client and for security. There will be more on security later. index.html The index file is the one that is sent to the client when the URL contains the name of the directory. You can use any name for it, but index.html is a common one. It should be listed in the welcome-file-list element. A simple example follows: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>grocery Store </title> </head> <body bgcolor = "cyan"> <h3>display the Data</h3> <form method = "get" action="../deli/display"> <p><input type="submit" value="send"></p> </form> </body> </html> A complete example of a web application deployment descriptor follows. It is for the deli example described above. <?xml version="1.0" encoding="iso-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=

"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>deli Application</display-name> <description> A delicatessen application that can access a database of grocery items. Clients will be able to display and find products. </description> <context-param> <param-name>author</param-name> <param-value>carol Wolf</param-value> <description>pace University</description> </context-param> <!-- The list of servlets used in the application. --> <servlet-class>produce.displayservlet</servlet-class> <load-on-startup>10</load-on-startup> <servlet-name>findservlet</servlet-name> <servlet-class>produce.findservlet</servlet-class> <!-- The mappings used for the servlets. --> <url-pattern>/display/*</url-pattern> <servlet-name>findservlet</servlet-name> <url-pattern>/find/*</url-pattern> <!-- The home page for the application. --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <!-- The page to be used when a file not found error occurs. --> <error-page> <error-code>404</error-code> <location>/notfound.html</location> </error-page> </web-app> Reference 1. Karl Moss, Java Servlets Developer s Guide, McGraw-Hill/Osborne, 2002.