Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

Struts Tutorial
Struts Introduction
Struts Controller
Struts Action Class
Struts ActionForm Class
Struts HTML Tags
Struts Validator Framework
Struts ClientSide Address Valiadation
Struts Tiles
Using tiles-defs.xml
Dynamic Action Form
Struts File Upload
Struts Database Connection

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


Introduction to Struts
Previous Next


  • For creating Java web application,Apache Struts is used which is a free open-source framework


  • The framework provide three key components which are as follows:
    • A "request" handler is provided by the application developer that is mapped to the standard URI .

    • A "response" handler which is responsible to transfer control to another resource which completes the response.

    • A tag library is used to help developer create interactive form-based applications with server pages.




    What is Struts?

    Model-View-Controller (MVC) design pattern is used by Struts Framework which is the implementation of the JSP. Struts is open source and is also maintained as a part of Apache Jakarta project. Struts Framework is well suited for application of any size.




    Major Versions of Struts

    Two major versions of Struts framework is offered by the Apache Struts Project. For the Java,Struts 1 is recognized as the most popular web application framework. The struts 1.x framework is the mature, well-documented, and widely supported. Struts 1 is the best choice for the teams who value proven solutions to common problems.

    Other name of Struts 2 was WebWork 2. The WebWork and the Struts communities joined forces to create Struts 2 after working independently for several years. For teams who value elegant solutions to difficult problems,the new framework is best choice .

    In the fourth quarter of the 2006,a stable release of Struts 2 is expected . A BETA release is also available now.




    The Six Basic Steps in Using Jakara Struts

    1. Modify struts-config.xml.

      In addition to forward and action elements used to specify the destination URLs and Action object, we use the form-bean element to declare form beans. We also add the scope and name attributes to the action element to tie the form bean to the Action. Optionally, to declare a properties file containing the standard messages, names, and labels,we add a message-resources element .



    2. Define a form bean.

      This bean has the properties (i.e., getter and setter methods) corresponding to each of the incoming request parameters and normally extends ActionForm and . Alternatively,in which case it will contain a Map representing the request parameters, the bean can extend the DynaActionForm.



    3. Create results beans.

      These are normal beans of which is used in MVC when implemented directly with RequestDispatcher. That is, they represent the data access code and results of the business logic. These beans are stored in request, session, or application scope with the use of setAttribute method of HttpServletRequest, HttpSession, or ServletContext, just as in the normal non-Struts applications.



    4. Create an Action object to handle requests.

      Rather than calling request.getParameter explicitly as in the previous example, we can use the execute method casts the ActionForm argument to the specific form bean class, then uses getter methods to access the properties of the object.



    5. Create form that invokes blah.do.

      This form can use the bean:message tag to output text labels and standard messages that are defined in the properties file that is declared with the message-resources in struts-config.xml



    6. Display results in JSP.

      The JSP page uses the bean:write tag to output properties of the result bean and form bean . It may also use the bean:message tag to output text labels and standard messages that are defined in standard properties file.




    Advantages of Using Struts

    • Centralized File-Based Configuration.

      Rather than hard-coding information into Java programs, many Struts values are represented in the property or XML files. This loose coupling means that many changes can be made without recompiling or modifying the Java code, and that wholesale changes can be made by editing a single file. This approach also lets Web developers and Java focus on their specific tasks (implementing business logic, presenting certain values to clients, etc.) without needing to know about overall system layout.



    • Form Beans.

      In JSP,To automatically populate a JavaBean component based on the incoming request parameters, you can use property="*" with jsp:setProperty . Unfortunately, however, in the standard API this capability is unavailable to the servlets, even though with MVC it is really servlets, not JSP pages, that should usually be the target of form submissions. Apache Struts extends this capability to Java code and adds in several useful utilities, all of which serve to greatly simplify the processing of the request parameters.



    • Bean Tags.

      Apache Struts provides a set of custom JSP tags (bean:write, in particular) that let you easily output the properties of JavaBeans component. Basically, these are concise and powerful variations of standard jsp:useBean and jsp:getProperty tags.



    • HTML Tags.

      Apache Struts provides a set of custom JSP tags to create HTML forms that are associated with the JavaBeans components. This bean/form association serves two useful purpose:

      • It lets you get initial form-field values from the Java objects.
      • It lets you to redisplay forms with some or all previously entered values intact.


    • Form Field Validation.

      Apache Struts has builtin capabilities for checking that form values are in required format. If values are missing or in an improper format, the form can be automatically redisplayed with the error messages and with the previously entered values maintained.
          This validation can be performed on server (in Java), or both on server and on client (in JavaScript).



    • Consistent Approach.

      Struts encourages consistent use of MVC throughout of your application




    Disadvantages of Using Struts

    • Bigger Learning Curve.

      To use MVC with the standard RequestDispatcher, you need to be comfortable with the standard JSP and servlet API and a large and elaborate framework that is almost equal in size to the core system. This drawback is especially significant with smaller project, near-term deadlines, and less experienced developers; you could spend as much time learning Struts as building your actual system.



    • Worse Documentation.

      Compared to the standard servlets and JSP APIs, Struts has fewer online resources, and many first-time users find the online Apache documentation confusing and poorly organized. There are also fewer books on the Apache Struts than on standard servlets and JSP.



    • Less Transparent.

      With Struts applications, there is a lot more going on behind scenes than with normal Java-based Web applications. As a result, Struts applications always are:

      • Harder to benchmark and optimize
      • Harder to understand


    • Rigid Approach.

      The flip side of the benefit that Struts encourages a consistent approach to MVC is that Struts makes it difficult to use other approaches.




    What You Should Already Know

    Before you goes to this tutorial you should have a basic understanding of the following:

    • HTML
    • A basic understanding of JAVA
    • JSP
    • Servlets
    • JDBC
    • Custom Tags

    If you are going to study these subjects first, find the tutorial on our Home page




    Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
    • blinkbits
    • BlinkList
    • blogmarks
    • co.mments
    • connotea
    • del.icio.us
    • De.lirio.us
    • digg
    • Fark
    • feedmelinks
    • Furl
    • LinkaGoGo
    • Ma.gnolia
    • NewsVine
    • Netvouz
    • RawSugar
    • Reddit
    • scuttle
    • Shadows
    • Simpy
    • Smarking
    • Spurl
    • TailRank
    • Wists
    • YahooMyWeb

    Previous Next

    Keywords: jakarta struts jsp, web applications, struts 1.1,programming jakarta struts,java struts,struts tutorial


    HTML Quizes
    HTML Quiz
    XHTML Quiz
    CSS Quiz
    TCP/IP Quiz
    XML Quizes
    XML Quiz
    XSL Quiz
    XSLT Quiz
    DTD Quiz
    Schema Quiz
    XForms Quiz
    XSL-FO Quiz
    XML DOM Quiz
    XLink Quiz
    XQuery Quiz
    XPath Quiz
    XPointer Quiz
    RDF Quiz
    SOAP Quiz
    WSDL Quiz
    RSS Quiz
    WAP Quiz
    Web Services Quiz
    Browser Scripting Quizes
    JavaScript Quiz
    VBScript Quiz
    AJAX Quiz
    DHTML Quiz
    HTML DOM Quiz
    WMLScript Quiz
    E4X Quiz
    Server Scripting Quizes
    ASP Quiz
    PHP Quiz
    PERL Quiz
    SQL Quiz
    ADO Quiz
    .NET (dotnet) Quizes
    Microsoft.Net Quiz
    XML Web Services Quiz
    ASP.Net Quiz
    .Net Mobile Quiz
    C# : C Sharp Quiz
    ADO.NET Quiz
    VB.NET Quiz
    Multimedia Quizes
    SVG Quiz
    Flash Quiz
    Media Quiz
    SMIL Quiz
    Web Building  Quizes
    Web Browsers Quiz
    Web Hosting Quiz
    W3C Quiz
    Web Building Quiz
    Web Quality Quiz
    Web Semantic Quiz
    Web Careers Quiz
    Java Quizes
    Java Quiz
    JSP Quiz
    Servlets Quiz
    Struts Quiz
    EJB Quiz
    JMS Quiz
    JMX Quiz
    Programming Langauges Quizes
    C Quiz
    C++ Quiz
    Visual Basic Quiz
    Data Structures Using C Quiz
    Soft Skills Quizes
    Communication Skills Quiz
    Time Management Quiz
    Project Management Quiz
    Team Work Quiz
    Leadership Skills Quiz
    Corporate Communication Quiz
    Negotiation Skills Quiz

    Privacy Policy
    Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.