Apache Tomcat Representation and Management of Data on the Web.

Slides:



Advertisements
Similar presentations
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Advertisements

ANT – Another Neat Tool Representation and Management of Data on the Internet.
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.
1 Web Services – Part II CS , Spring 2008/9.
Configuring web servers and web applications 1. 2 Server configuration vs. application configuration A web server may run several web application Server.
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.
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Helpful tips for working with NJIT University Computing Systems for Homework and projects Rafael Orta, Prashanth Sanagavarapu and George Blank.
Tomcat Configuration A Very, Very, Very Brief Overview.
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 Servlets and JSP.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Softsmith Infotech Installing and Configuring Tomcat.
Configuring Apache tomcat Specifying the server port NOTE: Edit the install_dir/conf/server.xml and change the port attribute of the connector element.
WebServer & Tomcat By B. Venkateswarlu M.Tech Assoc Prof IT(Dept) Newton’s Institute of Engineering.
Tomcat Celsina Bignoli History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source.
Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.
Linux Operations and Administration
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Apache Tomcat Web Server SNU OOPSLA Lab. October 2005.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
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.
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.
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.
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Web Applications - Basics. Introduction to Web Web features Clent/Server HyperText Transfer Protocol HyperText Markup Language URL addresses Web server.
CS-4220 Dr. Mark L. Hornick1 Servlet configuration and deployment.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
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.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
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.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
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.
Java Web Server Presented by- Sapna Bansode-03 Nutan Mote-15 Poonam Mote-16.
1 G52IWS: Example Web-services Chris Greenhalgh. 2 Contents Software requirements AXIS web service run-time components Getting started with Jetty & AXIS.
NJIT 1 Apache Tomcat (Version 6.0) THETOPPERSWAY.COM.
JAVA, JEE Training Introduction to Web Harinath Mallepally
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Topics to be covered (ni) Client side validation JSF (free tools as well) Webservices Tell Resources e.g. sites Packaging and deploying web applications.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Deploying Web Applications to Tomcat Server Chun Guo
APACHE TOMCAT WEB SERVER
Tomcat Celsina Bignoli
Developing the Tools Montreal 2004
Representation and Management of Data on the Web
By Dr. Kodge Bheemashankar G
Installing and Configuring Tomcat
Apache Tomcat Web Server
Introduction to JBoss application server
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Representation and Management of Data on the Web
CS3220 Web and Internet Programming Introduction to Java Servlets
Installing Tomcat.
Presentation transcript:

Apache Tomcat Representation and Management of Data on the Web

What is Tomcat? Tomcat is a Servlet container (Web server that interacts with Servlets) developed under the Jakarta Project at the Apache Software Foundation Tomcat implements the Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems Tomcat is an open-source, non commercial project -Licensed under the Apache Software License Tomcat is written in Java (OS independent)

Tomcat Directory Structure

The directory TOMCAT-HOME contains executables and libraries required for the server launching, running and stopping -This directory is placed under /usr/local/… The directory TOMCAT-BASE contains the Web-site content, Web applications and configuration data -This directory is placed under your home directory

Installing Tomcat Create a directory for tomcat base -For example: mkdir ~/tomcat-base Set the environment variable CATALINA_BASE to your tomcat-base directory -For example: setenv CATALINA_BASE ~/tomcat-base -Insert this line into your.cshrc file Run ~dbi/tomcat/bin/setup $CATALINA_BASE is now a legitimate Tomcat base directory, and Tomcat is ready to run

Choosing a port for Tomcat In the file $CATALINA_HOME/conf/server.xml you will find the element Connector of the service Catalina Choose a port (greater than 1024) and change the value of the port attribute to your chosen one: … … …

Running Tomcat To start tomcat use ~dbi/tomcat/bin/catalina run Or, in background ~dbi/tomcat/bin/catalina start To stop tomcat use ~dbi/tomcat/bin/catalina stop To see the default page of Tomcat from your browser use the URL : / -machine-name is the name of the machine on which Tomcat runs and port is the port you chose for Tomcat You can also use / if your browser runs on the same machine as Tomcat

Creating Web Applications A Web application is a self-contained subtree of the Web site. It has a distinct context, sessions, and Servlet mappings A Web application usually contains several Web resources like HTML files, Servlets and JSP files, and other resources like Database tables Each Web application has its own subdirectory under the directory $CATALINA_BASE/webapps/

The Directory Structure of a Web Application Tomcat automatically identifies a directory $CATALINA_BASE/webapps/myApp/ with the relative URL /myApp/ For example, a file named index.html in myApp is mapped to by the following URLs: : /myApp/index.html : /myApp/

The Directory Structure of a Web Application You can also use subdirectories under myApp For example: the file myApp/myImages/im.gif is mapped to by the URL Tomcat maps the root directory ( ) to the directory webapps/ROOT/

The Directory Structure of a Web Application An application's directory must contain the following: -The directory myApp/WEB-INF/ -A legal web.xml file under myApp/WEB-INF/

Tomcat and Java Classes Tomcat uses Java classes you provide in order to run Servlets and JSP files -For example, the Servlets themselves! Tomcat 5.x initialization scripts ignore your environment CLASSPATH variable Classes are expected to be placed (or linked) at some predefined places in its directories

Java Class Locations Tomcat expects to find Java classes in class files (in a directory named classes ) and JAR files (in a directory named lib ) in the following places: TOMCAT-HOME/common/ - basic runtime classes. No need to touch this directory $CATALINA_BASE/shared/ -classes that are used by all the Web applications $CATALINA_BASE/webapps/myApp/WEB-INF/ -application specific classes (Servlets are typically here)

Java Class Locations

Classes Provided by DBI Course In order to provide the classes you need, like ORACLE, SAX and DOM related packages, the Tomcat-setup script links the directory $CATALINA_HOME/shared/lib/ to ~dbi/tomcat/shared/lib/, thus the latter packages are automatically known by your Tomcat server

We know how static resources (e.g HTML, images) are advertised using Tomcat In order to advertise a Servlet in Tomcat we have to do the following: -Put the class file in a proper place -Tell Tomcat that the class acts as a Servlet -Tell Tomcat the URL mapping of the Servlet 2 and 3 are discussed in the following slides Advertising a Servlet

Configuring a Web Application Application-specific configuration and declarations are written in the file myApp/WEB-INF/web.xml This file contains: -Servlet declarations, mappings and parameters -Session time-out specification -Context (application) parameters -Error pages (sent in cases of HTTP errors) -Security constraints, and more…

Servlet Declaration and Mapping The element declares a Servlet The sub element defines an initialization parameter to the Servlet -Access using ServletConfig.getInitParameter() The element maps a URL to a specific Servlet -The URL is relative to the application’s base URL

hi HelloWorld login snoopy hi /welcome Matches: web.xml Example

hi *.welcome hi /welcome/* Matches: More Mapping Examples Matches: How can the Servlet know the original URL?

A Tip Tomcat provides a Servlet that enables invoking an existing Servlet class without declaration and mapping To enable this feature, uncomment the elements servlet and servlet-mapping in the file of the Servlet called invoker in $CATALINA_BASE/conf/web.xml To call the compiled Servlet myServlet.class in the application myApp use this URL: : /myApp/servlet/myServlet NEVER publish a Web-site with this feature enabled! -Otherwise, your security restrictions are easily bypassed

More Configurations Set the session time-out value using under the element -This value is the maximal time of inactivity within a session, specified in minutes Set context parameters using -Access using ServletContext. getInitParameter() -Use this for parameters that are relevant for the whole application (the webmaster’s , for example)

20 webmaster web.xml Example

Yet More Configurations Use the element to define the page sent in case of an HTTP error that occurs within the application context When the URL of the application base directory is requested, what page should be sent? You can define this property using the element

Functional Pages Example Welcome Welcome, dear client! myWelcome.html 404 Error WHAT????? my404.html

Functional Pages Example myWelcome.html index.html index.jsp 404 /my404.html

web.xml DTD Your web.xml file must conform to the web-app DTD:

Reflecting Application Changes Usually, you have to restart Tomcat after changing your Web application Why? -web.xml is processed at Tomcat startup -Some of the Java classes may have already been loaded and initialized, so changes will not be reflected There are more elegant solutions

Web Application Development

Web Archives A WAR (Web ARchive) file is a JAR file that contains a whole Web-application directory For example, to create a WAR file of myApp do: > jar cvf myApp.war /* Tomcat unpacks all WAR files found in $CATALINE_BASE/webapps/ at statup -The unpacked directory and context will be named as the WAR file name (without the extension) -The WAR will not be unpacked if webapps/ already contains the unpacked directory and the WAR is not newer...

Tomcat 5.0 Manager Tomcat 5.0 comes with a Web application called “manager”, which supports functions for managing Web application with no need to restart tomcat You can either use the HTML interface at : /html/ or send direct HTTP requests to its Servlets You will need to authenticate as a privileged user Use the username “admin” with no password

Tomcat 5.0 Manager Using the manager, you can -Deploy a Web application from either a WAR file (POST command) or an existing directory in the server’s webapps/ (GET command) -Undeploy a deployed Web application -Start/stop a web application (make it available/unavailable) -Reload an existing Web application (unpack new WARs) Warning: while “stop” makes an application unavailable, “undeploy” deletes the application directory and WAR file (if exists) from webapps/

Application Development with ANT Apache provides an ANT package for Tomcat Web- application development For example: - ant compile - compiles your java classes and creates the application WAR file - ant deploy - (re)deploys your application ANT actually interacts with the manager application Detailed explanations in the course home-page

Tomcat and Eclipse An additional option is to use an Eclipse plugin for Tomcat Web-application development The “Sysdeo Eclipse Tomcat Launcher” plugin is installed in CS This plugin, like ANT, interacts with Tomcat manager Detailed explanations in the course home-page

Web Development Overview Several options for Web development were presented: Work directly in the application's base directory -Restart Tomcat to reflect changes, or use the manager home page to reload the application Work in a separate directory and use ANT to compile, deploy and reload the application Manage your Web-application directory using Eclipse -Does edit, compile and reload of the application

Our Recommendation To better understand and control Tomcat, we suggest that the first steps in your application development will be taken in the direct approach (work directly on Tomcat’s files) Once you understand how Tomcat works, either copy your application's directory to a new location and use ANT, or start a Tomcat project in Eclipse, with your application's directory as the project base Our recommendations are OS independent!