4) . Inner Communication in Struts

>> Friday, May 29, 2009



The communication between files or modules.

1. Action Servlet
2. JSP's
3. Web.xml
4. ActionBeans / FormBean
5. ActionClass
6. ActionForward
7. Struts Configuration file




1. ActionServlet : Builtin controller servlet of struts based web application this converts integration logic generated by framework software dynamically.

2. JSP's : View layer components having presentation logic it is recommended to develop JSP's of struts application as java less JSP's by using standard JSP's tags or JSP technologies,JSTL tags struts supplied JSP calass library tags and custom JSP tag library tags.

3.Web.xml : It is a deployment descripter file of web application having configuration of built in action servlet. This files also contains JSP tags library configuration, welcome file configuration.
Note: Even through action servlet is built in servlet, its configuration in web.xml using servlet tags is mandatory.

Note: Struts based web applications are MVC architectured based web-applications and there will be one servlet in the entire web application, that is action servlet acting as controller.

4. ActionForm/FormBean: (it is a JavaBean class): It is a programmer developed java bean class as helper class to controller servlet called action servlet FormBean class object stores form data send by browse and received by action servlet.

FormBean class contains form validation logic. Form Bean is a JavaBean having capability to store form data.And also capable of validating form data.

A JavaClass/JavaBean class that extends from org.apache.struts.action.ActionForm is called FormBean class predefined ActionForm class is an abstract class containing no abstract methods.

Q : What is need of FormBean class in Struts application.
A : Verifying the format of the form data is called form validation.

  • In MVC based web applications this logic must be available in controller Servlet.Struts applications are MVC based web applications. And the built in controller servlet does not give any form validation logic an does not allow to keep form validation logic directly in it. But programmer wants to write form validation logic. For this struts frame work software makes action servlet to receive form data by trapping request and makes to store form data in user defined java class object. This user defined java class is nothing but FormBean class.
  • Since FormData is visible and accessible in FormBean class the programmer also places form validation logic in FormBean Class.
Note : FormBean is a JavaBean but every JavaBean is not a FormBean.The JavaBean class that extends form predefined ActionForm class is called FormBean.

5. ActionClass : (programmer supplied java class) : If business logic is kept directly in Action class then it acts as model. If Action class is having logic to interact with other model layer components/applicaitons like EJB components spring with Hibernate applications or any other business component, then Action class is called as helper to controller called Action Servlet.

Q : What is the need of ActionClass.?
A : If Business logic of struts based web application is available in EJB Component or in Spring with Hibernate application the controller servlet called ActionServlet is supposed to interact with these model Layer EJB components Spring with Hibernate applications. Since ActionServlet is builtin Servlet we can't place above said integration logic in ActionServlet. So we place this integration logic is the helper class to controller called ActionServlet . This helper class named as ActionClass.


As part of struts application flow of execution the request trapped by ActionServlet definitly tries to execute the logics of appropriate FormBean class, Action class once. The java class that extends from org.apache.struts.action.ActionServlet class is called Action class of struts application.

6. Action-forward:
This is an XML entry specifing result JSP page of Action class. Based on these configuration the business logic execution result goes to result JSP page, where the presentation logic of result JSP page formats the result and sends formatted result as response to the browser.

7. Struts configuration file :
(any filename)(.xml file)
This xml file contains guidelines required for the Action servlet, Framework software to generate Integration logic dynamically. This file contains FormBean classes configuration Action classes configuration,action-forward configurations and plugins configuration like validates plugins,files plugins.

Based on this files instuctional configurations the Action servlet will decide FormBean , Action class to be utilize to process the request when action servlet traps request given by the browser.

Entries kept in web.xml will be read by webContainer of webserver / application server. These entries kept in struts configuration file will be read by struts frame work software and ActionServlet.

.xml can become struts configuration file but this file name must be informed to ActionServlet.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

3. Introduction to Struts.

>> Thursday, May 28, 2009

Struts:

  • TYPE : FrameWork Software to develop web application
  • VERSION : Struts 1.x(1.38) compatable with J2SDK 1.4 , 2.x(2.0.11) compatable with J2SDK 1.5.
  • VENDOR : Apache Foundation
  • Open Source Software
  • Download Software as Zip file from www.apache.org
  • For Help : www.struts.apache.org
  • For FAQs : www.forum.apache.org
  • Author: Craig mccallam
  • Online Tutorials : www.roseindia.com
  • Books : struts 1.x , Jakarta books(O'rielly press)
  • Complet reference of Struts(O'rielly press
  • Struts 2.x, Black Book
Struts 1.x Software.
  • Base Framework Software
  • Puugins
Validator plugins
Tiles plugins
  • Documentaiton
  • JSP Taglibraries
  • Example Applications
Installing Struts software but extracting zip file .(Struts 1.3.8-all.zip)file to a folder.
--> A plugin is a readymade solution configurable with applications.
--> JSP tag library is a library that contains set of readily available JSP tags. Struts 1.x Softwares gives six numberof JSP tag libraries. And these tags are JSP tag libraries are useful to make JSPs of webg applications as java codeless JSPs.
--> To make JSP as Java code less JSPs avoid scripting tags(scriptlet,expression,declaration),tags in JSP programming.

Note 1: Opensource software means not only free softwares , all the sources used to design and devolop a software will be given along with software installation.
Note 2: In strts based webapplications controller servlet is built in servlet and its name is action servlet. ActionServlet is given as HttpServlet.
  • According to java language API is nothing but set of classes and interfaces which come in the form of packages.
  • Struts API means working with classes and interfaces of org.apache.struts.package, and its subpackages.
  • To get help regarding struts-api,JSP tag libraries and XML files of struts use struts-home/docs/index.html file.
// The API given by thirdparty organization(other than sun microsystems) will come as jar files.
  • Struts software is always given by apache foundation, so it is giving struts API in the form of strutshome/lib/struts-core-version.jar file and this jar file is having multiple dependent jar files in the same tag.
  • Struts software installation gives example web application in strutshome/apps folder. The directory where struts software is installed(zip file is extraced) is called struts home directory.
//Setup required for Struts 1.x based application is nothing but developing normal web application by adding struts api support.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

2. Introduction to FrameWork

In MVC architecture based webapplication we use JSPs in view Laer servlet in controller Layer. JavaBean, EJB, Spring with Hibernate technologies in model layer.
Q. What happens if interchange technologies of these layers.?
A. We can change rolls of these technologies , but it is not recommended to do.

Reasons: If servlet is taken as view layer component

  • preesntation Logic of the webapplication changes at regulat intervals.
  • If source code of servlet is modified we need to recompile the servlet and we need to reload the webapplication.
  • If Source code of JSP is modified these is no need of recompiling JSP and reloading the webapplication.
  • Since presentation logic of webapplication changes regularly it is recommended to take JSP s as View components.
If JSP is taken as Controller
  • Integration Logic of controller is always java code.
  • Keeping Java Code in JSP is not industry standard.
  • It is always recommended to develop JSP as java codeless JSP.
  • If JSP is taken as controller it will be forced to have java code,representing integration logic which is not a recommended operation.So always prefer taking servlet as controller.
Note.:Only webComponents(Servlets, JSPs) can acts as controller Because they only can take Http request given by browser. So we can't see JavaBean, EJB, Hibernate and spring applications as controller because they can't take Http request.
These application can't act as view Layer application because they are not capable of generating web-pages.
  • If Seperates or another Servlet/JSP is taken as model layer components.
  • Business Logic placed in Servlet/JSP gives following limitations.
  • Allow only HttpClients(browsers) to access the business logic.
  • Business Logic becomes specific to one webapplication(businessLogic is not reusable).
  • Middleware services must be implemented manually.
  • To overcome these problems use EJB, Spring with hibernate to develop business logic of model layer,and take the advantage of reuability of business logic built in middle ware services under capability of allowing all types of java applications as clients(Both Http & Http Clients).
Note: Browsers are called HttpClients. Java application, awt, spring applications are called non HttpClients.

Framework is a special software that is capable of developing applications based on certain architectuere havingg ability to generate common logics of applications devolopment dynamically.
Due to framework software program need not to develop of all the logic of application. He just need to concentrate only on the logics that are specific to our applications.
Strut is a web based frame work software to develop MVC architecture based webapplication having capability of generating integration logic of controller Servlet dynamic calls.
In Struct based webbased application controller servlet is built in servlet and its integration logic will be generated dynamically By struct framework software . So programmer needs to develop only presentation , business logics.
  • Struts framework Software is designed by using servlet JSP technologies has underlaying technologies.
  • In strut based web application, MVC priciple will not be violated , because it experts source code files to programmer according to MVC principles.
  • By using struts frame work software complex operation of web application can be done easily with the support of built in wizards and (Phonics).
  • If web application developed manually with out using framework softwares are based on MVC architecture programmer needs to develop all the applications manually.
  • Compare to mannual implementation of MVC architecture(with out framework software) to develop web applications the framework software based web applications can be developed fastly.
Struts ----> Apache
JSF ----> Sun MicroSystems
Cocoon ----> Adobe
Webwork ----> OpenSymphony
Spring MVC----> Interface21.
TapStray ----> OpenCommunity
ASP.net ----> MicroSoft

Note : All java based webframe work softwares are given based on servlet JSP technologies.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

1.5. Disadvantages of MVC :

>> Wednesday, May 27, 2009

For parallel development more programmers with knowledge on multiple technologies is required.
Note: in the development of MVC architecture based web application not only we need to use multiple technologies , but we also need to use(follow) set of rules in the devolopment of web application.

  • Multiple layers are given in web-application development.Each layer is given for specific logics. Just keep only these logics and don't place any extra logics.
  • Every operation /execution that takes place in MVC architecture webapplication must be executed under the control of controller Servlet.
  • We can see multiple business components in model layer. Multiple view components in view layer, But these should be only one servlet acting as controller.
  • Clean separation of logic is required in multiple layers of application development.
  • View components should not interact with model components directly and viceversa. This communication must be executed or happened through the controller servlet.
  • Two types of web application must not interact each other directly. This communication should happens through controller servlet.
  • Design pattern are the set of rules which come as best solution for real time problems of application development.
  • Senior developers design these design pattern based on experience and junior devolopers use these design patterns in projects development.
  • To develop Java, J2EE application as best application without having sideaffects of java, J2EE technologies. It is recommended to develop application by applying design patterns.
  • If design patterns becomes popular & minimum standards to devolop applications,base to design new softwares then design patterns acts as architectures.
  • MVC is gives as design patterns initially. After its popularity it has become MVC architecture.
  • Struts, JSF and etc frame work softwares are designed based on MVC design pattern/architecture.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

1.4. Advantages of MVC Architecture

Since there are multiple layers representing multiple logics there will be clean separation of roles or logics.

  • Modification of one logic does not effect other logics.
  • Easy to maintain and enhance the project.
  • Parallel development is possible due to this productivity is very good.
  • Project Leader divides a team into two parts.
  • 1. Web Authors
  • 2. J2EE Developers.
1.Web Authors : These programmers use JSP in developers presentation logic of the application.
2.J2EE Developers: These programmers use J2EE technologies like servlets EJB and e.t.c, to develop integration logic and business logic, persistence logic of the application.
While working with EJB , Spring and Hibernate technologies in model layer we can take the advantage of built in middle ware services due to this programmer will not be over burdened.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

1.3. MVC Architecture.

In MVC architecture based web-application devolopment multiple layers will be involved like

  • View layer,
  • Model layer,
  • Controller layer.

M(Model) Contains
  • Business Logic
  • Persistence Logic
  • Java Bean/EJB
  • Spring with Hibernate simply named as (Accounts Officer)
V(View) Contains
  • Presentation Logic
  • JSPs /Free marker simply named as (Beauticians)
C(Controller) Contains
  • Integration Logic
  • Servlet simply named as (Traffic Police).
Java application use JDBC or ORM (Object Relational Mapping)technologies like Hibernate to interact with database softwares.
  • Java applications use JCA(Java Connector Architecture) to interact with ERP (Enterprise Resource Plan) & CRM (Customer Resource Management).
  • Java Application use JNI ( Java Native Interface) to communicate with legacy system.
  • Integration Logic is the connectivity logic b/w model layer components.
  • Integration Logic controls and monitors all the operations that are taking place in MVC architecture based web-application.
  • Integration Logic is responsible to trap and take the request to send request to Model Layer, to get business logic execution request from model layer to pass request to view layer components
with respect to the above diagram:
  1. 1.Browser gives request to web application.
  2. 2.The controller Servlet traps and taken the request.
  3. 3.Controller servlet uses integration logic and passes the request to appropriate model layer to business component.
  4. 4.& 5. Model Layer business logic executes if necessary business components interacts with one of the back-end softwares for using persistence Logic.
  5. 6.The business Logic execution logic comes to controller servlet.
  6. 7. Controller servlet passes the new request to view always components JSP.
  7. 8. Presentation Logic of JSP formats the result and sends formatted result to browser as response.
Calling Model 1 as MVC 1, Model 2 as MVC 2 is always an appropriate terminalogy.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

1.2. Limitations Of Model 1 Architecture

>> Tuesday, May 26, 2009

Since multiple logic's are mixed up in every web resources of web application there are no clean separation of logic's/rolls.

  • Modification done in one logic disturbs other logic of the web application parallel development is not possible due to this productivity is very poor.
  • Maintenance and enhancement of the project is always complex.
  • Programmer will be overburdens because he has to implement middle-ware services along with main logic's.
Advantages : Knowledge servlets of JSP is enough to develop the web-application.
  • Model 1 architecture is not a industry standard to develop the web-application.
  • To overcome the problem of Model 2 architecture use MVC architecture Model 3 architecture to develop the web-application.

Read more...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

1.Web application introduction.

WebApplication is a collection of web resources like HTML files, JavaScript files, image files Servlets, jsps and etc.

In order to make resources of a application as globally accessible resources developed as web resources of web-application each web-resource develops one webpage and this webpage is globally accessible page.
The web-application that is moved to internet network after development is called Website.

A web application contains two types of web-resources. 

**    Server side Web-resource    
**    Client side Web-resource
    A web resource that comes to browser(client) from web application placed in web-server/application server for execution is called client side web resource.

    EX:  HTML,JavaScript programs.

    The web-resource program that executed in the server(web-server/application server)is called server-side web-resource program.

    EX : Servlet,JSP
    • Don't decide weather web-server program is server-side or client side based on the place where it resides and decide based on the place where it executes.

    Read more...

    Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Google Bookmark Yahoo ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl

    Related Posts Plugin for WordPress, Blogger...

    Random Posts

    JavabynataraJ - Find me on Bloggers.com Find me on blorner.com Technology Blogs JavabynataraJ Backlinks Blogarama - The Blog Directory

      © Blogger template Webnolia by Ourblogtemplates.com 2009

    Back to TOP