SlideShare a Scribd company logo
Web Application Deployment COMP 118 Spring 2003
Help from Java Session tracking is provided by Java servlet API. HttpSession object Returned by getSession method of request. Can store info in session object as named attributes. setAttribute, getAttribute Other methods to configure session timeout, get information about session, etc. Uses cookies.
Example 3 Same as example 2, but uses built in Java session support.
Example 3 discussion What happens is cookies are disabled? Can use URL rewriting, but need to let servlet encode URL’s with session id. Use encodeURL method of request object  Does rewrites URL with session id embedded as additional parameter is cookies are turned off. Returns URL unchanged if cookies turned on.
Java Servlet API Documentation on Java Servlet API A good book. Java Servlet Programming by Jason Hunter, published by O’Reilly Unfortunately, pretty expensive.
Web Application Deployment Typically a web application is comprised of: HTML pages Data Images Servlets Source code Libraries Other resources A servlet is a component of a web application.
Separating server from web app. Person running the web server and person writing a web application running on that web server may not be the same. Example: a web hosting company runs a web server which “hosts” the sites of several other companies for a fee. What could be problematic about this? Need to isolate customers. Web app developer shouldn’t need to know anything about web server’s installation.
Standardizing deployment Server products (like Tomcat) have support for setting up resources and isolating one web application from another. Old days: different servers each did things their own way. Now: there is a standard (Servlet 2.4) that defines exactly how a web application is organized and how a server maps requests to it. Note: our version of Tomcat implements 2.3
Mapping to a web app. The server is responsible for mapping URL’s that start with a specific prefix to the location of a web application. This is the “root” of the web application. In Tomcat, this is done with a configuration file. We have defined a single web application that maps to each of your class directories.
Web app structure There is a specific organization of the files within a web application that you need to adhere to. /WEB-INF Private resources of a web application that can not be directly served to a client. /WEB-INF/web.xml Deployment descriptor that configures the web application.
Web app structure /WEB-INF/classes Class files for servlets Directory structure needs to reflect package names. /WEB-INF/lib Libraries (jar) files that may be needed by servlets
Common code Many web applications may need access to common libraries and classes. Servlet API XML processing libraries Email processing libraries These are put in the server’s root /common/classes /common/lib
COMP 118 Setup Server: wwwj.cs.unc.edu:8080 To compile correctly, be sure to: setenv JAVA_HOME /usr/java1.2 setenv CLASSPATH /opt/jakarta-4.1.18/common/lib/servlet.jar:.
web.xml This file contains important configuration information needed to make servlets work. For a servlet to function properly, you need to add a “servlet definition” and a “servlet mapping” for each servlet. /servlet/class_name used to be a shortcut Supposed to work, but doesn’t seem to in the new version. The order of things in web.xml is important. We will put in a template which you can modify.
Defining Servlets <servlet> <servlet-name>Name</servlet-name> <servlet-class>servlet.class</servlet-class> </servlet>
Servlet Mapping This determines what URL’s get mapped to the servlet. <servlet-mapping> <servlet-name>Name</servlet-name> <url-pattern>/path</url-pattern> </servlet-mapping>
Revisiting previous examples.
Administrivia Examples from class will be put up on the web site. First programming assignment will be put up on the web site by the weekend. Make a home page (index.html) and put it at the top of your class directory. Put a picture and your name on it. Write and deploy a “hello world” servlet to test your environment.
Initialization Parameters Can use web.xml to provide initialization parameters to a web application. Within servlet definition: <init-param> <param-name>name</param-name> <param-value>value</param-value> </init-param> Example reading book info from file.
Debugging Our server is set up to log error messages to a file in WEB-INF/logs
Multithread Issues There is one instance of each servlet deployed which handles every request to that servlet. But, each request is handled in its own thread. When will this cause problems? Problematic if the servlet updates non-local variables (i.e., persistent state). What is the solution? Use Java’s synchronization mechanisms Example using forms to add new books.
Redirection and Errors Servlet can redirect request sendRedirect()  Servlet can generate an error page. sendError() Status codes in documentation for HttpServletResponse
Generating Your Own Error Pages Server puts together error page to report errors to users. You can configure your web application in order to generate your own error pages. <error-page> <error-code> 400 </error-code> <location> /400.html </location> </error-page>

More Related Content

PPTX
High-Level Display: Screen J2ME User Interface
PPTX
Cloud security Presentation
PPT
android content providers
PPTX
Lecture 7: Server side programming
PDF
Android Components
PPTX
Ii 1500-publishing your android application
PPTX
High-Level Display: Screen J2ME User Interface
Cloud security Presentation
android content providers
Lecture 7: Server side programming
Android Components
Ii 1500-publishing your android application

What's hot (20)

PDF
Android Location and Maps
PPTX
Android Architecture.pptx
PDF
Capacity Planning for Cloud Computing
PPTX
Cloud computing and Cloud Enabling Technologies
PPTX
Cloud Computing and Data Centers
PPTX
1 .java basic
PDF
Agreement Protocols, distributed File Systems, Distributed Shared Memory
PPT
Java Servlets
PPTX
DevOps.pptx
PPT
Mobile Application Development MAD J2ME
PPTX
Requirements elicitation
PPTX
Introduction to GCP (Google Cloud Platform)
PPTX
Cloud computing using Eucalyptus
PPTX
Android Services
PPTX
Cloud Security Mechanisms
PDF
Google App Engine
PPT
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
PPTX
Content addressable network(can)
PPTX
Google Cloud Platform (GCP)
PDF
VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...
Android Location and Maps
Android Architecture.pptx
Capacity Planning for Cloud Computing
Cloud computing and Cloud Enabling Technologies
Cloud Computing and Data Centers
1 .java basic
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Java Servlets
DevOps.pptx
Mobile Application Development MAD J2ME
Requirements elicitation
Introduction to GCP (Google Cloud Platform)
Cloud computing using Eucalyptus
Android Services
Cloud Security Mechanisms
Google App Engine
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
Content addressable network(can)
Google Cloud Platform (GCP)
VTU 6TH SEM CSE COMPUTER NETWORKS 2 SOLVED PAPERS OF JUNE-2013 JUNE-14 & JUNE...
Ad

Viewers also liked (6)

PDF
Application deployment for iot
PDF
Introduction to java servlet 3.0 api javaone 2009
PDF
Introduction to java servlet 3.0 api javaone 2008
PPTX
java Servlet technology
PPTX
Java EE - Servlets API
PPT
Java: Java Applets
Application deployment for iot
Introduction to java servlet 3.0 api javaone 2009
Introduction to java servlet 3.0 api javaone 2008
java Servlet technology
Java EE - Servlets API
Java: Java Applets
Ad

Similar to Web Application Deployment (20)

PPTX
Web container and Apache Tomcat
DOC
Unit5 servlets
PPTX
Jsp and Servlets
PPT
Introduction to the Servlet / JSP course
PPT
JEE Course - The Web Tier
PPTX
Chapter 3 servlet & jsp
PDF
spring Boot Tutorial Part 1(JPA&Hibernate)
PPT
Java Servlets
PDF
Java servlet technology
PPT
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
PPTX
UNIT-3 Servlet
DOCX
Html servlet example
ODP
servlet 2.5 & JSP 2.0
PDF
Weblogic
PPTX
SERVLETS (2).pptxintroduction to servlet with all servlets
PPT
Web Applications and Deployment
DOC
Java Servlets & JSP
PDF
Bt0083 server side programing
PPTX
Jsp and jstl
Web container and Apache Tomcat
Unit5 servlets
Jsp and Servlets
Introduction to the Servlet / JSP course
JEE Course - The Web Tier
Chapter 3 servlet & jsp
spring Boot Tutorial Part 1(JPA&Hibernate)
Java Servlets
Java servlet technology
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
UNIT-3 Servlet
Html servlet example
servlet 2.5 & JSP 2.0
Weblogic
SERVLETS (2).pptxintroduction to servlet with all servlets
Web Applications and Deployment
Java Servlets & JSP
Bt0083 server side programing
Jsp and jstl

More from elliando dias (20)

PDF
Clojurescript slides
PDF
Why you should be excited about ClojureScript
PDF
Functional Programming with Immutable Data Structures
PPT
Nomenclatura e peças de container
PDF
Geometria Projetiva
PDF
Polyglot and Poly-paradigm Programming for Better Agility
PDF
Javascript Libraries
PDF
How to Make an Eight Bit Computer and Save the World!
PDF
Ragel talk
PDF
A Practical Guide to Connecting Hardware to the Web
PDF
Introdução ao Arduino
PDF
Minicurso arduino
PDF
Incanter Data Sorcery
PDF
PDF
Fab.in.a.box - Fab Academy: Machine Design
PDF
The Digital Revolution: Machines that makes
PDF
Hadoop + Clojure
PDF
Hadoop - Simple. Scalable.
PDF
Hadoop and Hive Development at Facebook
PDF
Multi-core Parallelization in Clojure - a Case Study
Clojurescript slides
Why you should be excited about ClojureScript
Functional Programming with Immutable Data Structures
Nomenclatura e peças de container
Geometria Projetiva
Polyglot and Poly-paradigm Programming for Better Agility
Javascript Libraries
How to Make an Eight Bit Computer and Save the World!
Ragel talk
A Practical Guide to Connecting Hardware to the Web
Introdução ao Arduino
Minicurso arduino
Incanter Data Sorcery
Fab.in.a.box - Fab Academy: Machine Design
The Digital Revolution: Machines that makes
Hadoop + Clojure
Hadoop - Simple. Scalable.
Hadoop and Hive Development at Facebook
Multi-core Parallelization in Clojure - a Case Study

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Getting Started with Data Integration: FME Form 101
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Getting Started with Data Integration: FME Form 101
Network Security Unit 5.pdf for BCA BBA.
Dropbox Q2 2025 Financial Results & Investor Presentation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Per capita expenditure prediction using model stacking based on satellite ima...
NewMind AI Weekly Chronicles - August'25-Week II
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Group 1 Presentation -Planning and Decision Making .pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
SOPHOS-XG Firewall Administrator PPT.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence

Web Application Deployment

  • 1. Web Application Deployment COMP 118 Spring 2003
  • 2. Help from Java Session tracking is provided by Java servlet API. HttpSession object Returned by getSession method of request. Can store info in session object as named attributes. setAttribute, getAttribute Other methods to configure session timeout, get information about session, etc. Uses cookies.
  • 3. Example 3 Same as example 2, but uses built in Java session support.
  • 4. Example 3 discussion What happens is cookies are disabled? Can use URL rewriting, but need to let servlet encode URL’s with session id. Use encodeURL method of request object Does rewrites URL with session id embedded as additional parameter is cookies are turned off. Returns URL unchanged if cookies turned on.
  • 5. Java Servlet API Documentation on Java Servlet API A good book. Java Servlet Programming by Jason Hunter, published by O’Reilly Unfortunately, pretty expensive.
  • 6. Web Application Deployment Typically a web application is comprised of: HTML pages Data Images Servlets Source code Libraries Other resources A servlet is a component of a web application.
  • 7. Separating server from web app. Person running the web server and person writing a web application running on that web server may not be the same. Example: a web hosting company runs a web server which “hosts” the sites of several other companies for a fee. What could be problematic about this? Need to isolate customers. Web app developer shouldn’t need to know anything about web server’s installation.
  • 8. Standardizing deployment Server products (like Tomcat) have support for setting up resources and isolating one web application from another. Old days: different servers each did things their own way. Now: there is a standard (Servlet 2.4) that defines exactly how a web application is organized and how a server maps requests to it. Note: our version of Tomcat implements 2.3
  • 9. Mapping to a web app. The server is responsible for mapping URL’s that start with a specific prefix to the location of a web application. This is the “root” of the web application. In Tomcat, this is done with a configuration file. We have defined a single web application that maps to each of your class directories.
  • 10. Web app structure There is a specific organization of the files within a web application that you need to adhere to. /WEB-INF Private resources of a web application that can not be directly served to a client. /WEB-INF/web.xml Deployment descriptor that configures the web application.
  • 11. Web app structure /WEB-INF/classes Class files for servlets Directory structure needs to reflect package names. /WEB-INF/lib Libraries (jar) files that may be needed by servlets
  • 12. Common code Many web applications may need access to common libraries and classes. Servlet API XML processing libraries Email processing libraries These are put in the server’s root /common/classes /common/lib
  • 13. COMP 118 Setup Server: wwwj.cs.unc.edu:8080 To compile correctly, be sure to: setenv JAVA_HOME /usr/java1.2 setenv CLASSPATH /opt/jakarta-4.1.18/common/lib/servlet.jar:.
  • 14. web.xml This file contains important configuration information needed to make servlets work. For a servlet to function properly, you need to add a “servlet definition” and a “servlet mapping” for each servlet. /servlet/class_name used to be a shortcut Supposed to work, but doesn’t seem to in the new version. The order of things in web.xml is important. We will put in a template which you can modify.
  • 15. Defining Servlets <servlet> <servlet-name>Name</servlet-name> <servlet-class>servlet.class</servlet-class> </servlet>
  • 16. Servlet Mapping This determines what URL’s get mapped to the servlet. <servlet-mapping> <servlet-name>Name</servlet-name> <url-pattern>/path</url-pattern> </servlet-mapping>
  • 18. Administrivia Examples from class will be put up on the web site. First programming assignment will be put up on the web site by the weekend. Make a home page (index.html) and put it at the top of your class directory. Put a picture and your name on it. Write and deploy a “hello world” servlet to test your environment.
  • 19. Initialization Parameters Can use web.xml to provide initialization parameters to a web application. Within servlet definition: <init-param> <param-name>name</param-name> <param-value>value</param-value> </init-param> Example reading book info from file.
  • 20. Debugging Our server is set up to log error messages to a file in WEB-INF/logs
  • 21. Multithread Issues There is one instance of each servlet deployed which handles every request to that servlet. But, each request is handled in its own thread. When will this cause problems? Problematic if the servlet updates non-local variables (i.e., persistent state). What is the solution? Use Java’s synchronization mechanisms Example using forms to add new books.
  • 22. Redirection and Errors Servlet can redirect request sendRedirect() Servlet can generate an error page. sendError() Status codes in documentation for HttpServletResponse
  • 23. Generating Your Own Error Pages Server puts together error page to report errors to users. You can configure your web application in order to generate your own error pages. <error-page> <error-code> 400 </error-code> <location> /400.html </location> </error-page>