SlideShare a Scribd company logo
© 2009 Marty Hall
Using and DeployingUsing and Deploying
Web Applicationspp
Originals of Slides and Source Code for Examples:
http://courses.coreservlets.com/Course-Materials/msajsp.html
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
© 2009 Marty Hall
For live Java training, please see training courses at
http //co rses coreser lets com/ Ser lets JSP Str tshttp://courses.coreservlets.com/. Servlets, JSP, Struts,
JSF, Ajax, GWT, Java 5, Java 6, Spring, Hibernate, JPA,
and customized combinations of topics.p
Taught by the author of Core Servlets and JSP, More
Servlets and JSP and this tutorial Available at public
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.
Servlets and JSP, and this tutorial. Available at public
venues, or customized versions can be held on-site at your
organization. Contact hall@coreservlets.com for details.
Agenda
• Purpose of Web applications
• Structure of Web applications
• Setting up Web applications with Tomcat
• Sharing data among Web applications
4
Idea of Web Applications
• Single directory or file
– Servlets, JSP pages, HTML files, utility classes, beans,
tag libraries, etc. are bundled together in a single
directory hierarchy or filedirectory hierarchy or file
• Common URL prefix
– Access to content in the Web app is always through app y g
URL that has a common prefix
– http://host/webAppPrefix/blah/blah
eb ml controls man things• web.xml controls many things
– Many aspects of Web application behavior controlled
through deployment descriptor (web.xml)
5
through deployment descriptor (web.xml)
• The deployment descriptor is covered in detail in the next
section.
Purposes of Web Applications
• Organization
– Related files grouped together in a single file or directory
hierarchy.
• HTML files, JSP pages, servlets, beans, images, etc.p g g
• Portability
– All compliant servers support Web apps.
C d l b i i l fil– Can redeploy on new server by moving a single file.
• Separation
– Each Web app has its own:– Each Web app has its own:
• ServletContext
• Class loader
• Sessions
6
• Sessions
• URL prefix
• Directory structure
Structure of a Web Application
• JSP and regular Web content
(HTML style sheets images etc ):(HTML, style sheets, images, etc.):
– Main directory or a subdirectory thereof.
• Servlets:
WEB INF/classes (if servlet is unpackaged i e in default package)– WEB-INF/classes (if servlet is unpackaged – i.e. in default package)
– A subdirectory thereof that matches the package name.
• Unjarred beans and utility classes:
Same place as servlets (but always use packages!)– Same place as servlets (but always use packages!)
• JAR files:
– WEB-INF/lib.
• web xml:• web.xml:
– WEB-INF
• Tag Library Descriptor files:
WEB INF bdi t th f
7
– WEB-INF or subdirectory thereof
• Files in WEB-INF not directly accessible to clients
– Server can use RequestDispatcher to forward to pages in WEB-INF
Example Deployment Structure
8
Installing Eclipse
• Overview
E li i f d l i– Eclipse is a free open-source development environment
with support for Java and many other languages
• Downloadingg
– http://www.eclipse.org/downloads/
• Choose "Eclipse IDE for Java EE Developers"
• As of 8/2008, version 3.4, called Eclipse GanymedeAs of 8/2008, version 3.4, called Eclipse Ganymede
• Installing
– Unzip into directory of your choice
P h li d k– Put shortcut to eclipse.exe on your desktop
• Integrating Tomcat in Eclipse
– http://www coreservlets com/
9
http://www.coreservlets.com/
Apache-Tomcat-Tutorial/eclipse.html
Configuring Eclipse
• Make sure Eclipse
k b Tknows about Tomcat
– Click on Servers tab at bottom.
R-click in windowR-click in window.
– New, Server, Apache, Tomcat v6.0,
Next, navigate to folder, Finish.
• Suppress unnecessary
compiler warnings
Wi d  P f – Window  Preferences 
Java  Compiler 
Errors/Warnings
10
g
• Change "Serializable class
without ..." to "Ignore"
Making Web Apps in Eclipse
• Make empty project
– File  New  Project 
Web  Dynamic Web Project
– Give it a name (e g "test")– Give it a name (e.g., test )
– Accept all other defaults
• Shortcut
– If you have made Dynamic
Web Project recently in
workspace you can just doworkspace, you can just do
File  New 
Dynamic Web Project
11
Adding Code to Eclipse Projects
• Locations
src– src
• Unpackaged Java code
• Packages strongly recommended
– src/somePackagesrc/somePackage
• Java code in somePackage package
– WebContent
• Web files (HTML, JavaScript,( p
CSS, JSP, images, etc.)
– WebContent/some-subdirectory
• Web content in subdirectory
W bC t t/WEB INF– WebContent/WEB-INF
• web.xml (will be discussed later)
• Can also click on
"Deployment Descriptor"
12
p y p
• Note
– Can cut/paste or drag/drop files into appropriate locations
Starting Server in Eclipse
• Start Tomcat
– Select "Servers" tab at bottom
– R-click on Tomcat
Choose "Start"– Choose "Start"
• Verify server startup
– Open browserOpen browser
– Enter http://localhost/
• You should see blank directory listing
– If you want pretty Tomcat
welcome page, search for a
folder called ROOT in your
Eclipse workspace.
13
p p
Copy files from
C:tomcat-dirwebappsROOT
to that folder
Deploying App in Eclipse
• Deploy project
– Select "Servers" tab at bottom
– R-click on Tomcat
Choose "Add and Remove Projects"– Choose "Add and Remove Projects"
– Choose project
– Press Add
– Click "Finish"
• Restart
Server
– R-click Tomcat
at bottom
14
at bottom
– Restart
Testing Deployed Apps in Eclipse
• Start a browser
Eclipse also has builtin browser– Eclipse also has builtin browser,
but I prefer to use Firefox or
Internet Explorer
• Test base URLTest base URL
– http://localhost/test/
• Test Web content
http://localhost/test/Hello html– http://localhost/test/Hello.html
(case sensitive!)
– http://localhost/test/Hello.jsp
– If you used subdirectoriesyou used subd ecto es
• http://localhost/test/
some-subdirectory/blah.html
• Test servlets
15
– http://localhost/test/servlet/HelloServlet
– http://localhost/test/servlet/coreservlets.HelloServlet2
• Note: custom URLs discussed in next section
Eclipse Structure (IDE-specific) vs.
Deployment Structure (Standard)Deployment Structure (Standard)
Eclipse Deployed
J d
• Java code
– src/subDirMatchingPackage
• Java code
– deployDir/webAppName/
WEB-INF/classes/src/subDirMatchingPackage
• HTML, JSP, Images
– WebContent
W bC / d Di
subDirMatchingPackage
• HTML, JSP, Images
– deployDir/webAppName
– WebContent/randomDir
• web.xml
– WebContent/WEB-INF
deployDir/webAppName
– deployDir/webAppName/
randomDir
• web xml• web.xml
– deployDir/webAppName/
WEB-INF
N t
16
• Note
– On Tomcat, deployDir is
tomcat_installdir/webapps
Making Custom Web Apps
ManuallyManually
1. Make a directory called app-blank
• app blank/WEB INF/web xml (copy from mine)• app-blank/WEB-INF/web.xml (copy from mine)
• app-blank/WEB-INF/classes (empty)
2. Copy/rename
E bl k d ll it A• E.g., copy app-blank and call it myApp
3. Put code in proper place in myApp
• Web content (HTML , JSP, images, etc.) goes in the top-level
directory (myApp) or any subdirectory other than WEB INF (e gdirectory (myApp) or any subdirectory other than WEB-INF (e.g.,
myApp/someDir)
• Servlets and other classes go in a subdirectory of WEB-
INF/classes that matches the package name.N /c asses t at atc es t e pac age a e.
4. Copy app to deployment directory
• On Tomcat, entire directory goes in install_dir/webapps
5 Update your CLASSPATH
17
5. Update your CLASSPATH.
• Add webAppDir/WEB-INF/classes to it.
• Not usually needed if you have ".." in the CLASSPATH
Manual Web App Development
Strategy with TomcatStrategy with Tomcat
• Development
– Keep the original of your Web app directory in your
development directory. Have all the files in the proper
location within that Web app directory.location within that Web app directory.
• Deployment
– Copy the entire Web app directory to the server'spy pp y
deployment location (e.g., to install_dir/webapps).
• I keep a shortcut to webapps and drag the Web app dir
onto the shortcut with the R mouse and then say "Copy".y py
• CLASSPATH
– Must include the top-level development directory
18
• That now means WEB-INF/classes dir of your Web app
• If your CLASSPATH has "..", you can leave CLASSPATH
unchanged as long as you avoid nested packages
Changing the Web App Prefix
• Eclipse default: project name is Web App
prefixprefix
– So, if project is named foo, when you deploy locally the
URL is http://localhost/foo/whatever
• Tomcat default: folder name is Web App
prefix
So if you deploy the folder bar to tomcat dir/webapps– So, if you deploy the folder bar to tomcat_dir/webapps,
the URL is http://localhost/bar/whatever.
• Custom prefix in Eclipse
– R-click on project, then Properties  Web Project
Settings  Context Root
• Custom prefix in Tomcat
19
Custom prefix in Tomcat
– Edit tomcat_dir/conf/server.xml
Defining Custom URLs
• Java code
package myPackage;package myPackage; ...
public class MyServlet extends HttpServlet { ... }
• web.xml entry (in <web-app...>...</web-app>)
Gi t l t– Give name to servlet
<servlet>
<servlet-name>MyName</servlet-name>
<servlet class>myPackage MyServlet</servlet class><servlet-class>myPackage.MyServlet</servlet-class>
</servlet>
– Give address (URL mapping) to servlet
<servlet-mapping><servlet-mapping>
<servlet-name>MyName</servlet-name>
<url-pattern>/MyAddress</url-pattern>
</servlet-mapping>
20
• Resultant URL
– http://hostname/webappPrefix/MyAddress
Defining Custom URLs: Example
(Assume Eclipse Project is "test")(Assume Eclipse Project is test )
<?xml version="1.0" encoding="UTF-8"?>
<web-app
Don't edit this manually.
Should refer to version 2.4<web app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
...
or 2.5 (Tomcat 6 only).
version="2.5">
<!-- Use the URL http://hostname/intro/hi instead
of http://hostname/intro/servlet/HelloServlet -->of http://hostname/intro/servlet/HelloServlet -->
<servlet>
<servlet-name>Second Hello Servlet</servlet-name>
<servlet-class>coreservlets.HelloServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Second Hello Servlet</servlet-name>
l tt /hi2 / l tt
Any arbitrary name.
But must be the same both times.
Fully qualified classname.
21
<url-pattern>/hi2</url-pattern>
</servlet-mapping>
</web-app>
The part of the URL that comes after the app (project) name.
Should start with a slash.
Defining Custom URLs: Result
• Eclipse details
f li j i– Name of Eclipse project is "test"
– Servlet is in src/coreservlets/HelloServlet2.java
– Deployed by right-clicking on Tomcat Add and Remove
22
– Deployed by right-clicking on Tomcat, Add and Remove
Projects, Add, choosing test project, Finish, right-clicking
again, Start
Failing to Define Custom URLs
• You should always use custom URLs on
d l d jdeployed projects
– URLs look cleaner and simpler and shorter
URLs have more meaningful names– URLs have more meaningful names
– You don't expose possibly proprietary class file names
– You can use web.xml to assign init params laterg p
• Does not work with …/servlet/myPackage.MyServlet
– You can apply filters and security settings later (via
web xml) in a more predictable and controllable mannerweb.xml) in a more predictable and controllable manner
– Most importantly of all, you can avoid being added to
Marty’s “Hall of Shame”
23
• The kiss of death for any self-respecting Java EE
developer
The Hall of Shame (Deployed Sites
with Ugly /servlet/ URLs)with Ugly …/servlet/… URLs)
24
The Art of WAR (Files)
• WAR files are simply JAR files with a different file
extensionextension
– And JAR files are simply ZIP files
• All servers are required to support Web apps that
are in WAR filesare in WAR files
– Technically, they are not absolutely required to support unbundled
Web apps.
• To create a WAR file change directory to top level• To create a WAR file, change directory to top-level
Web app directory and do:
– jar cvf webAppName.war *
O Wi Zi ( "C t C d F ld " XP)– Or use WinZip (or "Create Compressed Folder" on XP)
– Eclipse can build WAR files automatically
• R-click project, Export  WAR file
• Registering is still server specific
25
• Registering is still server-specific
– Tomcat: just drop WAR file in install_dir/webapps
– webAppName becomes Web application URL prefix
Handling Relative URLs:
ProblemProblem
• Individual JSP or HTML page: easy to load
i f l i l iimage from relative location
– <IMG SRC="EvilEmpire.gif" …>
<IMG SRC="redmond/EvilEmpire jpg" >– <IMG SRC= redmond/EvilEmpire.jpg …>
• What about servlets?
– Same strategy doesn't workgy
– Default servlet URL: http://host/prefix/servlet/Name
– Browser, not server, resolves relative URL
Wh t if i i d b JSP HTML• What if same image is used by JSP or HTML
pages scattered throughout app?
– Same problem
26
Same problem
• Also same problem:
– Style sheets, applets, even regular hypertext links
Handling Relative URLs:
SolutionsSolutions
• Use the Web application name in the URL.
– <IMG SRC="/webAppPrefix/redmond/Borg.gif" ...>
• Use web.xml to assign URLs that are at the
top level of the Web applicationtop level of the Web application
– Change http://host/webAppPrefix/servlet/SomeName to
just http://host/webAppPrefix/SomeNamej p pp
– More useful for servlets than for JSP
• Use getContextPath
– Call request.getContextPath()
and add result to URLs by hand
27
Velocity, WebMacro, and Other
Alternatives to JSP TechnologyAlternatives to JSP Technology
• Issues
– Standardization
– Portability
Integration– Integration
– Industry support
– Technical features
• Arguments for alternatives focus almost
exclusively on last issue
– Even if proponents were right about all their technical
arguments, would that matter?
28
Alternatives to JSP Technology:
Integration IssuesIntegration Issues
• Web apps give standard location for:
S l t JSP d l W b t t– Servlets, JSP pages, and regular Web content
– Not for Velocity or WebMacro pages
• Security settings apply to
– Servlets, JSP pages, and regular Web content
– Not Velocity or WebMacro pages
• Initialization parameters defined forp
– Servlets and JSP pages
– Not Velocity or WebMacro pages
• Filters apply to• Filters apply to
– Servlets, JSP pages, and regular Web content
– Not Velocity or WebMacro pages
Listeners apply to
29
• Listeners apply to
– Servlets, JSP pages, and regular Web content
– Not Velocity or WebMacro pages
Sharing Data Among Web
ApplicationsApplications
• Failure:
Sessions Each Web app has its own set of sessions– Sessions. Each Web app has its own set of sessions.
– Standard ServletContext. Each Web app has a separate one.
– Static methods or fields. Each Web app uses a different
ClassLoader.ClassLoader.
• Success:
– Explicit cookies. Cookies are shared by the whole site (even the
whole top-level domain if set appropriately).p pp p y)
• Be sure to do cookie.setPath("/"), however.
– ServletContext associated with a specific URL.
ServletContext myContext =y
getServletContext();
String url = "/someWebAppPrefix";
ServletContext otherContext =
30
myContext.getContext(url);
Object someData =
otherContext.getAttribute("someKey");
Setting Shared Data: Example
public class SetSharedInfo extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
session.setAttribute("sessionTest","Session Entry One");
ServletContext context = getServletContext();
context.setAttribute("servletContextTest",
"Servlet Context Entry One");
Cookie c1 = new Cookie("cookieTest1", "Cookie One");
c1.setMaxAge(3600); // One hour
response.addCookie(c1); // Default path
Cookie c2 = new Cookie("cookieTest2", "Cookie Two");
c2.setMaxAge(3600); // One hour
c2.setPath("/"); // Explicit path: all URLs
response.addCookie(c2);
String url = request.getContextPath() +
"/servlet/moreservlets.ShowSharedInfo";
31
// In case session tracking is based on URL rewriting.
url = response.encodeRedirectURL(url);
response.sendRedirect(url);
}}
Displaying Shared Data:
ExampleExample
public class ShowSharedInfo extends HttpServlet {
public void doGet(HttpServletRequest request,public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Shared Info";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR="#FDF5E6">n" +<BODY BGCOLOR= #FDF5E6 >n +
"<H1 ALIGN="CENTER">" + title + "</H1>n"+
"…");
HttpSession session = request.getSession(true);
…
ServletContext application = getServletContext();
…
li ti li ti tC t t("/ h T t1")
32
application = application.getContext("/shareTest1");
…
Cookie[] cookies = request.getCookies();
Accessing Web App Data:
Case 1Case 1
– SetSharedInfo run
from shareTest1from shareTest1
– ShowSharedInfo
also run from
shareTest1
– Results
• Found: session dataFound: session data
• Found: servlet context
data from normal
servlet contextservlet context
• Found: servlet context
data when explicitly
requesting servlet
33
requesting servlet
context from
shareTest1
• Found: all cookies
Accessing Web App Data:
Case 2Case 2
– SetSharedInfo run
from shareTest1from shareTest1
– ShowSharedInfo
run from shareTest2
R lt– Results
• Not found: session data
• Not found: servlet
context data fromcontext data from
normal servlet context
• Found: servlet context
data when explicitly
ti l trequesting servlet
context from
shareTest1
• Not found: cookies that
34
had default path
• Found: cookies with /
as path
Summary
• Web application benefits
Easy organization and deployment– Easy organization and deployment
– Isolation from other applications
• Structure
Top level directory or subdirectory other than WEB INF:– Top-level directory or subdirectory other than WEB-INF:
• JSP, HTML, other Web content
– WEB-INF
• web.xml
– WEB-INF/classes/directoryMatchingPackage
• Servlets, beans, utilities
• Creating a Web app in Eclipse
M k D i W b j– Make a new Dynamic Web project.
– Eclipse will create deployment structure automatically.
• Creating a Web app in Tomcat
M k di t ith t t ( WEB INF d
35
– Make a directory with proper structure (e.g. WEB-INF and
WEB-INF/classes subdirectories)
– Copy to tomcat_dir/webapps.
© 2009 Marty Hall
Questions?
Customized Java EE Training: http://courses.coreservlets.com/
Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6.
Developed and taught by well-known author and developer. At public venues or onsite at your location.

More Related Content

What's hot

All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
Joe Ferguson
 
Installing and Getting Started with Alfresco
Installing and Getting Started with AlfrescoInstalling and Getting Started with Alfresco
Installing and Getting Started with Alfresco
Wildan Maulana
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
Dan Stine
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Joe Ferguson
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
Tim Donohue
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The BasicsPhilip Langer
 
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patchesIntroduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Kalin Chernev
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
Jackson F. de A. Mafra
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
Coimbra JUG
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
Robert Scholte
 
Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)
Mathew Beane
 
Apache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDBApache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDBMongoDB
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
Povilas Korop
 
Development Tools - Maven
Development Tools - MavenDevelopment Tools - Maven
Development Tools - Maven
Bert Koorengevel
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
Ryan Cuprak
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Gavin Pickin
 

What's hot (20)

All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
Installing and Getting Started with Alfresco
Installing and Getting Started with AlfrescoInstalling and Getting Started with Alfresco
Installing and Getting Started with Alfresco
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloudphp[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
 
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patchesIntroduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)
 
Apache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDBApache Jackrabbit Oak on MongoDB
Apache Jackrabbit Oak on MongoDB
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
 
Development Tools - Maven
Development Tools - MavenDevelopment Tools - Maven
Development Tools - Maven
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Composer Helpdesk
Composer HelpdeskComposer Helpdesk
Composer Helpdesk
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
 

Viewers also liked

08 session-tracking
08 session-tracking08 session-tracking
08 session-trackingsnopteck
 
15 expression-language
15 expression-language15 expression-language
15 expression-languagesnopteck
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
04 request-headers
04 request-headers04 request-headers
04 request-headerssnopteck
 
13 java beans
13 java beans13 java beans
13 java beanssnopteck
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setupsnopteck
 
ICT observatories for better governance
ICT observatories for better governanceICT observatories for better governance
ICT observatories for better governancezalisova
 
06 response-headers
06 response-headers06 response-headers
06 response-headerssnopteck
 
11 page-directive
11 page-directive11 page-directive
11 page-directivesnopteck
 
Digital Engagement for CSPs
Digital Engagement for CSPsDigital Engagement for CSPs
Digital Engagement for CSPs
Kind of Digital
 
The Change! Tool
The Change! ToolThe Change! Tool
The Change! Tool
EmmaCranidge
 
05 status-codes
05 status-codes05 status-codes
05 status-codessnopteck
 
Linea Viso-Corpo "Naturale" by Delta BkB
Linea Viso-Corpo "Naturale" by Delta BkBLinea Viso-Corpo "Naturale" by Delta BkB
Linea Viso-Corpo "Naturale" by Delta BkBgravercosmetici
 
07 cookies
07 cookies07 cookies
07 cookiessnopteck
 
02 servlet-basics
02 servlet-basics02 servlet-basics
02 servlet-basicssnopteck
 
08 session-tracking
08 session-tracking08 session-tracking
08 session-trackingsnopteck
 

Viewers also liked (19)

08 session-tracking
08 session-tracking08 session-tracking
08 session-tracking
 
14 mvc
14 mvc14 mvc
14 mvc
 
15 expression-language
15 expression-language15 expression-language
15 expression-language
 
03 form-data
03 form-data03 form-data
03 form-data
 
04 request-headers
04 request-headers04 request-headers
04 request-headers
 
13 java beans
13 java beans13 java beans
13 java beans
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setup
 
ICT observatories for better governance
ICT observatories for better governanceICT observatories for better governance
ICT observatories for better governance
 
06 response-headers
06 response-headers06 response-headers
06 response-headers
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
 
11 page-directive
11 page-directive11 page-directive
11 page-directive
 
Digital Engagement for CSPs
Digital Engagement for CSPsDigital Engagement for CSPs
Digital Engagement for CSPs
 
The Change! Tool
The Change! ToolThe Change! Tool
The Change! Tool
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
 
05 status-codes
05 status-codes05 status-codes
05 status-codes
 
Linea Viso-Corpo "Naturale" by Delta BkB
Linea Viso-Corpo "Naturale" by Delta BkBLinea Viso-Corpo "Naturale" by Delta BkB
Linea Viso-Corpo "Naturale" by Delta BkB
 
07 cookies
07 cookies07 cookies
07 cookies
 
02 servlet-basics
02 servlet-basics02 servlet-basics
02 servlet-basics
 
08 session-tracking
08 session-tracking08 session-tracking
08 session-tracking
 

Similar to 01 web-apps

01 spring-intro
01 spring-intro01 spring-intro
01 spring-intro
hossein helali
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
Petr Jiricka
 
Jsp and servlet_netbeans-webapps
Jsp and servlet_netbeans-webappsJsp and servlet_netbeans-webapps
Jsp and servlet_netbeans-webappsOPENLANE
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
AnkitKumar2343
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
BG Java EE Course
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUlrich Krause
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-components
vinaysbk
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
Richard Martens
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
Steve Keener
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags AdvancedAkramWaseem
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
Minal Maniar
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
Eduardo Pelegri-Llopart
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Domino java
Domino javaDomino java
Domino java
Sumit Tambe
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best Practices
Alfresco Software
 
Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2Eduardo Pelegri-Llopart
 
Android training in Noida
Android training in NoidaAndroid training in Noida
Android training in Noida
SeoClass
 

Similar to 01 web-apps (20)

Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
01 spring-intro
01 spring-intro01 spring-intro
01 spring-intro
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
 
Jsp and servlet_netbeans-webapps
Jsp and servlet_netbeans-webappsJsp and servlet_netbeans-webapps
Jsp and servlet_netbeans-webapps
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-components
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Domino java
Domino javaDomino java
Domino java
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best Practices
 
Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2
 
Android training in Noida
Android training in NoidaAndroid training in Noida
Android training in Noida
 

Recently uploaded

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 

Recently uploaded (20)

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 

01 web-apps

  • 1. © 2009 Marty Hall Using and DeployingUsing and Deploying Web Applicationspp Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/Course-Materials/msajsp.html Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2009 Marty Hall For live Java training, please see training courses at http //co rses coreser lets com/ Ser lets JSP Str tshttp://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, Ajax, GWT, Java 5, Java 6, Spring, Hibernate, JPA, and customized combinations of topics.p Taught by the author of Core Servlets and JSP, More Servlets and JSP and this tutorial Available at public Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. Servlets and JSP, and this tutorial. Available at public venues, or customized versions can be held on-site at your organization. Contact hall@coreservlets.com for details.
  • 2. Agenda • Purpose of Web applications • Structure of Web applications • Setting up Web applications with Tomcat • Sharing data among Web applications 4 Idea of Web Applications • Single directory or file – Servlets, JSP pages, HTML files, utility classes, beans, tag libraries, etc. are bundled together in a single directory hierarchy or filedirectory hierarchy or file • Common URL prefix – Access to content in the Web app is always through app y g URL that has a common prefix – http://host/webAppPrefix/blah/blah eb ml controls man things• web.xml controls many things – Many aspects of Web application behavior controlled through deployment descriptor (web.xml) 5 through deployment descriptor (web.xml) • The deployment descriptor is covered in detail in the next section.
  • 3. Purposes of Web Applications • Organization – Related files grouped together in a single file or directory hierarchy. • HTML files, JSP pages, servlets, beans, images, etc.p g g • Portability – All compliant servers support Web apps. C d l b i i l fil– Can redeploy on new server by moving a single file. • Separation – Each Web app has its own:– Each Web app has its own: • ServletContext • Class loader • Sessions 6 • Sessions • URL prefix • Directory structure Structure of a Web Application • JSP and regular Web content (HTML style sheets images etc ):(HTML, style sheets, images, etc.): – Main directory or a subdirectory thereof. • Servlets: WEB INF/classes (if servlet is unpackaged i e in default package)– WEB-INF/classes (if servlet is unpackaged – i.e. in default package) – A subdirectory thereof that matches the package name. • Unjarred beans and utility classes: Same place as servlets (but always use packages!)– Same place as servlets (but always use packages!) • JAR files: – WEB-INF/lib. • web xml:• web.xml: – WEB-INF • Tag Library Descriptor files: WEB INF bdi t th f 7 – WEB-INF or subdirectory thereof • Files in WEB-INF not directly accessible to clients – Server can use RequestDispatcher to forward to pages in WEB-INF
  • 4. Example Deployment Structure 8 Installing Eclipse • Overview E li i f d l i– Eclipse is a free open-source development environment with support for Java and many other languages • Downloadingg – http://www.eclipse.org/downloads/ • Choose "Eclipse IDE for Java EE Developers" • As of 8/2008, version 3.4, called Eclipse GanymedeAs of 8/2008, version 3.4, called Eclipse Ganymede • Installing – Unzip into directory of your choice P h li d k– Put shortcut to eclipse.exe on your desktop • Integrating Tomcat in Eclipse – http://www coreservlets com/ 9 http://www.coreservlets.com/ Apache-Tomcat-Tutorial/eclipse.html
  • 5. Configuring Eclipse • Make sure Eclipse k b Tknows about Tomcat – Click on Servers tab at bottom. R-click in windowR-click in window. – New, Server, Apache, Tomcat v6.0, Next, navigate to folder, Finish. • Suppress unnecessary compiler warnings Wi d  P f – Window  Preferences  Java  Compiler  Errors/Warnings 10 g • Change "Serializable class without ..." to "Ignore" Making Web Apps in Eclipse • Make empty project – File  New  Project  Web  Dynamic Web Project – Give it a name (e g "test")– Give it a name (e.g., test ) – Accept all other defaults • Shortcut – If you have made Dynamic Web Project recently in workspace you can just doworkspace, you can just do File  New  Dynamic Web Project 11
  • 6. Adding Code to Eclipse Projects • Locations src– src • Unpackaged Java code • Packages strongly recommended – src/somePackagesrc/somePackage • Java code in somePackage package – WebContent • Web files (HTML, JavaScript,( p CSS, JSP, images, etc.) – WebContent/some-subdirectory • Web content in subdirectory W bC t t/WEB INF– WebContent/WEB-INF • web.xml (will be discussed later) • Can also click on "Deployment Descriptor" 12 p y p • Note – Can cut/paste or drag/drop files into appropriate locations Starting Server in Eclipse • Start Tomcat – Select "Servers" tab at bottom – R-click on Tomcat Choose "Start"– Choose "Start" • Verify server startup – Open browserOpen browser – Enter http://localhost/ • You should see blank directory listing – If you want pretty Tomcat welcome page, search for a folder called ROOT in your Eclipse workspace. 13 p p Copy files from C:tomcat-dirwebappsROOT to that folder
  • 7. Deploying App in Eclipse • Deploy project – Select "Servers" tab at bottom – R-click on Tomcat Choose "Add and Remove Projects"– Choose "Add and Remove Projects" – Choose project – Press Add – Click "Finish" • Restart Server – R-click Tomcat at bottom 14 at bottom – Restart Testing Deployed Apps in Eclipse • Start a browser Eclipse also has builtin browser– Eclipse also has builtin browser, but I prefer to use Firefox or Internet Explorer • Test base URLTest base URL – http://localhost/test/ • Test Web content http://localhost/test/Hello html– http://localhost/test/Hello.html (case sensitive!) – http://localhost/test/Hello.jsp – If you used subdirectoriesyou used subd ecto es • http://localhost/test/ some-subdirectory/blah.html • Test servlets 15 – http://localhost/test/servlet/HelloServlet – http://localhost/test/servlet/coreservlets.HelloServlet2 • Note: custom URLs discussed in next section
  • 8. Eclipse Structure (IDE-specific) vs. Deployment Structure (Standard)Deployment Structure (Standard) Eclipse Deployed J d • Java code – src/subDirMatchingPackage • Java code – deployDir/webAppName/ WEB-INF/classes/src/subDirMatchingPackage • HTML, JSP, Images – WebContent W bC / d Di subDirMatchingPackage • HTML, JSP, Images – deployDir/webAppName – WebContent/randomDir • web.xml – WebContent/WEB-INF deployDir/webAppName – deployDir/webAppName/ randomDir • web xml• web.xml – deployDir/webAppName/ WEB-INF N t 16 • Note – On Tomcat, deployDir is tomcat_installdir/webapps Making Custom Web Apps ManuallyManually 1. Make a directory called app-blank • app blank/WEB INF/web xml (copy from mine)• app-blank/WEB-INF/web.xml (copy from mine) • app-blank/WEB-INF/classes (empty) 2. Copy/rename E bl k d ll it A• E.g., copy app-blank and call it myApp 3. Put code in proper place in myApp • Web content (HTML , JSP, images, etc.) goes in the top-level directory (myApp) or any subdirectory other than WEB INF (e gdirectory (myApp) or any subdirectory other than WEB-INF (e.g., myApp/someDir) • Servlets and other classes go in a subdirectory of WEB- INF/classes that matches the package name.N /c asses t at atc es t e pac age a e. 4. Copy app to deployment directory • On Tomcat, entire directory goes in install_dir/webapps 5 Update your CLASSPATH 17 5. Update your CLASSPATH. • Add webAppDir/WEB-INF/classes to it. • Not usually needed if you have ".." in the CLASSPATH
  • 9. Manual Web App Development Strategy with TomcatStrategy with Tomcat • Development – Keep the original of your Web app directory in your development directory. Have all the files in the proper location within that Web app directory.location within that Web app directory. • Deployment – Copy the entire Web app directory to the server'spy pp y deployment location (e.g., to install_dir/webapps). • I keep a shortcut to webapps and drag the Web app dir onto the shortcut with the R mouse and then say "Copy".y py • CLASSPATH – Must include the top-level development directory 18 • That now means WEB-INF/classes dir of your Web app • If your CLASSPATH has "..", you can leave CLASSPATH unchanged as long as you avoid nested packages Changing the Web App Prefix • Eclipse default: project name is Web App prefixprefix – So, if project is named foo, when you deploy locally the URL is http://localhost/foo/whatever • Tomcat default: folder name is Web App prefix So if you deploy the folder bar to tomcat dir/webapps– So, if you deploy the folder bar to tomcat_dir/webapps, the URL is http://localhost/bar/whatever. • Custom prefix in Eclipse – R-click on project, then Properties  Web Project Settings  Context Root • Custom prefix in Tomcat 19 Custom prefix in Tomcat – Edit tomcat_dir/conf/server.xml
  • 10. Defining Custom URLs • Java code package myPackage;package myPackage; ... public class MyServlet extends HttpServlet { ... } • web.xml entry (in <web-app...>...</web-app>) Gi t l t– Give name to servlet <servlet> <servlet-name>MyName</servlet-name> <servlet class>myPackage MyServlet</servlet class><servlet-class>myPackage.MyServlet</servlet-class> </servlet> – Give address (URL mapping) to servlet <servlet-mapping><servlet-mapping> <servlet-name>MyName</servlet-name> <url-pattern>/MyAddress</url-pattern> </servlet-mapping> 20 • Resultant URL – http://hostname/webappPrefix/MyAddress Defining Custom URLs: Example (Assume Eclipse Project is "test")(Assume Eclipse Project is test ) <?xml version="1.0" encoding="UTF-8"?> <web-app Don't edit this manually. Should refer to version 2.4<web app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" ... or 2.5 (Tomcat 6 only). version="2.5"> <!-- Use the URL http://hostname/intro/hi instead of http://hostname/intro/servlet/HelloServlet -->of http://hostname/intro/servlet/HelloServlet --> <servlet> <servlet-name>Second Hello Servlet</servlet-name> <servlet-class>coreservlets.HelloServlet2</servlet-class> </servlet> <servlet-mapping> <servlet-name>Second Hello Servlet</servlet-name> l tt /hi2 / l tt Any arbitrary name. But must be the same both times. Fully qualified classname. 21 <url-pattern>/hi2</url-pattern> </servlet-mapping> </web-app> The part of the URL that comes after the app (project) name. Should start with a slash.
  • 11. Defining Custom URLs: Result • Eclipse details f li j i– Name of Eclipse project is "test" – Servlet is in src/coreservlets/HelloServlet2.java – Deployed by right-clicking on Tomcat Add and Remove 22 – Deployed by right-clicking on Tomcat, Add and Remove Projects, Add, choosing test project, Finish, right-clicking again, Start Failing to Define Custom URLs • You should always use custom URLs on d l d jdeployed projects – URLs look cleaner and simpler and shorter URLs have more meaningful names– URLs have more meaningful names – You don't expose possibly proprietary class file names – You can use web.xml to assign init params laterg p • Does not work with …/servlet/myPackage.MyServlet – You can apply filters and security settings later (via web xml) in a more predictable and controllable mannerweb.xml) in a more predictable and controllable manner – Most importantly of all, you can avoid being added to Marty’s “Hall of Shame” 23 • The kiss of death for any self-respecting Java EE developer
  • 12. The Hall of Shame (Deployed Sites with Ugly /servlet/ URLs)with Ugly …/servlet/… URLs) 24 The Art of WAR (Files) • WAR files are simply JAR files with a different file extensionextension – And JAR files are simply ZIP files • All servers are required to support Web apps that are in WAR filesare in WAR files – Technically, they are not absolutely required to support unbundled Web apps. • To create a WAR file change directory to top level• To create a WAR file, change directory to top-level Web app directory and do: – jar cvf webAppName.war * O Wi Zi ( "C t C d F ld " XP)– Or use WinZip (or "Create Compressed Folder" on XP) – Eclipse can build WAR files automatically • R-click project, Export  WAR file • Registering is still server specific 25 • Registering is still server-specific – Tomcat: just drop WAR file in install_dir/webapps – webAppName becomes Web application URL prefix
  • 13. Handling Relative URLs: ProblemProblem • Individual JSP or HTML page: easy to load i f l i l iimage from relative location – <IMG SRC="EvilEmpire.gif" …> <IMG SRC="redmond/EvilEmpire jpg" >– <IMG SRC= redmond/EvilEmpire.jpg …> • What about servlets? – Same strategy doesn't workgy – Default servlet URL: http://host/prefix/servlet/Name – Browser, not server, resolves relative URL Wh t if i i d b JSP HTML• What if same image is used by JSP or HTML pages scattered throughout app? – Same problem 26 Same problem • Also same problem: – Style sheets, applets, even regular hypertext links Handling Relative URLs: SolutionsSolutions • Use the Web application name in the URL. – <IMG SRC="/webAppPrefix/redmond/Borg.gif" ...> • Use web.xml to assign URLs that are at the top level of the Web applicationtop level of the Web application – Change http://host/webAppPrefix/servlet/SomeName to just http://host/webAppPrefix/SomeNamej p pp – More useful for servlets than for JSP • Use getContextPath – Call request.getContextPath() and add result to URLs by hand 27
  • 14. Velocity, WebMacro, and Other Alternatives to JSP TechnologyAlternatives to JSP Technology • Issues – Standardization – Portability Integration– Integration – Industry support – Technical features • Arguments for alternatives focus almost exclusively on last issue – Even if proponents were right about all their technical arguments, would that matter? 28 Alternatives to JSP Technology: Integration IssuesIntegration Issues • Web apps give standard location for: S l t JSP d l W b t t– Servlets, JSP pages, and regular Web content – Not for Velocity or WebMacro pages • Security settings apply to – Servlets, JSP pages, and regular Web content – Not Velocity or WebMacro pages • Initialization parameters defined forp – Servlets and JSP pages – Not Velocity or WebMacro pages • Filters apply to• Filters apply to – Servlets, JSP pages, and regular Web content – Not Velocity or WebMacro pages Listeners apply to 29 • Listeners apply to – Servlets, JSP pages, and regular Web content – Not Velocity or WebMacro pages
  • 15. Sharing Data Among Web ApplicationsApplications • Failure: Sessions Each Web app has its own set of sessions– Sessions. Each Web app has its own set of sessions. – Standard ServletContext. Each Web app has a separate one. – Static methods or fields. Each Web app uses a different ClassLoader.ClassLoader. • Success: – Explicit cookies. Cookies are shared by the whole site (even the whole top-level domain if set appropriately).p pp p y) • Be sure to do cookie.setPath("/"), however. – ServletContext associated with a specific URL. ServletContext myContext =y getServletContext(); String url = "/someWebAppPrefix"; ServletContext otherContext = 30 myContext.getContext(url); Object someData = otherContext.getAttribute("someKey"); Setting Shared Data: Example public class SetSharedInfo extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); session.setAttribute("sessionTest","Session Entry One"); ServletContext context = getServletContext(); context.setAttribute("servletContextTest", "Servlet Context Entry One"); Cookie c1 = new Cookie("cookieTest1", "Cookie One"); c1.setMaxAge(3600); // One hour response.addCookie(c1); // Default path Cookie c2 = new Cookie("cookieTest2", "Cookie Two"); c2.setMaxAge(3600); // One hour c2.setPath("/"); // Explicit path: all URLs response.addCookie(c2); String url = request.getContextPath() + "/servlet/moreservlets.ShowSharedInfo"; 31 // In case session tracking is based on URL rewriting. url = response.encodeRedirectURL(url); response.sendRedirect(url); }}
  • 16. Displaying Shared Data: ExampleExample public class ShowSharedInfo extends HttpServlet { public void doGet(HttpServletRequest request,public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Shared Info"; out.println(ServletUtilities.headWithTitle(title) + "<BODY BGCOLOR="#FDF5E6">n" +<BODY BGCOLOR= #FDF5E6 >n + "<H1 ALIGN="CENTER">" + title + "</H1>n"+ "…"); HttpSession session = request.getSession(true); … ServletContext application = getServletContext(); … li ti li ti tC t t("/ h T t1") 32 application = application.getContext("/shareTest1"); … Cookie[] cookies = request.getCookies(); Accessing Web App Data: Case 1Case 1 – SetSharedInfo run from shareTest1from shareTest1 – ShowSharedInfo also run from shareTest1 – Results • Found: session dataFound: session data • Found: servlet context data from normal servlet contextservlet context • Found: servlet context data when explicitly requesting servlet 33 requesting servlet context from shareTest1 • Found: all cookies
  • 17. Accessing Web App Data: Case 2Case 2 – SetSharedInfo run from shareTest1from shareTest1 – ShowSharedInfo run from shareTest2 R lt– Results • Not found: session data • Not found: servlet context data fromcontext data from normal servlet context • Found: servlet context data when explicitly ti l trequesting servlet context from shareTest1 • Not found: cookies that 34 had default path • Found: cookies with / as path Summary • Web application benefits Easy organization and deployment– Easy organization and deployment – Isolation from other applications • Structure Top level directory or subdirectory other than WEB INF:– Top-level directory or subdirectory other than WEB-INF: • JSP, HTML, other Web content – WEB-INF • web.xml – WEB-INF/classes/directoryMatchingPackage • Servlets, beans, utilities • Creating a Web app in Eclipse M k D i W b j– Make a new Dynamic Web project. – Eclipse will create deployment structure automatically. • Creating a Web app in Tomcat M k di t ith t t ( WEB INF d 35 – Make a directory with proper structure (e.g. WEB-INF and WEB-INF/classes subdirectories) – Copy to tomcat_dir/webapps.
  • 18. © 2009 Marty Hall Questions? Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.