Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Referring to the above, which one of the following choices below allows the creation of a Strutsaware HTML form?
2. The Struts message resources can be loaded either by 1) an init parameter in the servlet config in
the web.xml or 2) by a <message-resources> tag in the struts-config.xml.
Referring to the above, when is using option 2 required in a Struts application?
Option 2 is required when the application uses the Struts Tiles framework.
Option 2 is required when the application supports more than one application resource file.
parameter key to the tag <message-resource>. With this key Struts knows which
message resource file to access.
Ans : Option 2 is required when the application supports more than one application resource
file.
3.
Referring to the above, which one of the following codes allows a file to be uploaded to the server?
part="multipart/form-data"
encrtype="multipart/form-data"
contentType="multipart/form-data"
filetype="multipart/form-data"
enctype="multipart/form-data"
Ans : enctype="multipart/form-data"
[Note:] http://www.roseindia.net/struts/strutsfileuploadandsave.shtml
4. struts-config.xml snippet:
<action path="/multi"
type="test.MultiAction"
name="MultiForm"
scope="request"
input="/multi.jsp"
parameter="method"/>
JSP code snippet:
<html:form ction="/multi">
<html:submit property="method">
<bean:message key="button.feature1"/>
</html:submit>
<html:submit property="method">
<bean:message key="button.feature2"/>
</html:submit>
</html:form>
Referring to the above, how does a developer create an Action class capable of processing multiple
submit buttons WITHOUT using JavaScript in the form?
By instantiating the DispatchAction class and defining an execute method called feature1 and
feature2
By subclassing the DispatchAction class and declaring an execute method called feature1 and
feature2 in the subclass
By subclassing the LookupDispathAction class and defining forward methods called feature1
and feature2 in the subclass
[Note:] http://www.roseindia.net/struts/struts-LookupDispatchAction.shtml
5.
Referring to the above, which code example clears the value from name?
this.name = null;
Ans : To present existing data that does not require additional processing
[Note:] http://struts.apache.org/1.0.2/api/org/apache/struts/taglib/bean/package-summary.html
7.
Referring to the above, a developer must create an Action class capable of processing build and test
functions for a car. How does the developer accomplish this task?
By creating the CarAction class by subclassing the DispatchAction class and declaring an
execute method called build and test in the subclass
By creating the CarAction class by subclassing the LookupDispathAction class and defining a
method called getKeyMethodMap in the subclass
By creating the CarAction class by subclassing the ExtensibleDispathAction class and defining
ActionForward methods called build and test in the subclass
By instantiating the DispatchAction class and defining an execute method called build and
test
Ans : By creating the CarAction class by subclassing the DispatchAction class and declaring
an execute method called build and test in the subclass
8.
Assuming classes Test*Action have valid ActionForm mappings and validate() contains login status
checks, how does the Sample <action-mapping> change to call this method for
com.test.struts.DefaultAction without affecting the other mappings?
[Note:]
http://www.jajakarta.org/struts/struts1.0/en/target/documentation/api/org/apache/struts/action/Ac
tionMapping.html
9. A developer has created an ActionForm subclass that has an integer property called contacts with
getContacts() and setContacts() accessors. The page field representing contacts can accept nonnumeric input.
Referring to the above, how does the developer change the configuration to display the value
entered back to the user if non-numeric input is entered?
Specify <form-property allow_integer=true> in the Action configurationy>.
Specify <form-property initial="java.lang.Integer"> in the Action configuration.
Contact property as a String.
Referring to the above, which one of the following prevents the execution of the LoginAction and
instead forwards to the Web resource /external/3rdpartylogin?
11.
12. What is the Struts validator syntax necessary to require a problem description if a problem
check box is selected?
<field property="pdesc">
<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>
Declare a scriplet before the <logic:iterate> tag to define int i = 1 and increment the value by 2 in
another scriptlet after <bean:write>.
Declare a scriplet after the <logic:iterate> tag to define int i = 1 and iterate the value in another scriptlet
after <bean:write>.
Change the example to display the indexId attributes from the <logic:iterate> tag.
Change the example to display the rowId property from the <logic:iterate> tag.
Change the example to display the rowId property from the <bean:write> tag.
/updateProfile?method=updateProfile&demographics=1
/updateProfile?method=updateProfile&demographics=yes
/updateProfile.do?method=demographics&updateProfile=yes
/updateProfile.do&app=demographics&updateProfile=yes
/updateProfile.do&method=demographics&updateProfile
Ans : /updateProfile.do?method=demographics&updateProfile=yes
The developer subclasses the ActionForward class and creates a public method called setModule().
The developer subclasses the ActionForward class and creates a public method called getModule().
The developer subclasses the ActionForward class and creates a public attribute called module.
Ans The developer subclasses the ActionForward class and creates a public method called getModule().
To define the action servlet and validation definitions for the application
To define the deployment descriptor and action mappings for the application
To define the action servlet and init parameter values for the application
To define the action servlet and the action mappings for the application
To define the action servlet and validator plugins for the application
Ans To define the action servlet and init parameter values for the application
17. A developer wishes to use the Property MessageResources class for Locale support.
Referring to the above, which one of the following is an advantage of the developer's decision?
The developer wants to consolidate all properties into one file for maintainability.
The developer believes an existing Struts application can benefit from faster lookup of
Locale data, with memory utilization not being a constraint
This class trades memory for speed by caching all messages located via generalizing
the Locale under the original locale as well. This results in specific messages being stored in
the message cache more than once, but improves response time on subsequent requests for
the same locale + key combination.
[Note:]
18. org.apache.struts.config
Class ForwardConfig
java.lang.Object
|
+--org.apache.struts.config.ForwardConfig
contextRelative
protected boolean contextRelative
Deprecated. Use module property instead; will be removed in a release following
1.2.0.
Based on the documentation above, how does the application handle the path property for all instances of
ForwardConfig?
The path should be used along with setting the contextRelative property to true.
The path should not be used for post Struts 1.2.x applications because of deprecation issues.
18.
Referring to the above how does the developer change the following sample to accept the request of format:
/edit*Customer?id=125?
19. Which one of the following do you NOT need to do in order to construct a typical Struts application
configuration that accepts user input from a Web browser?
20.
Referring to the above, which one of the following prevents the execution of the LoginAction and instead executes
the Web resource /external/3rdpartylogin, assuming it appeared later in the file?
21.
public class TestAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward("test");
}
}
Referring to the above, what is the purpose of return mapping.findForward("test"); in the Action class?
The ActionForm provides Javascript client side editing for a Struts Application.
The ActionForm allows HTML controls to display in the proper tab order.
The ActionForm contains the logic to display the Web page to the client.
The ActionForm acts like a firewall for HTML request parameters sent to a Struts application.
Referring to the above, which one of the following replaces the Sample ForwardConfig to achieve Struts 1.2.x
compliance?
[Note:] protected
java.lang.String module
The prefix of the module to which this ForwardConfig entry points, which must start
with a slash ("/") character.
24.
Assuming the class LoginForm contains a String property named "password", how does the LoginAction class
access the attribute called "password" in the above request?
request.getParameterNames().getParameter("password");
25.
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
Referring to the above, which one of the following adds the module test to the Struts configuration?
<init-param>
<param-name>config/test</param-name>
<param-value>WEB-INF/test-config.xml</param-value>
</init-param>
<init-param>
<param-name>test</param-name>
<param-value>WEB-INF/test-config.xml</param-value>
</init-param>
<init-param>
<param-name>config(test)</param-name>
<param-value>WEB-INF/test/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/test</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>module</param-name>
<param-value>test</param-value>
<param-name>path</param-name>
<param-value>WEB-INF/test-config.xml</param-value>
</init-param>
actionClass
actionFormBean
formClass
unknown
formAttribute
27. In order to create a thread-safe Struts application, which one of the following guidelines does the developer
follow?
The developer upgrades to Struts release 1.2 or greater since the latest release has provisions for threadsafe Action classes.
The developer declares a pool of Action classes in the struts-config.xml to ensure an adequate supply of
Action class instances.
[Note:]
28.
sendRedirect=false
redirect=true
contextRelative=true
sendRedirect=true
redirect=false
29.
Referring to the above, what happens when loginForm.reset method is invoked, assuming the reset() method has
the default implementation?
30. Assuming you are using Struts 1.2 or later and are NOT using container-managed security, what is the
recommended method for implementing security access to a Struts action?
Subclass the RequestProcessor, define the security in this subclass, and plug this subclass in as the
processor.
31.
<action-mappings>
<action path="/test"
type="org.apache.struts.actions.SwitchAction"/>
</action-mappings>
Referring to the above, which one of the following URL examples correctly switches to testModule?
/testModule.do?prefix=/test&page=/index.do
/test.do?prefix=/testModule&page=/index.do
/test.do?prefix=/test&page=/index.do
Each property defined in the <action-attribute> element corresponds to attributes contained within the
ActionMapping instance.
The <action-mappings> tag in struts-config.xml is required since it is the only technique for
creating an ActionMapping.
The Struts controller servlet automatically creates instances of the ActionMapping class for each action
defined under the <action-mappings> tag.
33.
Use the <html:select> and <html:option> tag in conjunction with the <html:options> tag and the logic
tags should not be retained.
Correct the tag <logic:iterate> to specify scope=application and the <logic:present> tag to specify
scope=request.
Use the <html:select> and <html:option> tag in conjunction with the <html:options> tag and the logic
tags should be retained.
Correct the tag <logic:iterate> to specify scope=session and the <logic:present> tag to
specify scope=application.
Referring to the above, which code example allows the Action form to access the collection of "states" as
"choices"?
request.setAttribute("states", choices);
request.setAttribute("choices", choices);
request.setAttribute("choices", states);
request.getSession().setAttribute("choices", choices);
request.setAttribute("states", states);
37.
Referring to the above, which one of the following prevents the execution of the LoginAction and instead forwards
to the Web resource /external/3rdpartylogin?
39.
Mapping
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
<struts-config>
<!-- Form Bean Definitions -->
<form-beans>
<form-bean name="testForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userid" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
</form-beans>
Execute method signature:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String name = "testForm";
String[] formValues = (String[]) form.get(name);
}
Referring to the above, which one of the following happens when the application excecutes the code: String[]
formValues = (String[]) form.get(name);?
The application sets the value of formValues with the values from testForm.
40.
In the sample above, the value 10.00001 fails the validation as expected, but 10.000001 does not. Which one of
the following approaches does the developer take to correct this problem?
41.
42. For the Struts config, each <action> element under <action-mapping> represents which one of the
following?
42.
resource bundle:
Cannot find message resources under key org.apache.struts.action.MESSAGE
The init parameter definition for the application property specifies the location of the file.
When you configue the controller servlet in the web application deployment
descriptor, one of the things you will need to define in an initialization
parameter is the base name of the resource bundle for the application.
[Note:]
The important thing is for the resource bundle to be found on the class
path
for your application.
43.
Referring to the above, in order for the exception handler to function correctly, which one of the following tasks
does the developer perform?
The developer defines a class which extends org.apache.struts.action.ExceptionHandler and returns the
ActionError type.
The developer defines a class that extends org.apache.struts.action.ExceptionHandler and leaves the
default execute method intact.
44. Which one of the following descriptions defines the "Model" of the Model-View-Controller (MVC) pattern?
[Note:]
45.
Referring to the above, which code example clears the value from name?
this.name = null;
}
46.
<plug-in className="org.apache.struts.plugins.DigestingPlugIn">
<set-property property="configPath" value="/WEB-INF/config.xml"/>
<set-property property="configSource" value="servlet"/>
<set-property property="digesterPath" value="digester-test.xml"/>
<set-property property="digesterSource" value="classpath"/>
<set-property property="key" value="TEST_KEY"/>
</plug-in>
Referring to the above, assuming a portion of the application needs to dynamically reference the compiled plugin
in an attribute called COMPILED_KEY, which one of the following tasks does the developer perform?
47.
/updateProfile.do&method=demographics&updateProfile=yes
/updateProfile?method=updateProfile&demographics=yes
/updateProfile.do&app=demographics&updateProfile=yes
/updateProfile.do?method=demographics&updateProfile=yes
/updateProfile?method=updateProfile&demographics=1
48.
<logic:test1 message="true">
<html:messages id="tst" message="true">
<div class="test">
<bean:write name="tst"/>
</div><br/>
</html:messages>
</logic:test1>
Referring to the above, assuming myAction contains an instance of the Action class, which one of the following
clears messages from the session attribute for this tag?
myAction.saveErrors(session, null);
myAction.saveMessages(session, message);
myAction.saveMessages(session, null);
myAction.saveErrors(session, message);
myAction.saveToken(request);
49.
<struts-config>
<action-mappings>
<action path="/login" type="test.LoginAction" >
<forward name="success" path="/homepage.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
<action path="/logout" type="test.LogoutAction">
<forward name="success" path="/login.jsp"/>
</action>
<action path="/test" forward="/test.jsp"/>
</action-mappings>
</struts-config>
Referring to the above, which one of the following allows the LoginAction to be executed for all undefined path
mappings?
[Note:] The unknown attribute can be used by only one <action> element in the xml file. When set to true it
tells the ActionServlet to use this <action> element as the default behavior whenever it cannot find a path
attribute that matches the end users requested action.
50. A manager requests that an existing application use a dispatch action to consolidate several action classes.
The application CANNOT use Javascript and multi-language support is required
Which class does the developer use?
DispatchAction
PagingDispatchAction
LookupDispatchAction
AggregateDispatchAction
51.
<logic:test1 message="false">
<html:messages id="tst" message="false">
<div class="test">
<bean:write name="tst"/>
</div><br/>
</html:messages>
</logic:test1>
Referring to the above, assuming myAction contains an instance of the Action class to access this message tag,
which one of the following saves error messages to the session attribute for this tag?
myAction.saveMessages(session, message);
myAction.saveErrors(session, null);
myAction.saveMessages(session, null);
myAction.saveToken(request);
myAction.saveErrors(message);
It improves the online performance of the application since consolidated mapping files produce better
online application performance.
The team lead wants to maintain backwards compatibility with a Struts v1.x application.
It improves the startup time of the application since consolidated mapping files produce significantly
better startup performance.
It improves the readability and maintainability of the application since consolidated mapping
files are easier to read and maintain. (Not Sure)
The team lead wants to migrate to a Struts module application architecture, and wildcard mappings are
required for this type of configuration.
53. What must you do to the MessageResourceFactory before createResources() can be used?
Implement the getFactoryClass() and return the name of the factory instance.
54.
55. How does a developer enforce the client side validation in Struts?
By specifying the property clientside=true in the <html:javascript> tag to the JSP page
By specifying the property validate=client in the <html:javascript> tag to the JSP page
By specifying the property suppress=false in the <html:javascript> tag to the JSP page
By specifying the property formName with the name of the used form in the
<html:javascript> tag to the JSP page
56. A developer troubleshoots a Struts application and discovers a request parameter from the JSP page,
called description, is not populated in the ActionForm.
Referring to the above, which one of the following is a likely cause of the problem?
The ActionServlet init() method did not define the accessors getDescription() and setDescription().
The ActionForm did not define the accessors getDescription() and setDescription().
The Action subclass did not define the accessors getDescription() and setDescription().
57. In order to implement a Model 2 Struts architecture, how does the developer structure the web.xml file?
The developer deploys the application with J2EE v1.4 compliance which results in a Struts Model 2
architecture.
The developer defines two instances of the ActionServlet in the web.xml and dispatches inbound requests
from one instance to the other.
The developer defines one instance of the ActionServlet in the web.xml and defines a
request processor in the web.xml to delegate the requests.
The developer defines one instance of the ActionServlet in the web.xml and defines a request processor
in the file defined by the config parameter in the web.xml to delegate the requests.
The developer defines three instances of the ActionServlet in the web.xml and designates each one as
model, view, and controller.
By upgrading to Struts 1.2.7 or greater and setting the tag value to <html:link action="/bigapp/test?
lang=es">
By extending the LinkTag class and making the appropriate changes in the struts-html.tld file
By extending the LinkTag class and making the appropriate changes in the struts-config.xml file
59.
<controller
processorClass="org.apache.struts.action.RequestProcessor"
contentType="text/html"/>;
Referring to the above, a Struts application is configured with five separate modules with all JSP files residing in the same
location. Which one of the following changes to the <controller> configuration allows access to these JSP files?
<controller
processorClass="org.apache.struts.action.RequestProcessor"
forwardPattern="$P.jsp"
contentType="text/html" />
<controller
processorClass="org.apache.struts.action.RequestProcessor"
pagePattern="$M$P"
contentType="text/html"/>
<controller
processorClass="org.apache.struts.action.RequestProcessor"
forwardPattern="$M$P"
contentType="text/html"/>;
<controller
processorClass="org.apache.struts.action.RequestProcessor"
forwardPattern="$M"
contentType="text/html"/>
<controller
processorClass="org.apache.struts.action.RequestProcessor"
pagePattern="$P"
contentType="text/html"/>;
60. Which one of the following statements about a Struts Module is correct?
It allows the developer to segregate the application into different modules to allow for
easier configuration.
It can have only one configuration file for all module definitions.
61.
/donemy.jsp
donemy.jsp
/done.jsp
Null
62. <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
The configuration shown above is part of a legacy Struts application where Struts 1.0 behavior for populating
forms is desired. How does the developer modify the configuration?
By adding an init param, setting rulesets to 1.0
By adding an init param, setting legacy to true
By adding an init param, setting compatibility-mode to 1.0
By adding an init param, setting convertNull to true
By adding an init param, setting compatibility-mode to true
63.
Referring to the above, what error exists with the web.xml configuration?
The ActionServlet does not start since the action servlet is mapped to <url-pattern> /do1/*
and must be mapped to /do/*.
The servlet <name> must be called strutsAction in order to invoke action classes.
The ActionServlet does not start due to the application init-parameter not being defined.
64. A Struts form consists of three JSP fields a, b, and c. Validation for field c is only required when the value for
field b = "test" and the value in field a is not null.
Which recommended Struts validator solves the above problem?
validWhen
required
validIf
requiredWhile
maxLength
A frequent requirement in validation design is to validate one field against another (for
example, if you have asked the user to type in a password twice for confirmation, to make
sure that the values match.) In addition, there are fields in a form that may only be required
if other fields have certain values. The validwhen validation rule is designed to handle these
cases.
[Note:]
65.
66.
exceptionHandler
bundle
scope
className
key
For the Struts config, each <action> element under <action-mapping> represents which
one of the following?
67.
68.
Null
en_us
default_locale
request_locale
It should contain the logic for populating the associated ActionForm object from the
request parameters.
It is associated with the public servlet variable when the Action instance is first
created.
70.
<action-mappings>
<action path="/test"
type="org.apache.struts.actions.SwitchAction"/>
</action-mappings>
Referring to the above, which one of the following URL examples correctly switches to
testModule?
/testModule.do?prefix=/test&page=/index.do
/test.do?prefix=/testModule&page=/index.do
/test.do?prefix=/test&page=/index.do
[Note:] The module to switch to is specified with the prefix parameter & the page to forward
to afterward is specified with the page parameter.
71.
maintenance=Maintenance Mode
update=Update Mode
* mode is a variable in the form bean
Referring to the above, assuming the mode property of an action form has a value of
maintenance or update, which one of the following correctly displays the mode on the page?
72.
<bean:message key=$"{mode}"/>
<bean:message key="${mode}"/>
<bean:message key="maintenance,update"/>
<bean:message key="${maintenance,update}"/>
<bean:message mode="${maintenance,update}"/>
Referring to the above, which one of the choices below allows the loginForm to be used as a
wizard with a unique instance for each individual user?
scope="application"
scope="session"
scope=application
scope=session
scope="request"
73.
BEFORE:
<html:select name="TestBean" property="testCd">
<html:option value="-1">--Select--</html:option>
<logic:present name="TestBean" property="test" >
<logic:iterate name="TestBea" property="test" id="testList" scope="request">
<option value="<bean:write name='testList' property='ident'/>">
<bean:write name='testList' property='applicants'/>
</option>
</logic:iterate>
</logic:present>
</html:select>
AFTER:
<html:select name="TestBean" property="testCd">
<html:option value="-1">--Select--</html:option>
<html:options collection="test" labelProperty="ident" />
</html:select>
Referring to the above, the example JSP tag code BEFORE is replaced by AFTER. Assuming
the form bean is populated correctly, what is missing from AFTER that allows the code to
retain the correction selection for each user session?
The <logic:present> tag performs an operation on the test property before the
<html:option> tag.
Which Struts JSP taglib is used to present messages from a message resource bundle?
74.
struts-bean.tld
struts-html.tld
struts-logic.tld
struts-nested.tld
struts-validator.tld
75.
<forward
name="success"
path="/{1}.jsp"/>
How do you change the path statement above to access the entire request URI?
76.
path="/{*}.jsp"/>
path="/{9}.jsp"/>
path="/{0}.jsp"/>
path="/{**}.jsp"/>
path="/{%}.jsp"/>
Referring to the above, which one of the following choices below allows the creation of a
Struts-aware HTML form?
<%@
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> %>
77.
Referring to the above, how is the sample JSP code changed to display the error message for
the test property to the right of the field?
<table>
<tr>
<th align="right">Test Field:</th>
<td align="left"><html:text property="test" maxlength="5"/></td>
<td><logic:errorsPresent property="test"/></td>
</tr>
</table>
<table>
<tr>
<th align="right">Test Field:</th>
<td><html:errors property="test"/></td>
<td align="left"><html:text property="test" maxlength="5"/></td>
</tr>
<table>
<tr>
<th align="right">Test Field:</th>
<td align="left"><html:text property="test" maxlength="5"/></td>
<td><logic:messagesPresent property="test"/></td>
</tr>
</table>
<table>
<tr>
<th align="right">Test Field:</th>
<td align="left"><html:text property="test" maxlength="5"/></td>
<td><html:errors property="errors"/></td>
</tr>
</table>
<table>
<tr>
<th align="right">Test Field:</th>
ANS: <table>
<tr>
<th align="right">Test Field:</th>
<td align="left"><html:text property="test" maxlength="5"/></td>
<td><html:errors property="test"/></td>
</tr>
</table>
78.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
[PLACE CODE HERE]
</plug-in>
Referring to the above, which one of the following configures the ValidatorPlugIn with the
rules contained in the files:
/WEB-INF/validator-rules1.xml
/WEB-INF/validator-rules2.xml
<set-property property="pathnames"
value="/WEB-INF/validator-rules1.xml />
<set-property property="pathnames" value=
"/WEB-INF/validator-rules2.xml"/>
<set-property property="pathnames"
value="/WEB-INF/validator-rules1.xml />
<set-property property="pathnames" append="true"
value="/WEB-INF/validator-rules2.xml"/>
<set-property property="pathnames"
value="/WEB-INF/validator-rules1.xml />
<set-property property="pathnames" merge="true"
value="/WEB-INF/validator-rules2.xml"/>
<set-property property="pathnames"
value="/WEB-INF/validator-rules1.xml,/WEB-INF/validator-rules2.xml"/>
<set-property property="pathnames"
value="/WEB-INF/validator-rules1.xml />
<set-property property="pathnames" concat="true"
value="/WEB-INF/validator-rules2.xml"/>
[Note:] Upon initialization, the plug-in loads the comma-delimited list of Validator config files
specified by the pathnames property. Each config file's path should be specified by use of a
Web application-relative path, as shown
79.
Referring to the above, which one of the following codes allows a file to be uploaded to the
server?
enctype="multipart/form-data"
encrtype="multipart/form-data"
filetype="multipart/form-data"
contentType="multipart/form-data"
part="multipart/form-data"
80. Struts Locale support contains which one of the following features?
It requires setup of a single separate message resource bundle that supports all
languages.
It supports the usage of multiple files using the <locale-resources> tag located in
struts-config.xml.
81.
Referring to the above, how does the Sample <action-mapping> change to support mapping
of /test3 /test4, and /test5 to com.test.struts.DefaultAction without affecting the other
mappings?
<action unknown="true"
type="com.test.struts.DefaultAction"/>
83. The definition of the Struts <controller> was moved from servlet initialization parameters
84.
Referring to the above, which one of the following allows the LoginBean action form to be
associated with the LoginAction?
85.
forward = mapping.findForward("cancel");
if (forward!=null) {
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.redir"));
saveErrors(request,errors);
return forward;
}
Referring to the above, the code example prevents errors from being displayed on the JSP
page when the configuration is set to redirect=true. How does the developer correct this
problem?
86.
<struts-config>
<form-beans>
<form-bean
name="logonForm"
type="org.apache.struts.webapp.example.LogonForm" />
</form-beans>
<global-forwards
type="org.apache.struts.action.ActionForward">
<forward
name="failx"
path="/fail1.jsp"
redirect="false" />
</global-forwards>
<action-mappings>
<action path="/logon" default="true"
type="test.LogonAction" />
<forward
name="failx"
path="/test.jsp"/>
<forward
name="fail2"
path="/fail2.jsp"/>
<forward
name="test.jsp"
path="/fail3.jsp"/>
</action-mappings>
</struts-config>
87.
/test.jsp
/fail1.jsp
/fail2.jsp
/test2.jsp
/fail3.jsp
What is the Struts validator syntax necessary to require a problem description if a problem check box is selected?
</var>
</field>
<field property="pdesc" depends="validwhen">
<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>
<field property="pdesc" depends="requiredif">
<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>
88. A manager has asked a developer to create a Struts application with English and Spanish
support.
Referring to the above, which one of the following high level tasks does the developer
accomplish to support this requirement?
89.
Create message resources bundles for English and Spanish and configure the servlet
init parameter to load the message resources bundle.
Create message resources bundles for English and Spanish and configure
the web application to load the message resources bundle.
Upgrade to Struts 1.2.x or greater, which includes default English and Spanish support.
Create message resources bundles for English and Spanish and configure the strutsconfig <plug-in> to load the message resources bundle.
Create language specific XML files for English and Spanish and configure the Web
application to load these XML files.
Referring to the above, your manager has asked you to change the validate parameter to
false. When is this change reflected in the application, assuming the app container does NOT
support reloading when configurations change?
90.
<field property="trips" depends="">
<arg0 key="person.trips"/>
<arg1 name="intRange" key="${var:min}" resource="false"/>
<arg2 name="intRange" key="${var:max}" resource="false"/>
<var><var-name>min</var-name><var-value>2</var-value></var>
<var><var-name>max</var-name><var-value>5</var-value></var>
</field>
Referring to the above, which of the following validators do you specify to require at least
two trips, but prevent more than five trips from being entered?
intRange
required
integer,intRange
required,integer,intRange
required,integer
A single <form-bean> entry usually maps to several diverse HTML or JSP pages.
92. Design Requirement 3.a - Widget - add a custom property called "widget" to the
mapping properties
Referring to the above, which one of the following techniques does the developer perform to
accomplish the task?
The developer uses the ActionMappingBase class and calls the addProperty() method
to add the property.
The developer upgrades Struts to version 1.2.x or greater since the widget property is
standard in this release.
The developer subclasses the ActionMapping class and adds the appropriate
getter and setter methods for the property.
The developer modifies the ActionMappingBase class and adds the custom property
93.
mapping.getInputForward("details");
(ActionMappingFactory)mapping.findForward("details");
mapping.findForward("details");
mapping.findForward("detailspage");
mapping.findForward("details.html");
94. An existing legacy database table exists with key/value mapping for page values used in
the organization. A developer must use this existing infrastructure to create a new Struts
application.
Referring to the above, how does a developer best use this legacy infrastructure to create
the ResourceBundle?
Instantiate the MessageResourcesConfig class and set the setFactory method with a
map of the values from the database
95.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEBINF/validations.xml"/>
</plug-in>
Referring to the above, assuming the Struts version is 1.2.0, how do you modify the plug-in
to check all client side validations (without stopping on the first error)?
96.
Referring to the above, assuming TestUploadForm extends ActionForm, what else should
TestUploadForm define?
97.
ActionMessages messages = new ActionMessages();
ActionMessage message = new ActionMessage("message.relation.insert.success",
relation.getRelation() );
messages.add([put code here], message );
Referring to the above, which one of the following code examples placed in [put code here]
allows messages to be recorded only for message.relation.insert.success?
"message.relation.insert.success"
PageContext.SERVLET_SCOPE
ActionMessages.GLOBAL_MESSAGE
ActionMessages."message.relation.insert.success"
PageContext.PAGE_SCOPE
98.
Technique 1:
return (new ActionForward("/test.jsp"));
Technique 2:
Referring to the above, which one of the following is an advantage of using Technique 2 over
Technique 1?
A change to the test.jsp file name requires an application restart for Technique 1.
To define a generic set of mappings that can be used across all actions
100. Assuming a Struts application only has support for French, which one of the following
<message-resources key="default_fr_only"
parameter="com.test.ApplicationResources_fr"/>
<message-resources key="default_fr"
parameter="com.test.ApplicationResources.properties"/>
<message-resources key="default_only"
parameter="com.test.ApplicationResources_fr"/>
101.
Which one of the following statements is true regarding the declarative exception handling
above?
Referring to the above, how does the developer map all unmapped requests to the
TestAction class?
103.
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
Referring to the above, assuming that the tiles-defs.xml file contains an XML preamble
specifying a remote DTD, which one of the following changes to the struts-config.xml
prevents the application from accessing this remote DTD?
104.
Technique 1:
<action path="/test" forward="/test.jsp"/>
Technique 2:
<action path="/test"
type="com.test.struts.TestAction"/>
Referring to the above, assuming TestAction is a subclass of ForwardAction, which one of the
following choices is an advantage of using Technique 1 over Technique 2?
105. Which one of the following codes retrieves the same form information for every request
105.
Referring to the above, based on the testForm definition, how does the developer implement
the form bean?
The developer should not have to explicitly implement the form bean since this
configuration has a dynamic form bean.
106.
public class TestDispatchAction extends DispatchAction {
if (eInfo != null)
TestInfo2TestForm(ef, eInfo);
return mapping.findForward(ForwardConst.VIEW_DETAILS_SUCCESS);
}
A common Web application issue is the processing of "stale" forms. For example, a user may press the back
button to return to a submitted form and resubmit the form again.
How does the developer prevent the above from happening in TestDispatchAction?
The developer uses getResources() to determine if this resource was already used.
The developer uses getServlet() to determine if the same instance of the application
servlet is being used.
The developer uses isCancelled() to determine if the cancel button was pressed.
107.
Referring to the above, which one of the following actions does the developer take to ensure
integrity with the struts-config.xml?
Referring to the above, which one of the following changes the scope of the copy bean from
request to session?
<bean:copy id="copy" name="test"
fromScope="request" toScope="session"/>
<bean:define id="copy" name="test" copy="true"
scope="request" toScope="session"/>
<bean:define id="copy" name="test"
scope="request" toScope="session"/>
<bean:define id="copy" name="test" copy="clone"
scope="request" toScope="session"/>
<bean:define id="copy" name="test"
fromScope="request" toScope="session"/
109.
<!-- message resources -->
<message-resources
parameter="ApplicationResources"
/>
Referring to the above, a developer has changed the message-resources tag to include
null="false". What is the developer trying to do?
110.
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
Referring to the above, which one of the following tags can the application use with the JSP
taglib definition?
<html:xhtml>
<html:bundle>
<html:template>
<html:xsl>
<html:empty>
111.
Referring to the above, which one of the following choices below allows the creation of a
Struts-aware HTML form?
<%@
112.
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> %>
Referring to the above, assuming the variable testConfig contains a cloned instance of
MyTestConfig, which one of the following changes the struts global exception handler to
handle java.lang.NullPointerException?
testConfig.setPath("java.lang.NullPointerException");
testConfig.setScope("session, java.lang.NullPointerException");
testConfig.setType("java.lang.NullPointerException");
testConfig.setHandler("java.lang.NullPointerException");
testConfig.setKey("java.lang.NullPointerException");
113.
Referring to the above, which one of the following choices resets the value of userid as
defined in the struts-config.xml?
set("userid", FormBeanConfig.getName("userid"))
((DynaActionForm) form).initialize(mapping)
reset(ActionForward, ServletRequest)
set("userid", getDynaProperty("userid"))
reset(ActionRedirect, HttpServletRequest)
The example above shows two substitution parameters. Using the Struts MessageResources
format, what is the maximum number of substitution parameters that are supported per
value string?
115. What is the correct syntax for removing ActionMessages from the session context?
request.getSession().saveErrors(session, null);
Action.removeErrors();
Action.saveErrors(session, null);
Action.clearErrors(session, null);
116.
<struts:text
pattern="/^[1-9]{4,6}$/"
property="test"
errorMessage="PLACE HERE"/>
Referring to the above, assuming that the <struts:text> tag has an extension called pattern
that can accept regular expressions, which one of the following error messages, substituted
for "PLACE HERE," provides a descriptive error for the pattern?
This property requires 1 to 9 digits and must contain either a 4 or a 6 but not both.
117.
<form-bean name="testForm" type="org.apache.struts.validator.LazyValidatorForm">
<form-property name="testMap" type="java.util.TreeMap" />
<form-property name="testBeans"
type="org.apache.commons.beanutils.LazyDynaBean[]" />
</form-bean>
Referring to the ApplicationContext.xml snippet above, which one of the following is a valid
reason for explicitly defining mapped or indexed properties?
The developer wants to use a different type of collection from the default.
The developer wants to specify a List type for the collection since this is not the
default.
118.
Referring to the above, assuming the formBean variable has been assigned to the
DynaValidatorForm, which one of the following allows the application to retrieve the value of
"age"?
119. A developer received a request to create a Struts action that will download a file from
the application server to the user's desktop with a dynamic buffer size set by a request
parameter.
How does the developer accomplish the above task?
By subclassing the DownloadAction, defining this class in the web.xml file, and
overriding the getBufferSize() method to return the request parameter.
By subclassing the DownloadAction, defining this class in the struts-config.xml file, and
setting the DEFAULT_BUFFER_SIZE to the incoming size on the request parameter.
By subclassing the DownloadAction, defining this class in the strutsconfig.xml file, and creating a setBufferSize() method to set the value from
the request parameter and override the getBufferSize() to return this value.
120. Which one of the following tasks does a developer perform to create a pluggable
validator?
121. A developer has designed a banking Struts application that requires user authentication
(userid and password). This application contains 30 Action classes. At a minimum, what does
each of the Action classes implement?
122.
<html:select name="TestBean" property="testCd">
<html:option value="-1">--Select--</html:option>
<logic:present name="TestBean" property="test" >
<logic:iterate name="TestBean" property="test" id="testList" scope="request">
<option value="<bean:write name='testList' property='ident'/>">
<bean:write name='testList' property='applicants'/>
</option>
</logic:iterate>
</logic:present>
</html:select>
In the sample tag code above, a selection is made and sent to the Action class, but the JSP
does NOT retain the selection. Assuming the form bean is populated correctly, how do you
correct this tag to retain the correct selection for each user session?
Use the <html:select> and <html:option> tag in conjunction with the <html:options>
tag and the logic tags should be retained.
Use the <html:select> and <html:option> tag in conjunction with the <html:options>
tag and the logic tags should not be retained.
123. A user requires that a home page have the ability of switching languages dynamically
(for example, between English and Spanish by simply clicking on a link in the JSP page).
How do you design a Struts application to support the feature above?
Design the application to have a mapping for ActionLocale and contain links on the
home page to pass language to this mapping.
Design the application to set the session attribute to Action.LANGUAGE_KEY for the
incoming lang request parameter.
Design the application to have the locale set to true in the init parameter configuration
of the ActionServlet.
Design the application to have a mapping for LocaleAction and contain links
on the home page to pass language to this mapping.
124. Which one of the following statements describes the Struts architecture?
Model 1 MVC architectural approaches are possible in Struts but should only
be done for simple applications with few pages.
Struts Model 2 MVC architecture has JSP as a controller for processing request.
The ActionRedirect method getOriginalPath() will return all values added by the
addParameter() method.
126. - Create an action class to process a user registration. When the cancel button
is pressed, remove all data from the database for the associated user and provide
the message "registration successfully cancelled".
Referring to the above, how does the developer accomplish the design spec task?
By subclassing the DispatchAction class and overriding the method execute to perform
the delete and the message save
saveErrors(HttpServletRequest, ActionMessages);
saveMessages(HttpServletRequest, ActionMessages);
saveMessages(ServletRequest, ActionMessages);
saveErrors(HttpSession, ActionMessages);
saveMessages(HttpSession, ActionMessages);
128.
public class LoginAction extends Action {
Using the sample above and assuming the loginForm.reset() method was not defined, what
happens when actionForm.reset() is invoked?
The form values are initialized with the default reset() implementation. (Not
sure)
129.
scope
parameter = "LOGGED_IN"
scope
scope
validate = "true"
= "page"
= "request"
= "application"
130.
REQUEST ---> CONTROLLER
|
MODEL
^
|
RESPONSE <--- VIEW
Given the sample MVC diagram above, what is the relationship between Model-ViewController (MVC) components?
The Model component interacts with the Controller component by using the View as an
aspect adapter.
131. What is the correct helper action syntax needed to create a dispatcher that invokes the
equivalent of a MappingDispatchAction method contained within the struts-config.xml?
132.
Given the following code:
RequestDispatcher rd =
request.getRequestDispatcher("/logon.jsp");
rd.forward(request, response);
A user session has timed out and must be authenticated. The parameter "timeout=yes"
must be sent to indicate this condition.
Referring to the above, assuming the sample code contains a reference to the timeout
parameter, which one of the following represents the equivalent syntax?
133. Which one of the following statements about a Struts Module is correct?
It allows the developer to segregate the application into different modules to allow for
easier configuration.
It can have only one configuration file for all module definitions.
134.
to the example configuration in struts-config.xml shown above, how does the application
process this exception?
The invalid configuration does not allow the Struts application to start.
Mapping
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
<struts-config>
<!-- Form Bean Definitions -->
<form-beans>
<form-bean name="testForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userid" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
</form-beans>
Execute method signature:
Referring to the above, which one of the following happens when the application excecutes the code:
String[] formValues = (String[]) form.get(name);?
The application sets the value of formValues with the values from testForm.
}
}
Referring to the above, assuming the default cancelled() implementation, which one of the choices below
contains the value for ActionForward af = TestDispatchAction.cancelled(mapping, form);?
af is set to null;