SlideShare a Scribd company logo
Developing Java Web Applications Dr. Harry Chen CMSC 491S/691S February 11, 2008
Agenda Web application architecture  Java Servlet technology WebWork : building webapps made easy Spring : Inversion of Control (IoC) Maven : Java project management and build tool
A canonical Web architecture Do you see any technical issues in this architecture? Source: http://www.ibm.com/developerworks/ibm/library/it-booch_web/
Stateless communication Communications between your browser and the Web Server is usually stateless “ Cookie” was invented to solve this problem.
Thin client vs. Thick (fat) client Where do you place your business logic? Thin client : most of the business logic live on the client side Thick client : application states are managed by the server Thin clients live here. Thick clients live here.
How do we create View? Raw data must be processed before it’s presented to the user.  Users see the View (HTML, PDF, RSS etc.) Should you “hardwire” code in the business logic to generate Views? Raw data View (HTML, PDF, etc) How will be the Views be generated?
Overhead in access data A major part of the application implementation consists of accessing and updating the “raw data” – which can be costly. Reduce this overhead can speed up your development (i.e., save cost) SQL DB HTML Do I have to call “SELECT”, “INSERT”, “UPDATE” all the time?
Framework Software engineering is like civil engineering: we need framework. Option 2: Use framework Your Goal Option1: Build everything from scratch…
Framework: It’s a juggle out there. http://en.wikipedia.org/wiki/List_of_web_application_frameworks JavaScript Backbase   Clean AJAX   Dojo Toolkit   Echo   Ext   JQuery   Microsoft AJAX Library   Mochikit   MooTools   OpenLink  AJAX Toolkit   Prototype JavaScript Framework   qooxdoo   Rialto Toolkit   Rico   Script.aculo.us   SmartClient   Spry framework   Yahoo! UI Library   ASP.NET MonoRail   DotNetNuke   CSLA   ASP.NET MVC Framework   Java Apache Cocoon   Apache Struts   AppFuse   Aranea  framework   Click   [ fleXive ]   Google Web Toolkit   Grails   Hamlets   ICEfaces   IT Mill Toolkit   ItsNat   JavaServer  Faces   Java JBoss  Seam   Makumba   OpenLaszlo   OpenXava   Oracle ADF   Reasonable Server Faces   RIFE   Shale Framework (software)   SmartClient   Spring Framework   Stripes (framework)   Tapestry   ThinWire   WebObjects   WebWork   Wicket framework   ZK Framework   ztemplates   Perl Catalyst   Interchange   Maypole   Mason   PHP Akelos  PHP Framework   Antares  Framework   CakePHP   Canvas Framework   CodeIgniter   DIY Framework   Drupal   epesi   FUSE   Horde   Joomla !   KohanaPHP   MODx   PHP For Applications   PHPOpenbiz   PostNuke   PRADO   Qcodo   QPHP Framework   Seagull PHP Framework   Simplicity PHP framework   Symfony ColdFusion ColdBox   ColdFusion on Wheels   ColdSpring   Fusebox   Mach-II   Model-Glue   onTap
Java Servlet technology
Java Servlet technology Servlets are Java code that run in a server application (e.g., Tomcat) and answer client request.  Source: http://www.informit.com/articles/article.aspx?p=26920
HelloWorld Servlet Set HTTP Header: Content-Type (HTML) Creates the HTML page content Implementation that handles HTTP GET request Outputs the HTML into the HTTP Response Do you see any technical issues with this implementation? Source: http://www.informit.com/articles/article.aspx?p=26920
JSP (Java Servlet Pages) Technology that allows Java code and certain pre-defined actions to be embedded into static content.  Java Servlet: Write code    compile    deploy JSP Write code    deploy
HelloWorld JSP Source: http://mainline.brynmawr.edu/~dkumar/JSP/ Use Java as if it’s a scripting language
Open issues in Java Servlet technology No mention of any framework or design pattern for building web applications How to handle stateless communication? Use Thin or Thick client? How to access data? How to create Views?
MVC: Model-View-Control Java BluePrints developed a recommended design pattern for building Java Servlet applications Goal: help you to design, implement and  maintain  your Java Web applications http://java.sun.com/blueprints/patterns/MVC-detailed.html
Example: J2EE webapp This is what you want to build.
Example: J2EE webapp (cont.) This is an MVC solution All DB access and update operations are implemented here. All business logic and applications states are stored here. HTML, PDF and whatever goes here. They read and parse data object from the Model
Problems with MVC MVC is only a design pattern – i.e., you still have to write code to follow this specification An obvious problem is that everyone has to learn and write their own MVC framework
WebWork
WebWork A Java MVC framework that help developers to minimize code and to be more concentrated on business logic and modeling.  Less “plumbing” code, more “useful” code. http://www.opensymphony.com/webwork/
WebWork terminology Action : a piece of code that is executed when a URL is visited Bean : a data object that holds useful application information Views : templates pages for generating outputs for the clients to consume.  Result : the output created by a template page
WebWork workflow Read:  http://www.javaworld.com/javaworld/jw-03-2004/jw-0329-webwork.html
WebWork HelloWorld Goal: Go a URL, the webapp outputs “Hello World!” 3 Steps Create an Action class to handle the request Create a View (template) to produce HTML Configure Action and View
Action: HelloWorld.java Extends a standard Action superclass. Implement the business logic How to access the Bean (the message)
View: helloworld.jsp Use JSP Tag lib to access our Bean (the message) If you don’t like to use JSP, you have other options:  Freemarker  and Velocity
WebWork Configuration: HelloWorld Edit  xwork.xml  to “glue” the Action with the Template view. Define our Action and name it “helloworld” If the action returns “ success ”, then apply the “ hello.jsp ” template
WebWork: HelloWorld Output Read: http://www.javaworld.com/javaworld/jw-10-2005/jw-1010-webwork.html
Spring IoC
Dynamic object instantiation Often your business logic implementation requires runtime configuration Customer Relationship App may use a different JDBC connection to access a new customer DB Dynamically fine tune how many threads the robot should instantiate for building search index DB Configure the username, password and DB url for your JDBC connection.
Inversion of Control (IoC) IoC is a principle that encourage the decoupling of code.  A.K.A. Dependency Injection. Problem : The use of “MovieFinderImpl” is hardwired into “MovieLister”. Change this logic will require code rewrite and re-compile “MovieFinderImpl” Read: http://martinfowler.com/articles/injection.html
IoC Solution Introduce an intermediate component to handle the assembly of class objects. Solution : If you want to use a different “MovieFinder”, just change how “Assembler” calls <creates>. <creates>
Spring IoC A framework that can be coupled with WebWork to provide Dependency Injection.  Spring IoC  implements a flexible “Assembler”. Developers can tell this “Assembler” how to perform “<create>” via XML configuration. http://static.springframework.org/spring/docs/2.0.x/reference/beans.html
Spring IoC: HelloWorld in gnizr How HelloWorld Action is instantiated in gnizr’s HelloWorld demo http://code.google.com/p/gnizr/wiki/HelloWorldDemo
Spring IoC: a more complex example (1) The Class object “folderTagListener” is dynamically associated with “bookmarkManager” via a configuration file, not hardwired in the source of “bookmarkManager”. (2) Developers also fine tune the number of WorkerThread to be instantiated by “bookmarkManager” in the same configuration file. (1) (2)
Apache Maven
Jave project management It concerns the management of  library dependency,  code building,  unit testing,  packaging and  documentation. Why do you think it’s important to consider those issues when building software? - Can you relate to what you have experienced in the past (in school or at work)?
Problems I have faced When some JAR library changed, I have to manually download the JAR from the project web site. Make sure dependency library are included in my CLASSPATH for building and testing Decide the directory layout of my project (where is “src”, “classes”, “resources”). Figure out how to write documentation and call “javadoc” in my project.
Apache Maven Maven is an open source Java project management tool that simplifies many of the tedious tasks associated with Java programming. Features I love very much: Library dependency management Build, test, and package Pre-defined directory layout for webapp dev.  http://maven.apache.org/
POM file In “Make”, we have “Makefile” In “Maven”, we have “POM file” (pom.xml) In this POM file, you can define JAR (version and package names) that should to be included in your build CLASSPATH (dependencies).  The layout of your project (where do you keep source, .class, other resources and configuration) Information for generating documentation And many other stuff…
Maven: Create a project
Maven: POM file
Maven: build package
Try Maven in 5 minutes http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
Summary Building a successful and maintainable Java Web application requires the effective use of software frameworks and development tools. WebWork  and  Spring  are excellent frameworks for building scalable and high-quality Java Web applications. Apache Maven  solves many project management issues that programmers have been struggling for a long time.

More Related Content

PPT
Java J2EE
Sandeep Rawat
 
PPTX
Databases in Android Application
Mark Lester Navarro
 
PDF
eServices-Tp2: bpel
Lilia Sfaxi
 
PPT
Spring introduction
Manav Prasad
 
PDF
Enterprise JavaBeans(EJB)
Armen Arzumanyan
 
PPTX
servlet in java
sowfi
 
PDF
Blazor web apps
Rajesh Kolla
 
Java J2EE
Sandeep Rawat
 
Databases in Android Application
Mark Lester Navarro
 
eServices-Tp2: bpel
Lilia Sfaxi
 
Spring introduction
Manav Prasad
 
Enterprise JavaBeans(EJB)
Armen Arzumanyan
 
servlet in java
sowfi
 
Blazor web apps
Rajesh Kolla
 

What's hot (20)

PPTX
Spring boot
Gyanendra Yadav
 
PPTX
An Intro into webpack
Squash Apps Pvt Ltd
 
PPTX
Ef code first
ZealousysDev
 
PDF
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
ENSET, Université Hassan II Casablanca
 
PPTX
Entreprise Java Beans (EJB)
Heithem Abbes
 
PDF
Cours design pattern m youssfi partie 6 proxy
ENSET, Université Hassan II Casablanca
 
PPTX
Java Docs
Pallavi Srivastava
 
PDF
Tp3 - Application SOA avec BPEL
Lilia Sfaxi
 
PPTX
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 
PPTX
Django - Python MVC Framework
Bala Kumar
 
PDF
Spring Boot
koppenolski
 
PDF
OpenESB et BPEL
Lilia Sfaxi
 
PPTX
Java web application development
RitikRathaur
 
PPT
Server Side Technologies
tawi123
 
PDF
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...
ENSET, Université Hassan II Casablanca
 
PDF
Introduction to back-end
Mosaab Ehab
 
PDF
Spring Boot
Jaydeep Kale
 
PPTX
Spring boot
Pradeep Shanmugam
 
PPTX
Document Object Model (DOM)
GOPAL BASAK
 
PPT
J2ee
Prince Soni
 
Spring boot
Gyanendra Yadav
 
An Intro into webpack
Squash Apps Pvt Ltd
 
Ef code first
ZealousysDev
 
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
ENSET, Université Hassan II Casablanca
 
Entreprise Java Beans (EJB)
Heithem Abbes
 
Cours design pattern m youssfi partie 6 proxy
ENSET, Université Hassan II Casablanca
 
Tp3 - Application SOA avec BPEL
Lilia Sfaxi
 
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 
Django - Python MVC Framework
Bala Kumar
 
Spring Boot
koppenolski
 
OpenESB et BPEL
Lilia Sfaxi
 
Java web application development
RitikRathaur
 
Server Side Technologies
tawi123
 
Support de cours EJB 3 version complète Par Mr Youssfi, ENSET, Université Ha...
ENSET, Université Hassan II Casablanca
 
Introduction to back-end
Mosaab Ehab
 
Spring Boot
Jaydeep Kale
 
Spring boot
Pradeep Shanmugam
 
Document Object Model (DOM)
GOPAL BASAK
 
Ad

Viewers also liked (20)

PPT
Web Application Development Fundamentals
Mohammed Makhlouf
 
PDF
Architecture of a Modern Web App
scothis
 
PPT
An Introduction To Java Web Technology
vikram singh
 
PPTX
java Servlet technology
Tanmoy Barman
 
PPT
Java Servlets
BG Java EE Course
 
PPTX
Client server architecture
Bhargav Amin
 
PPT
Java Servlets
Nitin Pai
 
PPT
Basic Web Concepts
Cherry Ann Labandero
 
PPTX
Web application architecture
Tejaswini Deshpande
 
PDF
Fundamentals of Web Development For Non-Developers
Lemi Orhan Ergin
 
PDF
Leverage Hibernate and Spring Features Together
Edureka!
 
KEY
Java web programming
Ching Yi Chan
 
PPTX
Servlets
ZainabNoorGul
 
PPTX
Web Application Architecture
Philip
 
PDF
Web application architecture
Joshua Eckblad
 
PPTX
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
PDF
Yupp PHP Framework
Pablo Pazos
 
PPTX
Core web application development
Bahaa Farouk
 
PPT
Chap 4 hardware & software
UMaine
 
PPTX
Стажировка-2013, разработчики, 15 занятие. Web-фреймворки (1 часть)
7bits
 
Web Application Development Fundamentals
Mohammed Makhlouf
 
Architecture of a Modern Web App
scothis
 
An Introduction To Java Web Technology
vikram singh
 
java Servlet technology
Tanmoy Barman
 
Java Servlets
BG Java EE Course
 
Client server architecture
Bhargav Amin
 
Java Servlets
Nitin Pai
 
Basic Web Concepts
Cherry Ann Labandero
 
Web application architecture
Tejaswini Deshpande
 
Fundamentals of Web Development For Non-Developers
Lemi Orhan Ergin
 
Leverage Hibernate and Spring Features Together
Edureka!
 
Java web programming
Ching Yi Chan
 
Servlets
ZainabNoorGul
 
Web Application Architecture
Philip
 
Web application architecture
Joshua Eckblad
 
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
Yupp PHP Framework
Pablo Pazos
 
Core web application development
Bahaa Farouk
 
Chap 4 hardware & software
UMaine
 
Стажировка-2013, разработчики, 15 занятие. Web-фреймворки (1 часть)
7bits
 
Ad

Similar to Developing Java Web Applications (20)

PPTX
AJppt.pptx
SachinSingh217687
 
PPT
Introduction To Code Igniter
Amzad Hossain
 
PPTX
Front End Development | Introduction
JohnTaieb
 
PDF
Tomcat + other things
Aravindharamanan S
 
PPTX
Project Presentation on Advance Java
Vikas Goyal
 
PPT
Gnizr Architecture (for developers)
hchen1
 
PDF
Spring mvc
Hamid Ghorbani
 
PPTX
Getting Started with J2EE, A Roadmap
Makarand Bhatambarekar
 
PDF
Using HttpWatch Plug-in with Selenium Automation in Java
Sandeep Tol
 
PPT
Programming Server side with Sevlet
backdoor
 
PDF
Google Web Toolkit
Software Park Thailand
 
PPTX
Apache Cordova In Action
Hazem Saleh
 
PPS
Web Component Development with Servlet and JSP Technologies Unit 01
Prashanth Shivakumar
 
PPTX
Spring tutorials
TIB Academy
 
PDF
Beginning MEAN Stack
Rob Davarnia
 
PPTX
Spring Framework
tola99
 
ODP
eXo Platform SEA - Play Framework Introduction
vstorm83
 
DOCX
Month 2 report
PRIYANKA FNU
 
PPTX
Advance Java Topics (J2EE)
slire
 
AJppt.pptx
SachinSingh217687
 
Introduction To Code Igniter
Amzad Hossain
 
Front End Development | Introduction
JohnTaieb
 
Tomcat + other things
Aravindharamanan S
 
Project Presentation on Advance Java
Vikas Goyal
 
Gnizr Architecture (for developers)
hchen1
 
Spring mvc
Hamid Ghorbani
 
Getting Started with J2EE, A Roadmap
Makarand Bhatambarekar
 
Using HttpWatch Plug-in with Selenium Automation in Java
Sandeep Tol
 
Programming Server side with Sevlet
backdoor
 
Google Web Toolkit
Software Park Thailand
 
Apache Cordova In Action
Hazem Saleh
 
Web Component Development with Servlet and JSP Technologies Unit 01
Prashanth Shivakumar
 
Spring tutorials
TIB Academy
 
Beginning MEAN Stack
Rob Davarnia
 
Spring Framework
tola99
 
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Month 2 report
PRIYANKA FNU
 
Advance Java Topics (J2EE)
slire
 

More from hchen1 (13)

PPT
Semantic Web 2.0
hchen1
 
PPT
Semantic HTML
hchen1
 
PPT
Geonames
hchen1
 
PPT
Google Maps API
hchen1
 
PPT
Geospatial Web
hchen1
 
PPT
OpenSearch
hchen1
 
PPT
RSS and Atom in the Social Web
hchen1
 
PPT
An Introduction to Ajax Programming
hchen1
 
PPT
Machine Tags
hchen1
 
PPT
Web 2.0 Mashups
hchen1
 
PPT
Folksonomy and Tagging in the Social Web
hchen1
 
PPT
Inside Gnizr
hchen1
 
PPT
Social Web Technologies
hchen1
 
Semantic Web 2.0
hchen1
 
Semantic HTML
hchen1
 
Geonames
hchen1
 
Google Maps API
hchen1
 
Geospatial Web
hchen1
 
OpenSearch
hchen1
 
RSS and Atom in the Social Web
hchen1
 
An Introduction to Ajax Programming
hchen1
 
Machine Tags
hchen1
 
Web 2.0 Mashups
hchen1
 
Folksonomy and Tagging in the Social Web
hchen1
 
Inside Gnizr
hchen1
 
Social Web Technologies
hchen1
 

Recently uploaded (20)

PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Doc9.....................................
SofiaCollazos
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 

Developing Java Web Applications

  • 1. Developing Java Web Applications Dr. Harry Chen CMSC 491S/691S February 11, 2008
  • 2. Agenda Web application architecture Java Servlet technology WebWork : building webapps made easy Spring : Inversion of Control (IoC) Maven : Java project management and build tool
  • 3. A canonical Web architecture Do you see any technical issues in this architecture? Source: http://www.ibm.com/developerworks/ibm/library/it-booch_web/
  • 4. Stateless communication Communications between your browser and the Web Server is usually stateless “ Cookie” was invented to solve this problem.
  • 5. Thin client vs. Thick (fat) client Where do you place your business logic? Thin client : most of the business logic live on the client side Thick client : application states are managed by the server Thin clients live here. Thick clients live here.
  • 6. How do we create View? Raw data must be processed before it’s presented to the user. Users see the View (HTML, PDF, RSS etc.) Should you “hardwire” code in the business logic to generate Views? Raw data View (HTML, PDF, etc) How will be the Views be generated?
  • 7. Overhead in access data A major part of the application implementation consists of accessing and updating the “raw data” – which can be costly. Reduce this overhead can speed up your development (i.e., save cost) SQL DB HTML Do I have to call “SELECT”, “INSERT”, “UPDATE” all the time?
  • 8. Framework Software engineering is like civil engineering: we need framework. Option 2: Use framework Your Goal Option1: Build everything from scratch…
  • 9. Framework: It’s a juggle out there. http://en.wikipedia.org/wiki/List_of_web_application_frameworks JavaScript Backbase Clean AJAX Dojo Toolkit Echo Ext JQuery Microsoft AJAX Library Mochikit MooTools OpenLink AJAX Toolkit Prototype JavaScript Framework qooxdoo Rialto Toolkit Rico Script.aculo.us SmartClient Spry framework Yahoo! UI Library ASP.NET MonoRail DotNetNuke CSLA ASP.NET MVC Framework Java Apache Cocoon Apache Struts AppFuse Aranea framework Click [ fleXive ] Google Web Toolkit Grails Hamlets ICEfaces IT Mill Toolkit ItsNat JavaServer Faces Java JBoss Seam Makumba OpenLaszlo OpenXava Oracle ADF Reasonable Server Faces RIFE Shale Framework (software) SmartClient Spring Framework Stripes (framework) Tapestry ThinWire WebObjects WebWork Wicket framework ZK Framework ztemplates Perl Catalyst Interchange Maypole Mason PHP Akelos PHP Framework Antares Framework CakePHP Canvas Framework CodeIgniter DIY Framework Drupal epesi FUSE Horde Joomla ! KohanaPHP MODx PHP For Applications PHPOpenbiz PostNuke PRADO Qcodo QPHP Framework Seagull PHP Framework Simplicity PHP framework Symfony ColdFusion ColdBox ColdFusion on Wheels ColdSpring Fusebox Mach-II Model-Glue onTap
  • 11. Java Servlet technology Servlets are Java code that run in a server application (e.g., Tomcat) and answer client request. Source: http://www.informit.com/articles/article.aspx?p=26920
  • 12. HelloWorld Servlet Set HTTP Header: Content-Type (HTML) Creates the HTML page content Implementation that handles HTTP GET request Outputs the HTML into the HTTP Response Do you see any technical issues with this implementation? Source: http://www.informit.com/articles/article.aspx?p=26920
  • 13. JSP (Java Servlet Pages) Technology that allows Java code and certain pre-defined actions to be embedded into static content. Java Servlet: Write code  compile  deploy JSP Write code  deploy
  • 14. HelloWorld JSP Source: http://mainline.brynmawr.edu/~dkumar/JSP/ Use Java as if it’s a scripting language
  • 15. Open issues in Java Servlet technology No mention of any framework or design pattern for building web applications How to handle stateless communication? Use Thin or Thick client? How to access data? How to create Views?
  • 16. MVC: Model-View-Control Java BluePrints developed a recommended design pattern for building Java Servlet applications Goal: help you to design, implement and maintain your Java Web applications http://java.sun.com/blueprints/patterns/MVC-detailed.html
  • 17. Example: J2EE webapp This is what you want to build.
  • 18. Example: J2EE webapp (cont.) This is an MVC solution All DB access and update operations are implemented here. All business logic and applications states are stored here. HTML, PDF and whatever goes here. They read and parse data object from the Model
  • 19. Problems with MVC MVC is only a design pattern – i.e., you still have to write code to follow this specification An obvious problem is that everyone has to learn and write their own MVC framework
  • 21. WebWork A Java MVC framework that help developers to minimize code and to be more concentrated on business logic and modeling. Less “plumbing” code, more “useful” code. http://www.opensymphony.com/webwork/
  • 22. WebWork terminology Action : a piece of code that is executed when a URL is visited Bean : a data object that holds useful application information Views : templates pages for generating outputs for the clients to consume. Result : the output created by a template page
  • 23. WebWork workflow Read: http://www.javaworld.com/javaworld/jw-03-2004/jw-0329-webwork.html
  • 24. WebWork HelloWorld Goal: Go a URL, the webapp outputs “Hello World!” 3 Steps Create an Action class to handle the request Create a View (template) to produce HTML Configure Action and View
  • 25. Action: HelloWorld.java Extends a standard Action superclass. Implement the business logic How to access the Bean (the message)
  • 26. View: helloworld.jsp Use JSP Tag lib to access our Bean (the message) If you don’t like to use JSP, you have other options: Freemarker and Velocity
  • 27. WebWork Configuration: HelloWorld Edit xwork.xml to “glue” the Action with the Template view. Define our Action and name it “helloworld” If the action returns “ success ”, then apply the “ hello.jsp ” template
  • 28. WebWork: HelloWorld Output Read: http://www.javaworld.com/javaworld/jw-10-2005/jw-1010-webwork.html
  • 30. Dynamic object instantiation Often your business logic implementation requires runtime configuration Customer Relationship App may use a different JDBC connection to access a new customer DB Dynamically fine tune how many threads the robot should instantiate for building search index DB Configure the username, password and DB url for your JDBC connection.
  • 31. Inversion of Control (IoC) IoC is a principle that encourage the decoupling of code. A.K.A. Dependency Injection. Problem : The use of “MovieFinderImpl” is hardwired into “MovieLister”. Change this logic will require code rewrite and re-compile “MovieFinderImpl” Read: http://martinfowler.com/articles/injection.html
  • 32. IoC Solution Introduce an intermediate component to handle the assembly of class objects. Solution : If you want to use a different “MovieFinder”, just change how “Assembler” calls <creates>. <creates>
  • 33. Spring IoC A framework that can be coupled with WebWork to provide Dependency Injection. Spring IoC implements a flexible “Assembler”. Developers can tell this “Assembler” how to perform “<create>” via XML configuration. http://static.springframework.org/spring/docs/2.0.x/reference/beans.html
  • 34. Spring IoC: HelloWorld in gnizr How HelloWorld Action is instantiated in gnizr’s HelloWorld demo http://code.google.com/p/gnizr/wiki/HelloWorldDemo
  • 35. Spring IoC: a more complex example (1) The Class object “folderTagListener” is dynamically associated with “bookmarkManager” via a configuration file, not hardwired in the source of “bookmarkManager”. (2) Developers also fine tune the number of WorkerThread to be instantiated by “bookmarkManager” in the same configuration file. (1) (2)
  • 37. Jave project management It concerns the management of library dependency, code building, unit testing, packaging and documentation. Why do you think it’s important to consider those issues when building software? - Can you relate to what you have experienced in the past (in school or at work)?
  • 38. Problems I have faced When some JAR library changed, I have to manually download the JAR from the project web site. Make sure dependency library are included in my CLASSPATH for building and testing Decide the directory layout of my project (where is “src”, “classes”, “resources”). Figure out how to write documentation and call “javadoc” in my project.
  • 39. Apache Maven Maven is an open source Java project management tool that simplifies many of the tedious tasks associated with Java programming. Features I love very much: Library dependency management Build, test, and package Pre-defined directory layout for webapp dev. http://maven.apache.org/
  • 40. POM file In “Make”, we have “Makefile” In “Maven”, we have “POM file” (pom.xml) In this POM file, you can define JAR (version and package names) that should to be included in your build CLASSPATH (dependencies). The layout of your project (where do you keep source, .class, other resources and configuration) Information for generating documentation And many other stuff…
  • 41. Maven: Create a project
  • 44. Try Maven in 5 minutes http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
  • 45. Summary Building a successful and maintainable Java Web application requires the effective use of software frameworks and development tools. WebWork and Spring are excellent frameworks for building scalable and high-quality Java Web applications. Apache Maven solves many project management issues that programmers have been struggling for a long time.