Jakarta Struts Presented by Object Computing, Inc. (OCI) Written by Greg Elliott

Slides:



Advertisements
Similar presentations
JSP and web applications
Advertisements

Struts 2.0.
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
Web MVC-2: Apache Struts Rimon Mikhaiel
MVC Frameworks Alternatives to coding the MVC pattern.
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Apache Struts Technology A MVC Framework for Java Web Applications.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Building an application … with Struts! Presented by Ted Husted [ ]
Struts 2.0 an Overview ( )
Introduction to Struts 2.0 Jenny Ni Joey Feng Winddays Wang Hewmmi Zhu Heather Lv Software School,Fudan University 1.
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
Struts:The good, the bad, the ugly A detailed evaluation of Struts 1.1 and Enterprise Web Applications. By Paul Smith Ancept, Inc. (
Michael Rimov Centerline Computers Craig McClanahan Sun Microsystems O’Reilly Open Source Convention July , 2003.
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
Java Frameworks Indy Java Users Group January 29, 2003.
JSP Standard Tag Library
Author: DoanNX Version 2.0/Time: 30’. The ways to solve it There are 2 main ways:  Client-side: Using JavaScript (now one very good option is JQuery).
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Introduction to MVC and the Jakarta Struts Framework By Gyanendra Dwivedi Software Consultant.
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
Fall CIS 764 Database Systems Design L8. Web ….
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
BOF # The Struts Framework Community The Struts Framework Community Craig McClanahan.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
J2EE Struts 1 3 Struts: Introduction 1 4 Once you’ve coded a lot of JSP applications, you find yourself doing a lot of repetitive things. Also,
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Apache Struts. J2EE Web Application using MVC design pattern Why MVC? Separate components = easier maintenance – Model component holds object data – View.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
13 Copyright © 2004, Oracle. All rights reserved. Adding Validation and Error Handling.
11 Copyright © 2004, Oracle. All rights reserved. Customizing Actions.
Struts Framework Day-2 Ashok Chakravarti. DataSource Usage Sample Struts-config.xml …
Implementation Struts Framework for well-architectured web applications Model-View-Controller design pattern.
JavaServer Faces framework Craig McClanahan is presented that created Struts web framework and based on experience gathered designed JavaServer.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
Apache Struts Technology A MVC Framework for Java Web Applications.
Model View Controller. MVC is the separation of model, view and controller. It's simply a paradigm; an ideal that you should have in the back of your.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
V Web Tier Architecture MVC and Struts. v First, there were servlets And things were good Faster than CGI programs More scalable with built-in.
Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Introduction to Jakarta Struts Framework Try NCCU Computer Center Mar 20,2002.
Controlling an Application with Struts
Knowledge Byte In this section, you will learn about:
Unit 6-Chapter 2 Struts.
Introduction to Struts
The Model Layer What is Model?
JavaServer Faces: The Fundamentals
Struts BY: Tejashri Udavant..
Presentation transcript:

Jakarta Struts Presented by Object Computing, Inc. (OCI) Written by Greg Elliott

Jakarta Struts2 What is Struts? An open source development framework for building web applications Based on Model-View-Controller (MVC) design paradigm Implementation of JSP Model 2 Architecture Created by Craig McClanahan and donated to Apache Software Foundation (ASF) in nd release candidate of version 1.1 released Consists of 8 Top-Level Packages Approximately 250 Classes and Interfaces

Jakarta Struts3 Alternatives to Struts No framework (use straight JSP) Build your own framework Webwork Expresso Barracuda Cocoon SiteMesh Freemarker, Velocity and WebMacro XML/XSLT ???

Jakarta Struts4 Why consider Struts? Developed by industry experts Stable & Mature Manageable learning curve Open source Probably similar to what you would build if you weren’t going to use Struts Good documentation – both javadoc api as well as numerous books on topic Feature-rich Supported by many 3 rd party tools Flexible and extendable

Jakarta Struts5 Struts Framework Features Model 2 – MVC Implementation Internationalization support Rich JSP tag libraries Based on JSP, Servlet, XML and Java Supports different model implementations (JavaBeans, EJB, OJB, etc.) Supports different presentation implementations (JSP, XML/XSLT, etc.)

Jakarta Struts6 Struts Dependencies Java 1.2 or newer Servlet 2.2 and JSP 1.1 container XML parser compliant with JAXP 1.1 or newer (ie, Xerces) Jakarta Commons packages JDBC 2.0 optional package

Jakarta Struts7 Logical Architecture

Jakarta Struts8 Aspects of the Framework Controller Model View Configuration issues

Jakarta Struts9 Controller Components

Jakarta Struts10 Controller Components ActionServlet – (provided by the Framework) RequestProcessor – (provided by the Framework) Action Classes – (You build these)

Jakarta Struts11 The ActionServlet and RequestProcessor Receive the HttpServletRequest Automatically populate a JavaBean (ActionForm) from the request parameters Handle Locale and Content Type Issues Based on the URI, select the appropriate Action to handle the request

Jakarta Struts12 ActionServlet and RequestProcessor

Jakarta Struts13 The Action Class Extends org.apache.struts.action.Action Override the execute() method Bridge between the user-invoked URI and the business method residing in the Model class (Command pattern) Based on success/failure of processing in Model, determines which view should be rendered next Actually part of the Controller, not the Model

Jakarta Struts14 Action Class Diagram

Jakarta Struts15 Action Class Example import javax.servlet.http.*; import org.apache.struts.action.*; import example.model.*; public class TransformTextAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { TransformForm myForm = (TransformForm) form; String inputText = myForm.getInputText(); Integer transformType = myForm.getTransformType(); String resultText = TransformModel.transformText(inputText, transformType); myForm.reset(); request.setAttribute("resultText", resultText); // Forward control to the specified success URI return mapping.findForward("continue"); }

Jakarta Struts16 The Model Components

Jakarta Struts17 Struts Model Components No model components provided Any component model supported by Struts (JavaBeans, EJB, CORBA, JDO, OJB, etc.) Should always attempt to maintain a clean separation from Action and Model

Jakarta Struts18 Model Class Example package example.model; public class TransformModel { public static String transformText(String origText, Integer transType) { String rc = origText; switch(transType.intValue()) { case TransformerConstants.TO_UPPER: rc = origText.toUpperCase(); break; case TransformerConstants.TO_LOWER: rc = origText.toLowerCase(); break; } return rc; }

Jakarta Struts19 Model Class Example (cont.) package example.model; public class TransformerConstants { public static final int TO_UPPER = 0; public static final int TO_LOWER = 1; public static final int CAP_EACH_WORD = 2; public static final int SENTENCE_FORM = 3; }

Jakarta Struts20 The View Components

Jakarta Struts21 The View Components Java Server Pages HTML JavaScript and Stylesheets Multimedia Files Resource Bundles JavaBeans (Value Objects populated by Model components) JSP Custom Tags ActionForms

Jakarta Struts22 Struts JSP Tag Libraries HTML Bean Logic Nested Tiles Template

Jakarta Struts23 HTML Tag Library Tags used to create Struts input forms Examples include checkbox, image, link, submit, text, and text area

Jakarta Struts24 Bean Tag Library Tags used for accessing JavaBeans and their properties Examples include define, message, write

Jakarta Struts25 Logic Tag Library Managing conditional generation of output text Looping over objects in a collection for repetitive generation of output text Application flow management Examples include empty, lessThan, greaterThan, redirect, iterate

Jakarta Struts26 Bean, Logic, HTML Tag Example Text Transformer <html:form name="transformForm" type="TransformForm" action="transformer.do"> Please enter the text you would like tranformed: Please select the type of transformation to be performed: UPPER lower

Jakarta Struts27 Sample Application

Jakarta Struts28 Sample Application (cont.)

Jakarta Struts29 Sample Application (cont.)

Jakarta Struts30 The ActionForm Java class that extends org.apache.struts.action.ActionForm Captures user data from the HttpRequest Stores data temporarily Acts as a boundary/go-between between the View and the Controller Provides ability to validate the user input

Jakarta Struts31 ActionForm Example public class TransformForm extends org.apache.struts.action.ActionForm { private String inputText; private Integer transformType; public void setInputText(String aInputText) { inputText = aInputText; } public String getInputText() { return inputText; } public void setTransformType(Integer aTransformType) { transformType = aTransformType; } public Integer getTransformType() { return transformType; } public void reset() { inputText = ""; transformType = null; }

Jakarta Struts32 ActionForm Sequence of Events

Jakarta Struts33 ActionError and ActionMessage Used to signify general purpose informational and error messages Rely on the ResourceBundles JSP Tags have access to them

Jakarta Struts34 ActionError and ActionMessage Example

Jakarta Struts35 Configuring a Struts Application Create/edit the web application deployment descriptor (web.xml) Create/edit the struts-config.xml file Other configuration files as necessary (tiles, validator, etc.)

Jakarta Struts36 Configuring the web.xml File Add the servlet element Configure servlet-mapping element Add taglib elements

Jakarta Struts37 Sample web.xml action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 2 detail 2 2 action *.do

Jakarta Struts38 Sample web.xml (cont.) transformer.jsp /tags/struts-bean /WEB-INF/struts-bean.tld /tags/struts-html /WEB-INF/struts-html.tld /tags/struts-logic /WEB-INF/struts-logic.tld

Jakarta Struts39 The struts-config.xml File Uses xml Defines the set of “rules” governing a particular Struts application As of 1.1, can have multiple configuration files (acting as subordinates to master config file) Gets parsed and loaded into memory at startup Elements include: –Action mappings –Form bean definitions –Static parts: controller attributes, message resources, plug-in information, and data source definitions

Jakarta Struts40 struts-config.xml Example <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" " <form-bean name="transformForm" type="TransformForm"/> <action path="/transformer" type="TransformTextAction" name="transformForm" scope="request" input="transformer.do"> <forward name="continue" path="/transformer.jsp"/>

Jakarta Struts41 Internationalization Support Much of the framework’s functionality is based on java.util.Locale Struts uses Java ResourceBundles The support from the JDK for normal I18N issues can still be used in a Struts application (date/time formatting, currency formatting/converting, color conventions, etc.)

Jakarta Struts42 Packaging and Deployment Package as you would any other web application (Web ARchive = WAR file) Deploy to any Servlet 2.2/JSP 1.1 compliant container

Jakarta Struts43 What to watch for in the future Incorporation/closer integration/replacement of Struts tag libraries with those from JSTL Java Server Faces – new form of View, allowing more custom component creation on server prior to showing to user

Jakarta Struts44 Struts Resources Struts home page ( Struts user and mailing lists