Struts Intro
a) ActionServlet recieves the request sent by the client. It is the entry point to the application.
b ActionServlet populates the ActionForm bean and delegates to Action class.
c) The execute/perform function then does the job calling the business logic and forwarding to appropriate actionforward.
d) The parameters passed to execute/perform are mapping, actionform, request and response objects.
e) The execute function of Struts 1.1 has better exception handling than perform of Struts 1.0
f) The <action-mappings> in struts-config.xml file gives the details of action class, logical name and action forward etc.
g) The path to actionServlet is specified in the web.xml file.
h)
i)
The action path tells the logical name as used by the web container after trimming and suffix or prefix which is usually /do to .do
The action name tells which actionform bean is to be used to populate the data with that contained in the request.
The action type tells which action class is to be used for the current action.
The forward name tells logical name of the actionforward and path tells the path of the file where the actionforward file resides.
j) Here, the request will contain register.do. The actionServlet will look for /register in the <action-mappings> and if it finds it then it looks for name specified in <action> and looks up that bean in <form-beans> and loads the bean as specified by type attribute.
k) The actionServlet will call setter methods for all the parameters in the request. If doesn’t find one then it ignores that parameter.
l) The actionServlet will then look for type attribute of <action> and invoke its perform/execute method.
m) Depending upon the perform/execute method, actionForward is returned which is again looked up in <action> and corresponding page is shown.
n) ActionForwards help to program the hyperlinks
o) In struts 1.1, actionforms can also be defined using Map and a DynaBean may also be used.
p) To build a web application with struts, developers define the hyperlinks they need as ActionForwards, the HTML forms they need as ActionForms and whatever custom server side actions they need as Action classes.
q) If the actionForward is a jsp then jasper and not struts renders the page.
r) The actionServlet validates the ActionForm bean if the validate attribute is set to true in the <action>.
s) If the validation of actionForm fails then the page specified in the input attribute is shown.
t) The BeanUtil.populate method is used to populate form beans from an HTTP request and can also be used to populate any bean from any type of map.
u) Struts1.0 weak points
Struts doesn’t provide custom logging mechanism
No support for multiple configuration files
No support for multiple resource files
Custom JavaBeans must be created
Struts1.1 weak points
No event model
No debugging support
No access support for persistent data
Only one ActionServlet per application
System level messages like exceptions are not localized
Only one ActionForm is available in perform/execute
Fuzzy nomenclature
v) Struts Strong points
Centralized configuration
Different translators can work on their copy of message source
Open source
Provides general purpose tag extensions
Extensible
w) The struts-html taglib contains <html:base/> tag to make the browser use relative paths.
x) The struts-logic taglib contains <prefix:present scope=”session” name=”attribute” > to check if the name attribute is present in the user’s session.
<prefix:notPresent scope=”session” name=”attribute”> does the opposite.
y) Else tags are not present in struts-logic, which means that some code need to be repeated but that simplifies the syntax of tags.
Struts also maintains the user’s session by reading links from config file and then rewriting the hyperlinks.
<logic:present name="user">
<LI><html:link forward="logoff">Sign out</html:link></LI>
</logic:present>
a) ActionServlet recieves the request sent by the client. It is the entry point to the application.
b ActionServlet populates the ActionForm bean and delegates to Action class.
c) The execute/perform function then does the job calling the business logic and forwarding to appropriate actionforward.
d) The parameters passed to execute/perform are mapping, actionform, request and response objects.
e) The execute function of Struts 1.1 has better exception handling than perform of Struts 1.0
f) The <action-mappings> in struts-config.xml file gives the details of action class, logical name and action forward etc.
g) The path to actionServlet is specified in the web.xml file.
h)
<form-beans> <form-bean name=”registerForm” type=”app.Register”
i)
<action-mappings> <action path=”/register” type=”app.RegisterAction” name=”registerForm”> <forward name=”success” path=”/success.html”/> <forward name=”failure” path=”/failure.html”/> </action> </action-mappings>
The action path tells the logical name as used by the web container after trimming and suffix or prefix which is usually /do to .do
The action name tells which actionform bean is to be used to populate the data with that contained in the request.
The action type tells which action class is to be used for the current action.
The forward name tells logical name of the actionforward and path tells the path of the file where the actionforward file resides.
j) Here, the request will contain register.do. The actionServlet will look for /register in the <action-mappings> and if it finds it then it looks for name specified in <action> and looks up that bean in <form-beans> and loads the bean as specified by type attribute.
k) The actionServlet will call setter methods for all the parameters in the request. If doesn’t find one then it ignores that parameter.
l) The actionServlet will then look for type attribute of <action> and invoke its perform/execute method.
m) Depending upon the perform/execute method, actionForward is returned which is again looked up in <action> and corresponding page is shown.
n) ActionForwards help to program the hyperlinks
o) In struts 1.1, actionforms can also be defined using Map and a DynaBean may also be used.
p) To build a web application with struts, developers define the hyperlinks they need as ActionForwards, the HTML forms they need as ActionForms and whatever custom server side actions they need as Action classes.
q) If the actionForward is a jsp then jasper and not struts renders the page.
r) The actionServlet validates the ActionForm bean if the validate attribute is set to true in the <action>.
s) If the validation of actionForm fails then the page specified in the input attribute is shown.
t) The BeanUtil.populate method is used to populate form beans from an HTTP request and can also be used to populate any bean from any type of map.
u) Struts1.0 weak points
Struts doesn’t provide custom logging mechanism
No support for multiple configuration files
No support for multiple resource files
Custom JavaBeans must be created
Struts1.1 weak points
No event model
No debugging support
No access support for persistent data
Only one ActionServlet per application
System level messages like exceptions are not localized
Only one ActionForm is available in perform/execute
Fuzzy nomenclature
v) Struts Strong points
Centralized configuration
Different translators can work on their copy of message source
Open source
Provides general purpose tag extensions
Extensible
w) The struts-html taglib contains <html:base/> tag to make the browser use relative paths.
x) The struts-logic taglib contains <prefix:present scope=”session” name=”attribute” > to check if the name attribute is present in the user’s session.
<prefix:notPresent scope=”session” name=”attribute”> does the opposite.
y) Else tags are not present in struts-logic, which means that some code need to be repeated but that simplifies the syntax of tags.
Struts also maintains the user’s session by reading links from config file and then rewriting the hyperlinks.
<logic:present name="user">
<LI><html:link forward="logoff">Sign out</html:link></LI>
</logic:present>
0 Comments On This Entry
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
My Blog Links
Recent Entries
-
SCJP Notes - Part 8on Apr 04 2008 01:22 AM
-
SCJP Notes - Part 7on Mar 31 2008 05:06 AM
-
SCJP Notes - Part 6on Mar 27 2008 08:19 AM
-
SCJP Notes - Part 5on Mar 27 2008 08:05 AM
-
SCJP Notes - Part 4on Mar 27 2008 07:31 AM
Recent Comments
Search My Blog
15 user(s) viewing
15 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment








|