12.11.08 1 Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework.

Slides:



Advertisements
Similar presentations
Struts 2.0.
Advertisements

Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
Struts 2 Interceptors By, Srinivas Reddy.S
Web MVC-2: Apache Struts Rimon Mikhaiel
MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
JBoss Seam: Contextual Components Jason Bechtel
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
2/16/2004 Dynamic Content February 16, /16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.
Tomcat Configuration A Very, Very, Very Brief Overview.
Apache Struts Technology A MVC Framework for Java Web Applications.
Session-02. Index. Jsp in Struts 2 Web.xml File in Struts 2.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
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.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
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.
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.
WebWork in Action An introduction to WebWork Patrick A. Lightbody.
Welcome to Library Management System
1 Introduction to JavaServerFaces & MyFaces Anudeep Jassal.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
Introduction to MVC and the Jakarta Struts Framework By Gyanendra Dwivedi Software Consultant.
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Standalone Java Application vs. Java Web Application
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–
Fall CIS 764 Database Systems Design L8. Web ….
How to Build a Struts Application with JBuilder 9.
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.
Struts 2 introduction. Struts 2 framework Struts 2 A full-featured web application framework for the Java EE platform The Java Servlet API exposes the.
REVOLUTION TO NEXT GENERATION Struts2.0 20/02/ Avishek Arang ::
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar 1 Struts2 Reinventing Struts1 Wheel Ori Dar Consultant and Architect, AlphaCSP.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
Java Annotations. Annotations  Annotations are metadata or data about data. An annotation indicates that the declared element should be processed in.
Struts Framework Day-2 Ashok Chakravarti. DataSource Usage Sample Struts-config.xml …
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Struts 2 Introduction.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
The Chain of Responsibility Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
OOSD Using Java CBTS Framework. 11/2/04CBTS2 Servlet  A servlet is a Java program that can extends Web server’s functionality.  Servlets interact with.
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.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
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.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
An Introduction to and This document is for purely educational purposes.
Struts Zero Configuration Struts University Series.
CS3220 Web and Internet Programming Introduction to Java Servlets
Struts 2 Validation Framework
Unit 6-Chapter 2 Struts.
The Model Layer What is Model?
CS3220 Web and Internet Programming Introduction to Java Servlets
Java Annotations.
Presentation transcript:

Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework

Struts 2 flow (a bird eye view) source: Jakarta Struts: Processing Requests with Action Objects Struts 1.2 Versionwww.coreservlets.com Request …/blah.action Struts.xml

Struts 2 Lifecycle Source:

Struts 2 – Behind the scenes

Struts 2 – Behind the scenes (Cont…) HttpServletRequest – Request goes to servlet container Filters - various filters are applied FilterDispatcher – required filter dispacher is called ActionMapper –dispatcher consults mapper to invoke action or not ActionProxy – control is passed to proxy and it consults configuration manager for appropriate action and settings and then creates invocation ActionInvocation – calls interceptors before calling the Action Interceptors – interceptors do preActions ActionExecution – Action method is called ResultsPreparation – result is rendered depending upon the action method response Interceptors – interceptors are called in reverse order for postActions Filters – response is passed through filters HttpServletResponse – response is given to client

Hello World! One time configuration Web.xml Three steps process Create view (JSP) Create Action Class Map Action and view

Web.xml Placed in WEB-INF folder Struts Example defaultDispatcher org.apache.struts2.dispatcher.FilterDispatcher defaultDispatcher /*

Welcome.jsp Welcome Creating Welcome Page

Welcome.java package example; import com.opensymphony.xwork2.ActionSupport; public class Welcome extends ActionSupport{ private String message = "default String"; public String getMessage() {  return message; } public void setMessage(String message) {  this.message = message; } public String execute() throws Exception {  message = “Hello World! My First App is running";  return SUCCESS; // String SUCCESS = “success” } Creating Welcome Page

Welcome.java Either implement ActionSupport Or extend Action Or neither Do provide execute method Framework will search for execute method through Reflection Default execute method returns SUCCESS Execute is the default entry point for Action class Some return strings constants are already provided SUCCESS=“success” INPUT=“input” NONE=“none” ERROR=“error” LOGIN=“login” SUCCESS is the default return string Also returned by default execute method

Struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" " /jsp/welcome.jsp Creating Welcome Page

welcome.jsp Welcome.java private String message = "default String" ; public String getMessage() { return message; } public void setMessage (String message) { this.message = message; } <action name="Welcome" class="example.Welcome"> url= Welcome Page

Behind the scenes Source:

Struts 2 features Struts Tag Library Wildcard mappings Validation Localization OGNL expression language Interceptors Dynamic Method Invocation Profiling Debugging Annotations Type Conversion Result Types Dependency Injection Development Mode

Struts Tag Library Welcome Creating Login Page Login.jsp

Struts Tag Library package example; import com.opensymphony.xwork2.*; public class Login extends ActionSupport { private String username = "default"; private String password = ""; private String errorMessage = ""; public String getUsername() { return username; } public void setUsername (String username) { this.username = username;} public String getPassword () { return password;} public String getErrorMessage () { return errorMessage; } public void setErrorMessage (String errorMessage) {this.errorMessage = errorMessage;} public void setPassword (String password) {this.password = password;} public String execute () throws Exception { if (isValid(getUsername()) && isValid(getPassword())){ return SUCCESS;} errorMessage = "invalid input"; return "inputError"; } public boolean isValid(String field){ return field.length()!=0?true:false; } Creating Login Page Login.java

Struts Tag Library <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" " /jsp/success.jsp /jsp/login.jsp /jsp/welcome.jsp Creating Welcome Page Struts.xml

Struts Tag Library Welcome s:property value="message"/> ">Login value1 Welcome Adding links for Login Page welcome.jsp

Wildcard mappings Provides generic mappings GuestLogin and PremierLogin can both be mapped to *Login Calls EditUser & EditRegistration for /editUser & /editRegistration respectively Returns /jsp/User.jsp & /jsp/Registration.jsp respectively

Validation Define configuration file *-validation.xml or use annotations className-validation.xml Place in the directory where.class file is placed example.Login should have Login-validation.xml <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" " Username is required Password is required

Localization Get message from resource bundles Generalizes the messages Reusable messages Create.properties file for specific class and place in the class path Create package.properties file for specific package Searches for properties file in order ActionClass.properties BaseClass.properties Interface.properties (every interface and sub-interface) ModelDriven's model (if implements ModelDriven), for the model object repeat from 1 package.properties (of the directory where class is located and every parent directory all the way to the root directory) search up the i18n message key hierarchy itself global resource properties

Localization user.required=User Name is required password.required=Password is required Login.properties Login-validation.xml

Localization cont… Use either of for accessing properties from JSP or Java file The Default Message That Will Be Displayed

Interceptors Can execute code before and after execution Are thread-safe Can be used for Validation Pre populating fields Double-submit prevention Session control Authentication Type conversion