• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Struts Ppt 1

on

  • 23,737 views

 

Statistics

Views

Total Views
23,737
Views on SlideShare
23,682
Embed Views
55

Actions

Likes
17
Downloads
0
Comments
1

2 Embeds 55

http://www.slideshare.net 54
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Struts Ppt 1 Struts Ppt 1 Presentation Transcript

  • STRUTS Jaya Prakash...
  • Struts Agenda
    • Software Crises
    • What is Framework
    • Model1,Model2
    • What is Struts
    • Why we need it
    • Why is it called as Struts
    • Advantages of Struts
    • Terminology of Struts
    • Architecture of Struts
    • Controller Elements & it’s Responsibilities
    • Model Elements & it’s Responsibilities
    • View Elements & it’s
    • Responsibilities
    • Struts sequence diagram
    • I18n
    • Disadvantages
  • Challenges Exist In Software Development & Software Crisis
    • Projects must be developed Quickly.
    • Projects must be in High-Quality.
    • Application Stability.
    • Better code Maintainability.
    • Lower Cost for Developing Application.
    • To solve above Challenges
    • The Software Development Community Introduced Frameworks to Guide Development.
    * Time shown with out day light savings
  • What is Framework
    • A software framework is a re-usable design for a software system (or subsystem).
    • A framework is a pre-built assembly of components and is designed to be extended.
    • It is also base for components.
  • Advantages of Framework
    • Provide a procedure for the development of Application.
    • Saves developers Time.
    • Provides same approach for all developers for developing code and Consistency in Software Design
    • Provide low-level services that developers can use to speedup development.
    • It also reduces software development and maintenance costs.
    • Most of the frameworks follow Model1,Model2
  • Model 1
    • In the Model 1 the JSP page is responsible for processing the incoming request and replying back to the client.
  • Disadvantages of Model1
    • It does not have separate controller
    • This Architecture usually leads to a significant amount of Java code embedded within the JSP page
    • Model 1 architecture is suitable for applications that have very simple page flow, have little need for centralized and change little over time.
    Developers Designers JSP
    • Developers and designers must work on the same files!
  • Model 2
    • This Model2 approach combines the use of both servlets and JSP, using JSP to generate the presentation layer and servlets to perform process-intensive tasks.
    • Model2 architecture introduces a Servlet between the browser and the JSP pages.
    • The servlet acts as the controller and is in charge of the request processing and the creation of any beans or objects used by the JSP, as well as deciding, depending on the user's actions, which JSP page to forward the request to.
  • Model2 Advantages
    • No processing/business logic within the JSP page.
    • Model 2 applications are easier to maintain and extend, because views do not refer to each other directly.
    • The Model 2 controller servlet provides a single point of control for security and often encapsulates incoming data into a form usable by the back-end MVC model.
    • It also Provides unique responsibility to each component and each is independent of the other component .
    • Change in one component will have no or less impact on other components.
  • Model 2 Components and Responsibilities
    • Model
      • The Model portion of an MVC-based System responsible for internal state of the system, and actions that can be taken to change that state
      • Decide “ How to do ”
      • Controller
      • -Decide “ What to do ”
      • -The Controller portion of the application is focused on receiving requests from the client ,deciding what business logic is to be performed ,and then delegating responsibility for producing the next phase of user interface to an appropriate View Component
      • View
      • Presentation
  • What is Struts
    • An open source web application framework based on j2ee and java which implements the MVC design pattern is called Struts.
    • Why is it called as Struts
    • Strut synonym is Iron-rod.
  • Why we use and what are the advantages of Struts
    • It is open source.
    • Provides components for building Web Applications that speedup development and saves time for developers.
    • It makes complex applications into simple.
    • Built in Exception Handling
    • I18n support with resource bundles.
    • Built in validation framework.
    • It also have tiles framework (A template mechanism incorporated into struts for managing page layouts.)
  • Struts Architecture
  • Struts Framework Components
    • Controller Components - Direct the Action
    • Model Components - Access Data and Systems
    • View Components - What the users see
  • Struts Controller Components
    • Struts-config.xml
  • Actionservlet and Requestprocessor
    • Receive the HttpServletRequest
    • Automatically populate a JavaBean from the request parameters.
    • Handle Locale Issues
    • Determine which Action to invoke based on URI
    • Extends javax.servlet.http.HttpServlet
    • Receives all framework requests
    • Selects proper application module
    • Delegates request handling to the RequestProcessor instance
    • One ActionServlet instance per web application
    • Default implementation provided by Framework
  • Actionservlet and Requestprocessor
    • ActionServlet dispatch request to Request Processor(New from 1.1. previous this behaviour was in Action servlet)
    • The work of Request Processor is:-
      • Finding ActionMapping.
      • Mapping Action to FormBean.
      • Creating FormBean Object.
      • Calling reset() method of FormBean
      • Calling Validator of FormBean
      • If no form(jsp/html) validation errors calls execute method in Action Class and finding response to request.
      • If Errors give the errors on jsp present in input attribute of Action tag in struts-config.xml.
  • What is An Action Class
    • Extends org.apache.struts.action.Action
    • Overrides the execute() method
    • Acts as a bridge between user-invoked URI and a business method
    • Return information about which view should be rendered next
    • Part of the Controller ,not the Model
            • Actionclass Example
  • Struts-Config.xml
    • The power and flexibility of struts is due to the extracting of configuration information from across frame work.
    • Configuration file contains action mappings (determines navigation)
    • Controller uses mappings to turn HTTP requests into application actions
    • Mapping must specify
      • A request path
      • Object type to act upon the request
    • Tags in this file are:-
      • Data Sources.
      • Form Beans.
      • Global Exceptions.
      • Global Forwards
      • Actions
      • Controller
      • Message resources
      • Plug-in
      • Struts- Config.xml Example
  • The Model Components
    • Model Components
      • Java classes
      • middle tier components (EJB, Javabeans, …)
      • database access components
      • Used to represent the Internal state of the system
      • Actions that can change that state
    • Internal state of system represented by
      • JavaBeans
      • Enterprise JavaBeans
  • Action Form
      • Extends the ActionForm class
      • Create one for each input form in the application
      • It is just like a java bean, Store data temporary, reset default values to views, validate input view.
      • Hold state and behavior for user input.
      • If defined in the ActionMapping configuration file, the Controller Servlet will perform the following:-
        • Check for instance of bean of appropriate class
        • If no bean exists, one is created automatically
        • For every request parameter whose name corresponds to the name of a property in the bean, the corresponding setter method will be called
        • The updated ActionForm bean will be passed to the Action Class execute () method when it is called, making these values immediately available.
        • ActionForm Example
  • The View Components
  • Struts JSP Tag Libraries
    • HTML
    • Bean
    • Logic
    • Nested
    • Tiles
    • Template
  • Html Tag & Bean Tag Libraries
    • Tags used to create Struts input forms
    • Examples (checkbox,image,
    • link, submit ,text, text area)
    • Tags used for accessing JavaBeans and their properties
    • Examples (Define,message,write)
  • Logic ,Tiles & Nested Tag Libraries
    • Managing conditional generation of output text
    • Looping over object Collections for repetitive generation of output text
    • Example (empty,lessThan,
    • greaterThan)
    • Extended the base struts tags to allow them to relate to each other in nested nature
    • Tiles tags
    • Each part ("Tile") of webpage can be reused as often as needed throughout your application. This reduces the amount of markup that needs to be maintained and makes it easier to change the look and feel of a website.
  • Template Tag Library
    • The "struts-template" tag library contains tags that are useful in creating dynamic JSP templates for pages which share a common format. These templates are best used when it is likely that a layout shared by several pages in your application will change. The functionality provided by these tags is similar to what can be achieved using standard JSP include directive , but are dynamic rather than static.
    • Note: As of Struts 1.1 the template library has been deprecated
  • Action Message & Action Error
    • Used to signify general purpose informational and error messages
    • Rely on the resource bundles
    • JSP Tags can access them
      • </html:errors>
  • Internationalization Support
    • Much of the framework functionality based on java.util.Locale
    • Struts Uses Java Resource Bundles .
    • Ex:-
      • Date ,Time and Currency Formatting
      • Currency Conversion
    • Resource Bundle Example
  • Other Features Suported by Struts Framework
    • Multi-Module Support
    • Declarative Exception-Handling
    • Dynamic Action Forms
    • Plugins
    • Tiles integrated With Core
    • Validator Integrated With Core
  • Struts Sequence Diagram
  • Struts Example
    • 0.167.192.116login_app
    • Webapps|
    • |sample(Application Name)
    • |__ login.jsp
    • |__newLogin.Jsp
    • |__success.jsp
    • |__WEB-INF
    • |__web.xml
    • |__Struts-config.xml
    • |__*.tld  All the struts tld files
    • |__lib
    • |__*.jar  All the jar files
    • |__classes
    • |__LoginAction,LoginForm,
            • Messageresorces
  • Disadvantages
    • Bigger Learning Curve
    • Not Based on Domain Model
    • Property Names
    • Views are restricted .
  • Questions & Answers QUESTIONS & ANSWERS What did I Miss?
  • Thank u mail me:-jayaprakash.m.java@gmail.com