1 Running Web Applications with Tomcat CS 236607, Winter 2007/8.

Slides:



Advertisements
Similar presentations
DT228/3 Web Development Introduction to Java Server Pages (JSP)
Advertisements

DT211/3 Internet Application Development Active Server Pages & IIS Web server.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
Configuring web servers and web applications 1. 2 Server configuration vs. application configuration A web server may run several web application Server.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Introduction to Web Interface Technology (CSE2030)
Apache Tomcat Representation and Management of Data on the Web.
DT211/3 Internet Application Development Web Servers.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
CP476 Internet Computing Browser and Web Server 1 Web Browsers A client software program that allows you to access and view Web pages on the Internet –Examples.
Tomcat Configuration A Very, Very, Very Brief Overview.
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
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
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets and JSP.
Softsmith Infotech Installing and Configuring Tomcat.
Tomcat Celsina Bignoli History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source.
Creating a Hello App Using Google App Engine. What are Google apps? Apps is an abbreviation for application. An app is a piece of software. It can run.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Linux Operations and Administration
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
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,
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.
Web Servers.
Apache Tomcat Representation and Management of Data on the Web.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
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.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Web Applications - Basics. Introduction to Web Web features Clent/Server HyperText Transfer Protocol HyperText Markup Language URL addresses Web server.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
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.
BZUPAGES.COM WEB SERVER PRESENTED TO: SIR AHMAD KAREEM.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
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.
Web Server Administration Chapter 6 Configuring a Web Server.
Deploying Web Applications to Tomcat Server Chun Guo
APACHE TOMCAT WEB SERVER
Checking the Server.
Web Development Web Servers.
Tomcat Celsina Bignoli
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Java Servlets.
Representation and Management of Data on the Web
Knowledge Byte In this section, you will learn about:
Checking the Server.
PHP / MySQL Introduction
Installing and Configuring Tomcat
Apache Tomcat Web Server
Chapter 27 WWW and HTTP.
Representation and Management of Data on the Web
Java Servlets and JSP.
Installing Tomcat.
Web Application Development Using PHP
Presentation transcript:

1 Running Web Applications with Tomcat CS , Winter 2007/8

2 Web Servers The term web server can mean one of two things: A computer program that is responsible for accepting HTTP requests from clients (browsers), and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects (images, etc.). A computer that runs a computer program as described above. Web Servers rack

3 Common Features Although web server programs differ in detail, they all share some basic common features. HTTP: every web server program operates by accepting HTTP requests from the client, and providing an HTTP response to the client. Logging: usually web servers have also the capability of logging some detailed information, about client requests and server responses, to log files; this allows the webmaster to collect statistics by running log analyzers on log files. This NeXT workstation (a NeXTcube) was used by Tim Berners-Lee as the first Web server on the World Wide Web(1990). Today, it is kept in Microcosm, the public museum at the Meyrin site of CERN, in the Canton of Geneva, Switzerland. The document resting on the keyboard is a copy of "Information Management: A Proposal," which was Berners-Lee's original proposal for the World Wide Web.

4 In practice many web servers implement the following features also: Authentication, Handling of not only static content but of dynamic content too by supporting one or more related interfaces (SSI, CGI, SCGI, FastCGI, JSP, PHP, ASP, ASP.NET, Server API such as NSAPI, ISAPI, etc.). HTTPS support (by SSL or TLS) to allow secure (encrypted) connections to the server on the standard port 443 instead of usual port 80. Content compression (i.e. by gzip encoding) to reduce the size of the responses (to lower bandwidth usage, etc.). Virtual hosting to serve many web sites using one IP address. Large file support to be able to serve files whose size is greater than 2 GB on 32 bit OS. And more… More features…

5 Web Applications Structure A Web app is structured as a directory: myapp/ – contains HTML/CSS/GIF/... files myapp/WEB-INF/ – contains the deployment descriptor web.xml myapp/WEB-INF/classes/ – contains servlet class files (in subdirs corresponding to package names) myapp/WEB-INF/lib/ – contains extra jar files

6 Deployment Descriptors An XML file web.xml describing mapping from URIs to application resources initialization parameters security constraints registration of listeners and filters

7 Apache Tomcat Tomcat is a Servlet container (Web server that interacts with Servlets) developed under the Jakarta Project of Apache Software Foundation Tomcat implements the Servlet and the Java Server Pages (JSP) specifications of Sun Microsystems Tomcat is an open-source, non commercial project  Licensed under the Apache Software License Tomcat is written in Java (OS independent) Comparison of web server software

8 Tomcat Directory Structure (5.5) Tomcat-Base webappswork JAR files ROOTmyApp1myApp2 server.xml Tomcat-users.xm l WEB-INF libclasses web.xml bincommonlogsconf lib JAR Files

9 The Tomcat Server lib/servlet-api.jar  The main jar file needed for compiling servlets. bin/startup.sh, bin/shutdown.sh  Scripts for starting & stopping the server conf/  server.xml - Server configuration file: HTTP Port (Default 8080), SSL support …  Tomcat-users.xml – users definitions webapps/myapp  The root for myapp application directory

10 Catalina Catalina is the name of the servlet container of Apache Tomcat since version 4.x.  A Servlet container is a specialized web server that supports Servlet execution. It combines the basic functionality of a web server with certain Java/Servlet specific optimizations and extensions – such as an integrated Java runtime environment. Servlet containers are also referred to as web containers or web engines.

11 Creating Web Applications A Web application usually contains several different types of Web resources like HTML files, Servlets, JSP files, and other resources like Database tables Each Web application has its own subdirectory under the directory $CATALINA_BASE/webapps/  $CATALINA_BASE is an environment variable set to your tomcat-base directory (The directory that contains the Web-site content, Web applications and configuration data

12 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: You can also use subdirectories under myApp. For example: the file myApp/myImages/im.gif is mapped to by the URL

13 The Directory Structure of a Web Application – Cont. An application's directory should contain the following:  The directory WEB-INF/  A legal web.xml file under WEB-INF/ Minimal content of web.xml

14 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  Default files for directory requests (e.g index.html)  Error pages (sent in cases of HTTP errors)  Security constraints  Session time-out specification  Context (application) parameters  And more…

15 Servlet Declaration and Mapping The element declares a Servlet The sub element defines a parameter passed to the Servlet  Access using: ServletConfig.getInitParameter( String paramName) The element maps a URL to a specific Servlet  The URL is relative to the application’s base URL ( )

16 Publishing a Servlet -An Example hello HelloWorld hello /hi web.xml The 2 blocks do not have to be adjacent within web.xml myApp/WEB-INF/classes/HelloWorld.class

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

18 Error Pages Use the error-page element to define the page sent in case of an HTTP error that occurs within the application context An error page element has two sub elements:  error-code - the HTTP error status code  location - the page that should be sent

19 Error Page Example Not Found Sorry, no such file /my404.html web.xml my404.html

20 A non-existing resource

21 And now for a live show… Tomcat & Eclipse

22 Web Application Development

23 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: cd webapps/myApp jar cvf myApp.war * (don’t forget the filename! What would happen otherwise?) 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.war extension)  The WAR will not be unpacked if webapps/ already contains the directory and the WAR is not newer...

24 Reflecting Application Changes Changes in your Java classes may not be reflected in your application  Old versions may already have been loaded  The application needs to be reloaded Changes in other files like HTML or JSP are always reflected Modification of web.xml automatically causes the application to be reloaded

25 Tomcat 5.5 Manager Tomcat 5.5 comes with a Web application called “manager”, which supports functions for managing Web applications Using the manager, you can  Deploy a Web application by posting a WAR file  Undeploy a deployed Web application  Start/stop a Web application (make it available/unavailable)  Reload an existing Web application (unpack new WAR s) Warning: while “stop” makes an application unavailable, “undeploy” deletes the application directory and WAR file from webapps/

26 Tomcat and Eclipse As you saw in the example Tomcat is easily integrated into Eclipse. All you need to do is download Apache Tomcat (you may download from the course site) and create a new server in Eclipse. Follow the Eclipse instructions…

27 Resources The Apache Software Foundation An Introduction to XML and Web Technologies / Anders Møller and Michael I. Schwartzbach – course literature Wikipedia Sun Microsystems site