0% found this document useful (0 votes)
82 views

Paper 2 - Websites Based On J2EE of Struts

Uploaded by

josehp v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Paper 2 - Websites Based On J2EE of Struts

Uploaded by

josehp v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Websites Based on J2EE of Struts

Jiao Cui-Ling1 and Wang Jian-Ping2


1
Experiment Center, Henan Institute of Science and Technology, 453003, XinXiang, China
2
School of Information Engineer, Henan Institute of Science and Technology, 453003,
XinXiang, China
{jiaocuiling1969,xunji2002}@163.com

Abstract. Establishing Web service based on the layer structure could raise the
efficiency of Web development, it could manage the system structure
effectively; lower the complications and the supporting difficulty. The
important technology of MVC software designing model was the separating of
the operation code with the view code, struts was the implementation of the
MVC model based on the Web form according to the J2EE. It was analyzed the
MVC software designing model, JSP MODEL 2 frames, the main technology of
the struts, expatiated the advantage and disadvantage of the Web development
form based on the struts in details.

Keywords: Struts, MVC, J2EE, JAVA.

1 Introduction
Java is used in a wide variety of computing platforms from embedded devices and
mobile phones on the low end, to enterprise servers and supercomputers on the high
end. The development platforms of java can be divided into Java SE, Java EE and
J2ME.
J2SE is used for general-purpose on desktop PCs, servers and similar devices.
J2ME is the Micro Edition of JAVA. It specifies several different sets of libraries for
devices with limited storage, display, and power capacities. It often used to develop
applications for mobile devices, PDAs, TV set-top boxes, and printers.
J2EE means Java Platform, Enterprise Edition or Java EE. It is Oracle’s enterprise
java computing platform. The platform provides an API and runtime environment for
developing and running enterprise software, including network and web services, and
other large-scale, multi-tiered, scalable, reliable, and secure network applications.
J2EE defines the core set of API and features of Java Application Servers. The Web
modules include servlets, and JavaServer Pages.
JSP (JavaServer Pages) is a Java technology that helps software developers serve
dynamically generated web pages based on HTML, XML, or other document types.
Architecturally, JSP may be viewed as a high-level abstraction of Java servlets. JSPs
are loaded in the server and are operated from a structured special installed Java
server packet called a Java EE Web Application, often packaged as a file archive.
With the gradual development and wide application of the J2EE system, some
excellent application frames appeared. Among these frames, Struts was a more

C. Liu, L. Wang, and A. Yang (Eds.): ICICA 2012, Part I, CCIS 307, pp. 31–36, 2012.
© Springer-Verlag Berlin Heidelberg 2012
32 C.-L. Jiao and J.-P. Wang

popular one. It was a project which ASF supported, by using the technology of JSP ,it
accomplished the application frames based on the MVC design form of J2EE web,
Struts was a categorical product of MVC, It made the developer free from the trivial
work and exploited further web application ,Saving the time of designing frames,
struts let the developer concentrate on how to cope with the problem of real business
,which greatly simplified the development process of web application .Thus it
shortened the development period and improved the development efficiency.

2 MVC Model
MVC is short for model view controller. MVC is a software architecture, currently
considered an architectural pattern used in software engineering. The model manages
the behavior and data of the application domain, responds to requests for information
about its state, and responds to instructions to change state. In event-driven systems,
the model notifies observers when the information changes so that they can react.
MVC was a design form and it compelled to part the input, treatment and output of
the application program. It divided the application program into three core modules:
pattern view and controller, which undertook different task.
Model: business logic layer, realizing the function of specific business logic and
state control.
View: expression layer, reading the interface of interaction with the user and the
function of date input and output. The view renders the model into a form suitable for
interaction, typically a user interface element. Multiple views can exist for a single
model for different purposes. A view port typically has a one to one correspondence
with a display surface and knows how to render to it.
Controller: control layer .Realizing the function of Flow control and the
cooperation between view and Model. The controller receives user input and initiates
a response by making calls on model objects. A controller accepts input from the user
and instructs the model and a view port to perform actions based on that input.
The relation of Model, View and Controller shows as figure 1.

Fig. 1. Relation of MVC

3 JSP Models
In the design of Java Web applications, there are two commonly used design models,
referred to as Model 1 and Model 2.
Websites Based on J2EE of Struts 33

3.1 JSP Model 1


In JSP Model 1, a request is made to a JSP or servlet and then that JSP or servlet
handles all responsibilities for the request, including processing the request, validating
data, handling the business logic, and generating a response. The Model 1 architecture
is commonly used in smaller, simple task applications due to its ease of development.
The Structure of JSP Model 1 shows as figure 2.

Fig. 2. JSP Model 1 Structure

3.2 JSP Model 2


JSP Model 2 is a more complex design pattern that separates the display of content
from the logic used to obtain and manipulate the content. In a Model 2 application,
requests from the client browser are passed to the controller. The controller performs
any logic necessary to obtain the correct content for display. It then places the content
in the request (commonly in the form of a JavaBean or POJO) and decides which
view it will pass the request to. The view then renders the content passed by the
controller. The Structure of JSP Model 2 shows as figure 3.

Fig. 3. JSP Model 2 System Structure


34 C.-L. Jiao and J.-P. Wang

4 The Core Technology of Struts

4.1 The Core Module of Struts


(1) ActionServlet module
Struts’ controller is mapping the events (the events usually are HTTP post)to a Servlet
of the module. ActionServlet is the realization of the MVC Command, and it is the
core of this framework. ActionServlet creates and uses Action, ActionForm and
ActionForward. By modify the file struts-config.xml to configure the command. In
creat Web project, the user through extending Action and Actionform to solve the
specific problem. File struts-config.xml instructs Actionservlet that how to use the
expanded module.
(2) ActionForm module
ActionForm maintains Web applications session state. ActionForm is an abstract
module, and it must be for each input form type of the module to create more
children. ActionForm said is set by HTML form or updated the general sense of the
data. In setting UserActionForm form of organization by HTML,Struts framework
will examine whether there is UserActionForm, if does not exist, it will create an
instance of the module. By use the corresponding domain HttpServletRequest to set
up the state of UserActionForm. Struts framework will be passed to the User
ActionForm in business and will be updated it before packing the state of User
Action. Before passing it on to the kind of Action,Struts will also examine
UserActionForm the form state by reallocating the method of validation().
(3) Action module
Action module is a package of the logic business. The purpose of the module
makes HttpServletRequest convert to logic business. To use Action, you should create
submodule of it and cover process() method. By using perform()method,
ActionServlet(Command)will pass the parametric module to ActionForm.
In the Struts,Action is a guide to action,and passes the available information to the
corresponding logic modules to handle. Servlet is inherited by Action, so that some
simple function can be placed in Action, at last the Function perform()returns
operation success or failure of state records.
(4) Error module
The defined Error categories of Struts include ActionError and Action-Erroes.
ActionError encapsulates the single error messages. ActionErroes is the container of
the ActionError, and View can make the popularization and application of access to
these markers. ActionError is made that the Struts to keep way of the error list.
(5) ActionMapping module
ActionMapping includes how the given incident mapped to the given Action
information. Through the way of perform(), ActionServlet (command) passed the
ActionMapping to Action module. In this way it allowed Action to visit the
information used for control flow.
Websites Based on J2EE of Struts 35

4.2 Struts Work Flow


In the Web application process of Struts Frames, it would load and initialize
ActionServlet when Web application was started. ActionServlet read pre-load
information from the document of struts-config.xml and put them in the respective
disposal target. When ActionServlet receives a user’s demand, it would implement the
following flow: judge whether the suffix of a user’s HTTP demand is “do” and all the
demand would be intercepted by control ActionServlet. According to the collocating
information in Struts-config.xml, ActionServlet maps the intercepting information to
the Action module accordingly, and sealed the user request form in FormBean with a
given name. Then ActionServlet called the way of execute() in business logic Action
case to implement business logic. After using this method, it would return a
ActionForward target. Controller would search the collocating information based on
the returned target and turn the JSP page accordingly.

5 Conclusion
The advantages of using Struts to realize the website construction: It adopts JSP
marked mechanism to get the reusing codes and abstract codes. This method
contributed to improve the reusability and flexibility of codes. When the technology
space or the problem space varied, users have much more chances to reuse codes.
Using open source, everybody in the user’s room could check up codes. Struts make
the designers and developers pay their attention to their own favorite aspects.
Adopting separately control ideology to manage the problem space. The websites
based on this pattern had perfectly robustness. The layer structures were clear. As to
huge scale of system, Struts conducted to manage complicated system.
The disadvantages of using Struts to realize the website construction: The
applicable scope of Struts is limited. Struts are MVC solution based on web. So it
must be achieved by HTML, JSP document and Servlet and use J2EE application
program to support Struts. Struts need to support JSP1.1 and Servlet 2.2 standard
Servlet container. Of course, isolating the problem scope, but strengthening the
complicacy, so one must accept some training before they adopt Struts development.

References
1. Selfa, D.M., Carrillo, M., Del Rocío Boone, M.: A database and web application based on
MVC architecture. In: International Conference on Electronics, Communications and
Computers, pp. 48–49 (2006)
2. Lin, Y.-L., Hu, J.-P.: Design and implementation of the internet service platform for
rural house building technique criteria and management based on .NET MVC. Applied
Mechanics and Materials, 1727–1731 (2011)
3. Wang, L.-H., Xi, M., Li, D.-X.: A network-friendly architecture for Multi-view Video
Coding (MVC). Advanced Materials Research, 678–681 (2010)
4. Li, J.-M., Ma, G.-S., Feng, G., Ma, Y.-Q.: Research on Web Application of Struts
Framework Based on MVC Pattern. In: Shen, H.T., Li, J., Li, M., Ni, J., Wang, W. (eds.)
APWeb Workshops 2006. LNCS, vol. 3842, pp. 1029–1032. Springer, Heidelberg (2006)
36 C.-L. Jiao and J.-P. Wang

5. Xu, C.-W.: Applying the MVC diagram for building web applications in struts. In:
Proceedings of the 2005 International Conference on Internet Computing, pp. 38–44
(2005)
6. Li, Y., Chen, Q.-J.: MVC mode-based mobile telerobotic system and its java
implementation. In: Proceedings of the World Congress on Intelligent Control and
Automation (WCICA), pp. 4736–4740 (2004)
7. Zhang, Z.-Q., Xu, C.-J.: MVC model based on high-performance computing operating
audit system. In: International Conference on MultiMedia and Information Technology,
pp. 241–243 (2010)
8. Zhang, H.-T., Duan, F.-J., Wang, X.-Y.: Application framework of embedded system
based on MVC design pattern. Journal of Harbin Institute of Technology, 166–168 (2009)
9. Chen, N.: Automatic generation of resource access code based on MVC mode. Journal of
Shenyang University of Technology, 417–422 (2010)
10. Cui, W., Huang, L., Liang, L.-J.: The research of PHP development framework based on
MVC pattern. In: International Conference on Computer Sciences and Convergence7.
Information Technology, pp. 947–949 (2009)

You might also like