SlideShare a Scribd company logo
1 of 25
Java Web Applications   and Deployment Svetlin Nakov Borislava Spasova
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Tomcat Web Application Server
What is a Web Container? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Is Tomcat? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Web Container and Web Server Integration ,[object Object]
Installing Tomcat ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Running Tomcat ,[object Object],[object Object],[object Object],bin/startup.bat set JAVA_HOME= C:rogra~1avadk1. 6 .0_ 23 rem This space in the path will cause problems! set JAVA_HOME="C:rogram Filesavadk1. 6 .0_ 23"
Tomcat Directory Structure  (as in Tomcat 7.0.11) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Web Applications Structure and Deployment
Java Web Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Web Applications Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example – Login / Logout Web Application Structure The root directory of the Web application Classes of the application (including servlets) Libraries of the application (e.g. JDBC drivers) Deployment descriptor (configuration file) Public accessible files (HTML, JSP, CSS, ...) Special directory
WAR Files ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
WAR Files – Example ,[object Object],[object Object]
The Deployment Descriptor ( web.xml ) ,[object Object],[object Object],[object Object],[object Object],[object Object],<web-app version=&quot;2.4&quot;   xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> ... </web-app>
What is Defined in The Deployment Descriptor? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mapping a Servlet to URL ,[object Object],[object Object],[object Object],<servlet> <servlet-name> LoginServlet </servlet-name> <servlet-class> com.mycompany.myproduct. web. LoginServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> LoginServlet </servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping>
[object Object],[object Object],Configuring The Servlet Initialization Parameters <servlet> <servlet-name>InitTest</servlet-name> <servlet-class>myservlets.InitServlet</servlet-class> <init-param> <param-name> username </param-name> <param-value>admin</param-value> </init-param> <init-param> <param-name>emailAddress</param-name> <param-value>admin@localhost</param-value> </init-param> </servlet> getServletConfig().getInitParameter(&quot; username &quot;);
Sample  web.xml  File <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name>TimeServlet</servlet-name> <servlet-class>TimeServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TimeServlet</servlet-name> <url-pattern>/TimeServlet</url-pattern> </servlet-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
Creating Web Application and Deploying on Tomcat ,[object Object],[object Object],[object Object],[object Object],[object Object]
Creating Web Application and Deploying on Tomcat (2) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns=   &quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=   &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name> Hello Servlet</servlet-name> <servlet-class> Hello Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name> Hello Servlet</servlet-name> <url-pattern>/ Hello Servlet</url-pattern> </servlet-mapping> </web-app> web.xml
Creating Web Application and Deploying on Tomcat (3) ,[object Object],[object Object],[object Object],[object Object],http://localhost:8080/myapp/HelloForm.html
Problems ,[object Object],[object Object],[object Object]
Homework ,[object Object],[object Object],[object Object]

More Related Content

What's hot (20)

Http methods
Http methodsHttp methods
Http methods
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
WSDL
WSDLWSDL
WSDL
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Chapter07 Advanced File System Management
Chapter07      Advanced  File  System  ManagementChapter07      Advanced  File  System  Management
Chapter07 Advanced File System Management
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
AD & LDAP
AD & LDAPAD & LDAP
AD & LDAP
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
SNMP
SNMPSNMP
SNMP
 
Simple object access protocol(soap )
Simple object access protocol(soap )Simple object access protocol(soap )
Simple object access protocol(soap )
 
LDAP
LDAPLDAP
LDAP
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
 
Php array
Php arrayPhp array
Php array
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 

Viewers also liked

WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleJames Bayer
 
ZK_Arch_notes_20081121
ZK_Arch_notes_20081121ZK_Arch_notes_20081121
ZK_Arch_notes_20081121WANGCHOU LU
 
3) web development
3) web development3) web development
3) web developmenttechbed
 
7) packaging and deployment
7) packaging and deployment7) packaging and deployment
7) packaging and deploymenttechbed
 
Lecture 11 bitwise_operator
Lecture 11 bitwise_operatorLecture 11 bitwise_operator
Lecture 11 bitwise_operatoreShikshak
 
principle of oop’s in cpp
principle of oop’s in cppprinciple of oop’s in cpp
principle of oop’s in cppgourav kottawar
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technologyvikram singh
 
Screenshot of Desktop System Application Complete
Screenshot of Desktop System Application CompleteScreenshot of Desktop System Application Complete
Screenshot of Desktop System Application CompleteHendrawan Hendrawan
 
Linux directory structure by jitu mistry
Linux directory structure by jitu mistryLinux directory structure by jitu mistry
Linux directory structure by jitu mistryJITU MISTRY
 
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...Joget Workflow
 
WebService-Java
WebService-JavaWebService-Java
WebService-Javahalwal
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory StructureKevin OBrien
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsBG Java EE Course
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable typevinay arora
 

Viewers also liked (20)

WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
ZK_Arch_notes_20081121
ZK_Arch_notes_20081121ZK_Arch_notes_20081121
ZK_Arch_notes_20081121
 
3) web development
3) web development3) web development
3) web development
 
Introduction to jsf 2
Introduction to jsf 2Introduction to jsf 2
Introduction to jsf 2
 
7) packaging and deployment
7) packaging and deployment7) packaging and deployment
7) packaging and deployment
 
JSF 2.2
JSF 2.2JSF 2.2
JSF 2.2
 
Rich faces
Rich facesRich faces
Rich faces
 
Lecture 11 bitwise_operator
Lecture 11 bitwise_operatorLecture 11 bitwise_operator
Lecture 11 bitwise_operator
 
principle of oop’s in cpp
principle of oop’s in cppprinciple of oop’s in cpp
principle of oop’s in cpp
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
Screenshot of Desktop System Application Complete
Screenshot of Desktop System Application CompleteScreenshot of Desktop System Application Complete
Screenshot of Desktop System Application Complete
 
12 installing eclipse
12   installing eclipse12   installing eclipse
12 installing eclipse
 
Linux directory structure by jitu mistry
Linux directory structure by jitu mistryLinux directory structure by jitu mistry
Linux directory structure by jitu mistry
 
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 

Similar to Web Applications and Deployment

Similar to Web Applications and Deployment (20)

Lect06 tomcat1
Lect06 tomcat1Lect06 tomcat1
Lect06 tomcat1
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
bjhbj
bjhbjbjhbj
bjhbj
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Auxiliary : Tomcat
Auxiliary : TomcatAuxiliary : Tomcat
Auxiliary : Tomcat
 
Tomcat configuration
Tomcat configurationTomcat configuration
Tomcat configuration
 
Unit5 servlets
Unit5 servletsUnit5 servlets
Unit5 servlets
 
Tomcat tutorail
Tomcat tutorailTomcat tutorail
Tomcat tutorail
 
Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Server
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3
 
Jira Rev002
Jira Rev002Jira Rev002
Jira Rev002
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed intro
 
Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
 

More from BG Java EE Course (20)

JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
JSTL
JSTLJSTL
JSTL
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
CSS
CSSCSS
CSS
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
WWW and HTTP
WWW and HTTPWWW and HTTP
WWW and HTTP
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Creating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSSCreating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSS
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Introduction to-RDBMS-systems
Introduction to-RDBMS-systemsIntroduction to-RDBMS-systems
Introduction to-RDBMS-systems
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Basic input-output-v.1.1
Basic input-output-v.1.1Basic input-output-v.1.1
Basic input-output-v.1.1
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 

Web Applications and Deployment

  • 1. Java Web Applications and Deployment Svetlin Nakov Borislava Spasova
  • 2.
  • 3. Using Tomcat Web Application Server
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Java Web Applications Structure and Deployment
  • 11.
  • 12.
  • 13. Example – Login / Logout Web Application Structure The root directory of the Web application Classes of the application (including servlets) Libraries of the application (e.g. JDBC drivers) Deployment descriptor (configuration file) Public accessible files (HTML, JSP, CSS, ...) Special directory
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. Sample web.xml File <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name>TimeServlet</servlet-name> <servlet-class>TimeServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>TimeServlet</servlet-name> <url-pattern>/TimeServlet</url-pattern> </servlet-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
  • 21.
  • 22. Creating Web Application and Deploying on Tomcat (2) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <web-app version=&quot;2.4&quot; xmlns= &quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi= &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;> <servlet> <servlet-name> Hello Servlet</servlet-name> <servlet-class> Hello Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name> Hello Servlet</servlet-name> <url-pattern>/ Hello Servlet</url-pattern> </servlet-mapping> </web-app> web.xml
  • 23.
  • 24.
  • 25.

Editor's Notes

  1. webapp directory is considered the Web application root directory. All JSP, HTML, JavaScript files, and other resources are under this directory. The WEB-INF directory contains resources used by the application, WEB-INF is not in the public document root—no files contained in this directory structure are accessible by a client. The classes directory (under WEB-INF) contains servlets, beans, and utility classes needed for webapp&apos;s operation. lib directory (under WEB-INF) contains Java archive files (JARs), such as the JDBC driver or tag library, on which webapp depends. If a class is present in a JAR file and in the classes directory, the class loader loads the one in the classes directory.
  2. Notes Order matters: servlet before servlet-mapping JSP: Use jsp-file instead of servlet-class