Tomcat Configuration A Very, Very, Very Brief Overview.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
Tomcat Organization Deploying applications. Confusion Like a web server Root locations are from a defined directory location In addition… from that point.
Configuring web servers and web applications 1. 2 Server configuration vs. application configuration A web server may run several web application Server.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
1 Running Web Applications with Tomcat CS , Winter 2007/8.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Apache Tomcat Representation and Management of Data on the Web.
DT211/3 Internet Application Development Web Servers.
MC365 Application Servers: Java Server Pages (JSP’s) and Session Management.
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Web programming for project students Dr Jim Briggs.
Creating a.war file W(eb) AR(chive). Creating a.war file The following article may contain actual software programs in source code form. This source code.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Julien Thibault / Phil Brewster / Kristina Doing-Harris
CS 160: Software Engineering August 27 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Java web development Servlet & Java server pages.
Java Servlets and JSP.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Configuring Apache tomcat Specifying the server port NOTE: Edit the install_dir/conf/server.xml and change the port attribute of the connector element.
Tomcat Celsina Bignoli History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source.
Hyrax Installation and Customization Dan Holloway James Gallagher.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
Installing and Configuring Tomcat A quick guide to getting things set up on Windows.
Apache Tomcat Web Server SNU OOPSLA Lab. October 2005.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Servlets Environment Setup. Agenda:  Setting up Java Development Kit  Setting up Web Server: Tomcat  Setting up CLASSPATH.
Apache Tomcat Representation and Management of Data on the Web.
Java Servlets CS-422. Application Mapping Your servlet application will be mapped to a directory structure: –“myapp” maps to some directory C:/docs/apps/myapp.
Apache + Tomcat. Apache + Tomcat Download mod_webapp.so:
Application Servers: Tomcat. What is an application server? Servlets are Java’s answer to server-side programming. Servlets are a special type of Java.
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Running Jakarta/Tomcat CIT304/CSE301 University of Sunderland Harry R. Erwin, PhD.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
Chapter 6 Server-side Programming: Java Servlets
Chapter 2 An Overview of Servlet and JSP Technology.
C HAPTER 11 D EPLOYING YOUR WEB APP. WAR FILE A WAR file is simply a snapshot of your web app structure, in a nice portable, compressed form (it is really.
Topic Java EE installation (Eclipse, glassfish, etc.) Eclipse configuration for EE Creating a Java Web Dynamic Project Creating your first servlet.
Introductions  Two decades in software development  Software Engineering Solutions, Inc.  Technical Reviewer: Core.
Struts 2 introduction. Struts 2 framework Struts 2 A full-featured web application framework for the Java EE platform The Java Servlet API exposes the.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Installing and Configuring Tomcat SSE. Downloading Tomcat l Download url: 4.0/release/v4.1.24/bin/
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Apache Web Server Architecture Chaitanya Kulkarni MSCS rd April /23/20081Apache Web Server Architecture.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
NJIT 1 Apache Tomcat (Version 6.0) THETOPPERSWAY.COM.
 2003 Prentice Hall, Inc. All rights reserved Deploying a Web Application ( may include.war )
JAVA, JEE Training Introduction to Web Harinath Mallepally
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Setting Up First, install tomcat and axis as described elsewhere. Then copy Tomcat into a second folder. –I’ve named mine jakarta- tomcat-server and jakarta-
Deploying Web Applications to Tomcat Server Chun Guo
Hyrax Configuration.
Tomcat Celsina Bignoli
By Dr. Kodge Bheemashankar G
Apache Tomcat Web Server
Introduction to JBoss application server
Java Servlets and JSP.
Presentation transcript:

Tomcat Configuration A Very, Very, Very Brief Overview

Topics F Tomcat –Creating a new server. –Adding servlets to the web.xml file. –Initiating requests both with and without the translations inside the web.xml file. –Added initialization parameters to the web.xml file. –Starting and stopping Tomcat.

Servlet Engines F In order to execute a servlet, you must be running a servlet engine. –This is software that accepts and processes requests for servlets. –A servlet engine is usually a key component in an application server. F The application server, and hence the servlet engine, generally exists independently of the web server. –Application servers are tied to web servers via connectors.

Web Connectors F When a web server receives a request for static content such as an HTML document, it can handle the request itself. F When a request for dynamic content, such as a servlet, is received, the web server must hand that request off to the application server for processing. F The software that coordinates this effort is called a web connector.

Jakarta - Tomcat F Tomcat is the servlet and JavaServer Pages engine from the Apache group. – F It’s small, installs quickly, and free. F For the purposes of this class, Tomcat is acting as both a web and application server.

Tomcat Root F The directory where you installed Tomcat is called the Tomcat Root. For instance: –c:\program files\apache group\tomcat-3.1 F We’ll use the Tomcat Root as our point-of- reference for all Tomcat configuration stuff. F One installation of Tomcat can host multiple web applications. This is discussed on the next slide.

Document Root  Change to the webapps directory under the Tomcat Root. For example: –c:\program files\apache group\tomcat-3.1\webapps F Create a new subdirectory called the document root. For example: –SE491 F A separate document root is created for each application we wish to host.

Directory Structure F Within your document root, create the following directory structure: –WEB-INF –WEB-INF/classes/ –WEB-INF/lib/  WEB-INF is where Tomcat looks for elements relating to your application.  /classes is used for all of your servlets.  /lib is used for third-party APIs and classes.

Server Configuration F Once you have chosen a document root, it’s a good idea to make Tomcat aware of it. –In theory Tomcat can locate your new document root implicitly, but you’re always better off controlling the configuration explicitly.  If any part of your Tomcat configuration is incorrect, Tomcat will fail to start and will record the problem in the /logs subdirectory. For instance: –c:\program files\apache group\ tomcat-3.1 \logs

Server Configuration F Find and edit the following file: /conf/server.xml F Add a new entry at the bottom of the file:

Server Configuration (cont.) F The context path should be the document root directory you just created. This is the place that Tomcat will use to derive all other locations. F The docBase is where Tomcat looks for non- dynamic elements such as HTML. F The debug suggests that you aren’t debugging the servlet request. Change this value to “1” to get more information in the Tomcat logs.

Server Configuration (cont.) F The reloadable entry suggests that if Tomcat notices that a class file has changed, it should reload that class the next time it is requested. –This feature of application servers allows us to have 7 x 24 availability; we don’t need to shut down the server to deploy enhancements and fixes to the application.

Server Configuration (cont.)  You should add a new entry to server.xml for each document root you create. –We typically create a single document root for each application being hosted by the application server. –In a development environment we might host multiple application environments. For instance we might have document roots for development, string testing, system testing, acceptance testing, and performance testing. –We can use a similar approach if we’re doing both enhancements and regular maintenance concurrently.

Servlet Installation F Before we can execute the servlet, we need to install it on the application server. F Each application server has its own method for performing this installation. –The following instructions apply to Tomcat only.

Class File Location F Compile the servlet like any other Java program.  Copy the servlet’s.class file to the WEB- INF/classes subdirectory.  If you are using packages, make certain that you use the same directory structure under WEB- INF/classes that you did when developing your source code. –This ensures that the class loader is able to find all of the required resources.

web.xml F As with the Tomcat server configuration, when we add a new servlet to our application we should make Tomcat aware of it. –This is accomplished through the web.xml file.  Every application has its own web.xml file. F This file contains important configuration information that Tomcat uses to translate a browser request into a servlet execution.

web.xml (cont.) <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" " howdy HelloWorldExample howdy /howdy

web.xml (cont.) F The first part of this file provides a translation from the “pretty” name that users see in the browser to the servlet’s class name: howdy HelloWorldExample

web.xml (cont.) F The second part of this file provides a translation from groups of names to the servlet name identified in the first part of the file: howdy /greetings

Bouncing the Server F Whenever you make configuration changes to Tomcat you should “bounce” the server. –“Bouncing” is a euphemism for shutting the server down and then immediately restarting it. F To bounce Tomcat, follow these steps: –Change to the /bin directory –At the command line enter tomcat stop to stop the Tomcat server. –At the command line enter tomcat start to start the Tomcat server.

Running a Servlet F To execute a servlet you need to issue a request to Tomcat using your browser. F By default Tomcat listens for requests on port This can be configured, but for this class this value is fine.

Running a Servlet (cont.)  To execute the HelloWorldExample servlet, use the following URI: –  Because we have a servlet mapping from /greetings to howdy, and howdy has been associated with the HelloWorldExample servlet in our web.xml file, Tomcat can translate this request into a servlet call.

Running a Servlet (cont.) F All of these URIs invoke the same servlet: – – –  This works because of the translations we defined in the web.xml file.

Servlet Lifecycle Reprise F You issue a request to the application server (Tomcat) using the client of your choice. F Tomcat looks at your request and attempts to locate the servlet within the URI.  Tomcat then looks at the servlet mappings that were defined in the web.xml file to determine the class name of the servlet that was requested.

Initialization Parameters F Sometimes we want to initialize a servlet when it’s first loaded by the servlet engine. –For instance, we may wish to load some configuration settings before allowing the servlet to process requests. F This can be useful for testing when you don’t want to configure a web page to initiate the test.

Tomcat Initialization Parameters  Tomcat allows you to place the initialization parameters within the web.xml file. F It requires a slight modification from the original format: message MessageServlet msg this is a message....

Changing Initialization Parameters F If you change the initialization parameters for a servlet, you should bounce the servlet engine to ensure that those changes are accepted.  Recycling the server forces it to reload the server.xml and web.xml files.