Web MVC-2: Apache Struts Rimon Mikhaiel

Slides:



Advertisements
Similar presentations
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Advertisements

Apache Struts Technology
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
An introduction to Java Servlet Programming
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
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.
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
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.
Julien Thibault / Phil Brewster / Kristina Doing-Harris
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Java Servlets and JSP.
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.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.
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.
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.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Welcome to Library Management System
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework.
Jakarta Struts Presented by Object Computing, Inc. (OCI) Written by Greg Elliott
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 ….
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
How to Build a Struts Application with JBuilder 9.
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 ::
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
Model View Controller Architecture of Java Web Applications Dr. M V S Peri Sastry, Ph.D.[BITS-Pilani]
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.
JSP Custom Tags. Prerequisites Servlet API Mapping to JSP implicit objects JavaServer Pages Basic syntax Implementation via servlet API XML.
Java Servlets and Java Server Pages Norman White Stern School of Business.
© 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.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java Servlets and Java Server Pages
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
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.
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.
Ashley Montebello Katie Githens Wayne Rowcliffe. Project Overview Create graduate student review system for ECpE department Review system is used by students.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
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.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
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.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Unit 6-Chapter 2 Struts.
Introduction to Struts
Java Servlets and JSP.
Struts BY: Tejashri Udavant..
Presentation transcript:

Web MVC-2: Apache Struts Rimon Mikhaiel

Agenda Drawbacks with Web Model 1 Web Model 2 (Web MVC) Struts framework Example of workflow management. A Hello World Example

Web Model 1 In a standard J2EE web application: The client will typically submit information to the server via an HTTP request. The information is then handed over to a Servlet or a JSP which processes it, interacts with a database and produces an HTML- formatted response. This approaches is often considered inadequate for large projects because they mix application logic with presentation and make maintenance difficult.

Web Model 2 Web MVC Model: is responsible for: Providing the data from the database and saving the data into the data store. All the business logic are implemented in the Model. Data entered by the user through View are check in the model before saving into the database. Data access, Data validation and the data saving logic are part of Model. View: is responsible for: Taking the input from the user, Dispatching the request to the controller, and then Receiving response from the controller and displaying the result to the user. HTML, JSPs, Custom Tag Libraries and Resources files are the part of view component. Controller: is intermediary between Model and View; is responsible for: Receiving the request from client. Executing the appropriate business logic from the Model, and then Producing the output to the user using the View component. ActionServlet, Action, ActionForm and struts-config.xml are the part of Controller.

MVC Frameworks J2EE: Struts Spring MVC PHP CakePHP Strusts4php C#.NET Girders Ruby on Rails

Struts Framework Apache open source web application framework (it is free). Base on Model 2 MVC architecture. Supports J2EE web application “ Write once, Run Anywhere ” Supports different model implementation (Javabeans, EJB, etc.) Extends the Java Servlet API. Supports different presentation implementation (JSP, XML/XSLT, JSF). Supports internationalization (I18N). Enable Multi-language applications Supports application wide standard (error) message.

The struts architecture <action path="/login" type= “ com.myproject.action.LoginAction" > class LoginForm extends ActionForm { String username,password; public String getUsername(){ return username; } public void setUsername(String username){ this.username=username; } public String getPassword(){ return password; } public void setPassword(String password){ this.password=password; }

Working with Struts From strut ’ s official download page : From the recent release, download Struts2-blank.war Rename Struts2-blank.war to YourProjectName.war (say MyStruts.war ) Make sure that your tomcat is up and running. Copy MyStruts.war under ~/catalina/webapps/ the war file will be automatically extract itself under the same directory ( ~/catalina/webapps/MyStruts ). Restart your tomcat. Test your Struts application through: YourProjectName ( You should see the following screen:

Struts application structure MyStruts |-- META-INF |-- WEB-INF (jars, classes, and configurations) |-- example (jsp files) (optional) `-- index.html (front page) (optional) MyStruts/WEB-INF/classes |-- example (package example, you can find the source under ‘ MyStruts/WEB- INF/src/java/example/ ’ ) | |-- ExampleSupport.class | |-- HelloWorld.class | |-- Login-validation.xml | |-- Login.class | |-- package.properties | `-- package_es.properties |-- example.xml `-- struts.xml

Hello World (JSP page) Create a directory: ~/catalina/webapps/MyStruts/jsps Under the above directory, create the following HelloWorld.jsp Hello World!

Hello World (Action) package c410; import com.opensymphony.xwork2.ActionSupport; public class HelloWorld extends ActionSupport { public static final String MESSAGE = "Struts is up and running..."; private String message; public String execute() throws Exception { setMessage(MESSAGE); return SUCCESS; } public void setMessage(String message){ this.message = message; } public String getMessage() { return message; } - Create a directory ~/catalina/webapps/MyStruts/WEB- INF/src/c410 to store your java source code for a package “ c410 ” - Create HelloWorld.java under the above directory. - While being under the above directory, compile source code using: javac -classpath "../../lib/xwork jar" HelloWorld.java - Create a directory ~/catalina/webapps/MyStruts/WEB- INF/classes/c410 and copy the generate HelloWorld.class under this directory -

Hello World (Mapping) Modify ~/catalina/webapps/MyStruts/WEB-INF/classes/struts.xml to look like: <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" " /jsps/HelloWorld.jsp

Run HelloWorld You can run it through ort/MyStruts/HelloWorld.action You should get something like the following screen ort/MyStruts/HelloWorld.action

Exercise for next class Implement a simple bi-lingual (e.g. English, French, Spanish, etc) login screen: Validate that both user-name and password are given When user-name/password are given you display a message “ This page is under construction ” When the user clicks on “ Sign On ”, you display the same message “ This page is under construction ”

References Struts Offical Home Page Apache Struts2 Documentation: Bootstrap Apache Struts2 Documentation: Bootstrap Struts Guide What is Struts?