Sei sulla pagina 1di 63

1.

Referring to the above, which one of the following choices below allows the creation of a Strutsaware HTML form?

<%@ page language="java" %>

<%@ <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

%@! taglib uri="/WEB-INF/struts-html.tld" prefix="html" %

<%@! page language="java" %>

Ans: <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

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 supports database access.

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.

Option 2 is required when using Struts v1.2.x or greater.

Option 2 is required when the application uses the Spring framework.


[Note:] You can define more than one message resource file. Therefore you must add a

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 subclassing the DefinitionDispatcherAction class and defining an execute method called


feature1 and feature2 in the subclass

By instantiating the DispatchAction class and defining an execute method called feature1 and
feature2

By subclassing the LookupDispathAction class and defining a method called


getKeyMethodMap in the subclass

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

Ans : By subclassing the LookupDispathAction class and defining a method called


getKeyMethodMap in the subclass

5.

Referring to the above, which code example clears the value from name?

public void clear(ActionMappingFactory mapping, HttpServletRequest


request) {
this.name = null;
}

public void clear(ActionMapping mapping, HttpServletRequest request) {


this.name = null;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {


this.name = null;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {


this.name.reset();
}

public void reset(ActionMappingFactory mappingFactory,


HttpServletRequest request) {
this.name = null;

Ans : public void reset(ActionMapping mapping, HttpServletRequest request) {

this.name = null;

6. When is it advisable to use a scriptlet in a JSP contained within a Struts application?

For simple logic contained within a JSP

To process primitive data types within a JSP

For math logic contained within a JSP

To present existing data that does not require additional processing

For calling execute method on the mapped Action class

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 DefinitionDispatcherAction class and


defining an execute method called build and test 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?

<action unknown="validate" type="com.test.struts.DefaultAction"/>

<action unknown="true" type="com.test.struts.DefaultAction"/>

<action unknown="true" validate="true" type="com.test.struts.DefaultAction"/>

<action mapping="unknown" validate="true" type="com.test.struts.DefaultAction"/>

<action unknown="false" type="com.test.struts.DefaultAction


Ans : <action unknown="true" validate="true" type="com.test.struts.DefaultAction"/>

[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.

Specify <form-property initial="java.lang.String"> in the Action configurationproperty>.


Specify <form-property allow_invalid=true> in the Action configuration
10.

Referring to the above, which one of the following prevents the execution of the LoginAction and
instead forwards to the Web resource /external/3rdpartylogin?

<action path="/login" redirect="/external/3rdpartylogin">

<action path="/login" name="/external/3rdpartylogin">

<action path="/login" parameter="/external/3rdpartylogin">

<action path="/login" type="test.LoginAction" redirect="/external/3rdpartylogin">

<action path="/login" forward="/external/3rdpartylogin

11.

Referring to the above, which one


of the following choices retrieves
the value from userid?

DynaActionForm lForm = (DynaActionForm)form;


String login = (String)lForm.getDynaProperty("userid").toString();

DynaActionForm lForm = (DynaActionForm)form;


String login = (String)lForm.getStrings("testForm");

DynaActionForm lForm = (DynaActionForm)form;


String login = (String)lForm.getDynaClass(userid);

DynaActionForm lForm = (DynaActionForm)form;


String login = (String)lForm.get("userid");

DynaActionForm lForm = (DynaActionForm)form;


String login = (String)lForm.get(userid);

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>

<field prop="pdesc" depends="onlywhen">


<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>

<field property="pdesc" validwhen="depends">


<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="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>

13. <logic:iterate id="userName" name="userNames">


<bean:write name="userName" property="label" />
</logic:iterate>
The sample above displays a list of user names, but it does not display a sequence number. Which
one of the following suggested approaches allows the example to display a sequence number?

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.

14. <action path="/updateProfile" type="org.apache.struts.actions.DispatchAction"


name="profileForm" scope="request" input="/profile.jsp" parameter="method"/>
Referring to the above, assuming the Struts ActionServlet is mapped to *.do, which request format invokes the
demographics() method?

/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

15. public class TestAction extends Action


{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward("test");
}
}
...

A developer attempts to use an ActionForward by calling mapping.findForward("test"). However, the Struts


application contains the same forward mapping name in two different modules (called modulex and moduley).
Referring to the above, how does the developer specify the "test" forward in "modulex"?

The developer creates an ActionForward instance that specifies "modulex."

The developer subclasses the ActionForward class and creates a public method called setModule().

The developer calls mapping.findForward("module=modulex", "test").

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().

16. How does Struts use the web.xml file?

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 limit the memory used by the application.

The developer wants to create different modules for clarity.

The developer wants to consolidate all properties into one file for maintainability.

The developer wants to define all properties in the struts-config.xml.

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 without setting the module property.

The path should be used without setting the contextRelative property.

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.

The path should be used with setting the redirect property

18.

Referring to the above how does the developer change the following sample to accept the request of format:
/edit*Customer?id=125?

The developer changes validate="false" to validate="edit".

The developer changes path="/edit*" to actionPath="/edit*".

The developer changes path="/edit*" to path="/edit\**".

The developer changes path="/edit*" to path="/(edit)\***".

The developer changes validate="false" to validate="wildcard

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.

Create a DispatchAction to handle several related tasks.

Create an HTML form that invokes the action mapping in struts-config.xml.

Define a bean that extends ActionForm.

Create an Action class to handle the request.

Modify struts-config.xml to map requests to an action class

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?

<action path="/login" input="/external/3rdpartylogin">

<action path="/login" type="test.LoginAction" execute="/external/3rdpartylogin">

<action path="/login" name="/external/3rdpartylogin">

<action path="/login" include="/external/3rdpartylogin">

<action path="/login" parameter="/external/3rdpartylogin

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?

It allows the Struts application to perform no operation.

It returns the next processing destination for the Struts application.

It allows the Struts application to clean up resources.

It allows the Struts application to use a dispatching action.

It allows the Struts application to use multiple modules

22. Which one of the following describes one function of an ActionForm?

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 cannot perform input validation on the html form.

The ActionForm acts like a firewall for HTML request parameters sent to a Struts application.

23. ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setContextRelative( true);

Referring to the above, which one of the following replaces the Sample ForwardConfig to achieve Struts 1.2.x
compliance?

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setContextRelative( false);

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setModule("/");

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setModule(default);

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setRedirect(true);

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setName( getServletConfig().getContext());

[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?

String password = (LoginForm) form.getPassword();

String password =(String) request.getAttribute("password");

request.getParameterNames().getParameter("password");

String password = request.getParameter("password");

String password = form.getPassword();

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>

26. Which one of the following is an attribute of action-mapping in the struts-config.xml?

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 uses instance variables in the Action classes.

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.

The developer uses local variables in the Action classes.

The developer specifies scope=session in the Action class definition.

Only Use Local Variables


The most important principle that aids in thread-safe coding is to use only local variables, not instance
variables , in your Action class. Local variables are created on a stack that is assigned (by your JVM) to
each request thread, so there is no need to worry about sharing them. An Action can be factored into
several local methods, so long as all variables needed are passed as method parameters. This assures
thread safety, as the JVM handles such variables internally using the call stack which is associated with
a single Thread.

[Note:]

28.

<action path="/login" type="com.test.LoginAction">


<forward name="success" path="/mainMenu.jsp"
[put code here] />
</action>
Referring to the above, which one of the following uses the RequestDispatcher.forward() ?

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?

The loginForm bean properties are reset to null values.

The loginForm bean properties retain their existing values.

The application throws a ClassCastException.

The loginForm bean properties are reset to the new values.

The application throws a NullPointerException.

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?

Specify the "roles" attribute in the action mapping.

Call the java.security.Security.setProvider() with the location of the security class.

Develop a base Action class that contains the security infrastructure.

Subclass the RequestProcessor, define the security in this subclass, and plug this subclass in as the
processor.

Call the java.security.Security.getEngineClassName() with the location of the security class

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?

<html:link module="/test" path="/index.do"/>

/testModule.do?prefix=/test&page=/index.do

/test.do?prefix=/testModule&page=/index.do

<html:link module="/moduleB" path="/index.do"/>

/test.do?prefix=/test&page=/index.do

32. Which one of the following statements regarding ActionMapping is true?

ActionMapping classes map the request path to the ActionForward path.

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.

ActionMapping classes define the Struts request path.

33.

<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 not be retained.

Correct the tag <logic:iterate> to specify scope=application and the <logic:present> tag to specify
scope=request.

Correct the tag <logic:iterate> to specify scope=application.

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.

34. RedirectingActionForward = new RedirectingActionForward("/home/test.jsp");


Referring to the above, which one of the following creates an equivalent instance of RedirectingActionForward
class?

ActionForward af = new ActionForward(null, "/home/test.jsp", false);

ActionConfig af = new ActionConfig(null, "/home/test.jsp", true);

ActionForward af = new ActionForward(/home/test.jsp, true);

ActionForward af = new ActionForward("/home/test.jsp");


ActionForward af2 = af1.clone();

ActionForward af = new ActionForward("/home/test.jsp", true);

[Note:] Class RedirectingActionForward - A subclass of ActionForward that defaults the redirect


attribute to true.
35. ForwardingActionForward = new ForwardingActionForward("/home/test.jsp");
Referring to the above, which one of the following creates an equivalent instance of ForwardingActionForward
class?

ActionForward af = new ActionForward("/home/test.jsp", true);

ActionForward af = new ActionForward(/home/test.jsp);

ActionForward af = new ActionForward(null, "/home/test.jsp", true);

ActionForward af = new ActionForward("/home/test.jsp", false);

ActionForward af = new ActionForward(null, "/home/test.jsp", false);

[Note:] Class ForwardingActionForward - A subclass of ActionForward that defaults the redirect


attribute to false.
36.

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.

public class TestDispatchAction extends DispatchAction {


private TestMgr etMgr = null;
public ForwardAction viewDetails(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
TestForm ef = (TestForm)form;
// retrieve Test id from the request
String TestId = request.getParameter(RequestParams.Test_ID);
TestMgr etMgr = getTestMgr();
//retrieve Test by id
TestInfo eInfo = TestMgr.getTestById(getTestContext(request), new
Long(TestId).longValue());
// map TestInfo object to TestForm object
if (eInfo != null)
TestInfo2TestForm(ef, eInfo);
return mapping.findForward(ForwardConst.VIEW_DETAILS_SUCCESS);
}
Which one of the following problems exists with the above DispatchAction example?

The viewDetails method has an invalid declaration.

TestDispatchAction must define the setServlet() method.

DispatchAction cannot be subclassed since it is final.

The viewDetails method returns the wrong type.

The viewDetails method requires a default forward declaration.

[Note:] It should have been actionForward and not ForwardAction


38.

Referring to the above, which one of the following prevents the execution of the LoginAction and instead forwards
to the Web resource /external/3rdpartylogin?

<action path="/login" forward="/external/3rdpartylogin">

<action path="/login" redirect="/external/3rdpartylogin">

<action path="/login" parameter="/external/3rdpartylogin">

<action path="/login" type="test.LoginAction"


redirect="/external/3rdpartylogin">

<action path="/login" name="/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.

The application throws java.lang.IllegalStateException.

The application throws java.lang.NullPointerException.

The application throws java.lang.ArrayOutOfBoundsException.

The application throws java.lang.IllegalArgumentException.

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?

Change the validation to precision="long,longRange.

Change the validation to depends="int,intRange.

Limit the number of decimal places allowed in the field.

Limit the number of significant digits allowed in the field.

Change the validation to precision="double,floatRange

41.

an 24, 2006 7:17:17 AM org.apache.coyote.http11.Http11Protocol init


SEVERE: Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
Upon startup, the ActionServlet throws the above exception. How does the developer resolve this problem?

By investigating whether or not another application is using TCP port 8080.

By recompiling the application

By redeploying the application

By changing the Java virtual machine to 1.4 or greater

By changing the J2EE release 1.3 or greater

42. For the Struts config, each <action> element under <action-mapping> represents which one of the
following?

A module instance that the controller servlet creates

An ActionMapping instance that the controller servlet creates

An instance of the RequestProcessor

An ActionForward instance that the controller servlet creates

A ForwardConfig instance that the controller servlet creates

42.

resource bundle:
Cannot find message resources under key org.apache.struts.action.MESSAGE

Which one of the following explains the error shown above?

The forward config is missing from the struts-config.xml.

The ApplicationResources resides in the application classpath.

The init parameter definition for the application property specifies the location of the file.

The struts-config.xml contains multiple message resource configurations.

The <message-resources> tag has an invalid parameter setting.

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 creates the file error.jsp.

The developer defines a class which extends org.apache.struts.action.ExceptionHandler and returns the
ActionError type.

The developer declares a <global-exceptions> of type org.apache.struts.action.ExceptionHandler.

The developer declares a <global-exceptions> entry and a subclass of


org.apache.struts.action.ExceptionHandler.

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?

The "Model" component is defined by ActionServlet and ControllerConfig classes.

The "Model" component is defined by ActionServlet class.

The "Model" component is defined by Action classes.

The "Model" component is defined by JavaBeans and Enterprise JavaBeans.

The "Model" component is defined by other JSPs and Servlet definitions.

[Note:]

ActionServlet is the controller, View is the JSP.

45. <bean:define id="copy" name="test"/>


Referring to the above, which one of the following changes the scope of the copy bean from request to session?

<bean:define id="copy" name="test" copy="true"


scope="request" toScope="session"/>

<bean:define id="copy" name="test"


fromScope="request" toScope="session"/>

<bean:define id="copy" name="test" copy="clone"


scope="request" toScope="session"/>

<bean:define id="copy" name="test"


scope="request" toScope="session"/>

<bean:copy id="copy" name="test"


fromScope="request" toScope="session"/>

is not specified, the bean will be created in page scope.


The copy and fromScope attributes do not exist.
[Note:] If the toScope attribute

45.

Referring to the above, which code example clears the value from name?

public void reset(ActionMapping mapping, HttpServletRequest request) {


this.name = null;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {


this.name.reset();
}

public void clear(ActionMapping mapping, HttpServletRequest request) {


this.name = null;
}

public void reset(ActionMappingFactory mappingFactory, HttpServletRequest


request) {
this.name = null;
}

public void clear(ActionMappingFactory mapping, HttpServletRequest request) {


this.name = null;
}

Ans: public void reset(ActionMapping mapping, HttpServletRequest request) {

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?

Call setPush(true) followed by setKey("COMPILED_KEY") within the application.

Change <set-property property="key" value="TEST_KEY"/> to <set-property


property="key" value="COMPILED_KEY"/> and also restarts the application.

Change <set-property property="key" value="TEST_KEY"/> to <set-property property="key"


value="COMPILED_KEY"/> .

Call setPush(false) followed by setKey("COMPILED_KEY") within the application.

Call setKey("COMPILED_KEY") followed by storeGeneratedObject (obj) within the application.

47.

<action path="/updateProfile" type="org.apache.struts.actions.DispatchAction"


name="profileForm" scope="request" input="/profile.jsp" parameter="method"/>
Referring to the above, assuming the Struts ActionServlet is mapped to *.do, which request format invokes the
demographics() method?

/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?

<action path="/login" type="test.LoginAction" configured="true">

<action path="/login" type="test.LoginAction" scope="request">

<action path="/login*" type="test.LoginAction" unknown="true">

<action path="/login" type="test.LoginAction" configured="false">

<action path="/login" type="test.LoginAction" unknown="true">

[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

Subclasses Action and creates an internal mapping for each function

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);

[Note:] If messages=false then use saveErrors(HttpSession session, ActionMessages errors).


If messages=true then use saveMessages(HttpSession session, ActionMessages messages).
52. Your development team lead has identified that the ActionMappings of a Struts module can be consolidated
using wildcard mappings.
Which one of the following is a valid reason for performing the above consolidation?

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?

Instantate a subclass of MessageResources.

Instantiated the MessageResourceFactory by calling the createFactory() method.

Invoke the API setReturnNull(false) on the factory instance.

Implement the createResources() method and return a MessageResourceFactory instance.

Implement the getFactoryClass() and return the name of the factory instance.

54.

<% if (x.size()==0 || y.size()==0) { %>


<bean:write name="test" property="testName" />
<%}%>
Referring to the above, which one of the following choices can be substituted for the JSP Scriptlet?

<logic:empty name="x" || "y">


<bean:write name="test" property="testName" />
</logic:empty>
<logic:empty name="x">
<bean:write name="test" property="testName" />
</logic:empty>
<logic:notEmpty name="x">
<logic:empty name="y">
<bean:write name="test" property="testName" />
</logic:empty>
</logic:notEmpty>
<logic:empty name="x" name2="y">
<bean:write name="test" property="testName" />
</logic:empty>
<logic:empty name="x,y">
<bean:write name="test" property="testName" />
</logic:empty>
<logic:empty name="x","y">
<bean:write name="test" property="testName" />
</logic:empty>

55. How does a developer enforce the client side validation in Struts?

By removing the <html:javascript> from the JSP page

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 Action class did not subclass DispatchAction.

The Action class did not implement the FormDefs interface.

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.

58. <html:link action="/bigapp/test">


A developer wishes to set the hreflang=es on the link generated by <html:link>.
How does the developer accomplish the above task?

By setting the tag value to <html:link action="/bigapp/test" hreflang="es">

By upgrading to Struts 1.2.7 or greater and setting the tag value to <html:link action="/bigapp/test?
lang=es">

By 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 extends the configuration of ActionServlet by adding additional functionality.

It can have only one configuration file for all module definitions.

It can be associated with multiple names.

It is mandatory in a typical struts application.

61.

ActionConfig ac1 = new ActionConfig();


ac1.setPath("/*Action");
ac1.setForward("/done{1}.jsp");
ActionConfig [] ac2 = new ActionConfig [1];
ac2[0] = ac1;
ActionConfigMatcher am = new ActionConfigMatcher(ac2);
ActionConfig ac = am.match("myAction");
What is the value of ac.getForward() after execution of the sample code shown above?

/donemy.jsp

donemy.jsp

/done.jsp

/done{1}.jsp (Not sure)

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 servlet config (web.xml) should specifiy the config parameter.

The ActionServlet does not start since the action servlet is mapped to <url-pattern> /do1/*
and must be mapped to /do/*.

The web.xml should specify the appResources parameter.

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.

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setContextRelative( true);
Referring to the above, which one of the following replaces the Sample ForwardConfig to
achieve Struts 1.2.x compliance?

66.

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setName( getServletConfig().getContext());

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setRedirect(true);

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setModule(default);

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setModule("/");

ForwardConfig forwardConfig = new ForwardConfig();


forwardConfig.setContextRelative( false);

Which one of the following is NOT an attribute of the <global-exceptions> element?

exceptionHandler

bundle

scope

className

key

For the Struts config, each <action> element under <action-mapping> represents which
one of the following?
67.

An instance of the RequestProcessor

A ForwardConfig instance that the controller servlet creates

An ActionMapping instance that the controller servlet creates

A module instance that the controller servlet creates

An ActionForward instance that the controller servlet creates

68.

Locale locale = org.apache.struts.util.RequestUtils.getUserLocale(request, locale);


Assume: request is of type javax.servlet.HttpServletRequest and locale is of type
java.lang.String.

Referring to the above, what does the RequestUtils.getUserLocale(request, locale) method


return in the Struts application if locale is null?

Null

en_us

default_locale

request_locale

The locale as defined by the request headers or the server's locale.

[Note:] The method returns the current user locale


69.

Which one of the following about the org.apache.struts.action.Action class is true?

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.

It should be coded with a synchronized block if read-only access to a static variable is


required.

It associates with the servlet instance that created it.

It contains provisions for thread-safe processing across multiple threads

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?

<html:link module="/test" path="/index.do"/>

/testModule.do?prefix=/test&page=/index.do

/test.do?prefix=/testModule&page=/index.do

/test.do?prefix=/test&page=/index.do

<html:link module="/moduleB" path="/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 <html:option> tag specifies the attribute scope=request

The <logic:present> tag performs an operation on the test property before the
<html:option> tag.

The <logic:iterate> tag performs an iteration over the <html:option> tag.

The tag <html:options> specifies property="applicants".

The <html:option> tag specifies the attribute retain=true

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" prefix="html" %>

<%@

<%@ page language="java" %>

<%@! page language="java" %>

<%@! taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<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>

<td align="left"><html:text property="test" maxlength="5"/></td>


<td><html:errors property="test"/></td>
</tr>
</table>

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 allows multiple languages to be supported with a single application.

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.

It supports separate applicationContext.xml files to support multiple languages.

It allows up to 256 separate languages to be supported by the application.

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?

<controller inputForward="com.test.struts.DefaultAction" />

<controller processorClass="com.test.struts.DefaultAction" />

<controller defaultAction="com.test.struts.DefaultAction" />

<action unknown="true"

<controller forwardPattern="/test*" />

type="com.test.struts.DefaultAction"/>

82. Which instantiation of ActionForward sets the contextRelative parameter?


public ActionForward(java.lang.String name,
java.lang.String path,
boolean contextRelative,
java.lang.String module)
public ActionForward(java.lang.String name,
java.lang.String path,
boolean redirect,
boolean contextRelative)
public ActionForward(java.lang.String name,
java.lang.String path,
boolean redirect)
public ActionForward(java.lang.String name,
java.lang.String path,
boolean redirect,
java.lang.String module)
ActionForward(java.lang.String, boolean)

83. The definition of the Struts <controller> was moved from servlet initialization parameters

to the struts-config.xml file.


Based on the scenario above, for which one of the following reasons was the <controller>
element in struts-config moved to struts-config.xml?

84.

To allow different module configurations for the application. (not sure)

To allow faster servlet startup for the application.

To allow faster servlet shutdown for the application.

To allow different inputForward configurations for the application.

To allow specification of the forwardPattern for the application.

Referring to the above, which one of the following allows the LoginBean action form to be
associated with the LoginAction?

<action path="/login" type="test.LoginAction" multipartClass="LoginBean">

<action path="/login" type="test.LoginAction" parameter="LoginBean">

<action path="/login" type="test.LoginAction"


multipartClass="LoginBean.class">

<action path="/login" type="test.LoginAction" attribute="LoginBean">

<action path="/login" type="test.LoginAction" name="LoginBean">

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?

By saving the ActionErrors in the response context

By specifying global=true in the action configuration

By specifying savemessages=true in the action configuration

By saving the ActionErrors in the session context (not sure)

By specifying saveerrors=true in the action configuration

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>

Referring to the above, assume request /login.do results in mapping.findForward("failx").


Which JSP is invoked next?

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?

<field property="pdesc" validwhen="depends">


<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>
<field property="pdesc">
<arg0 key="pdesc.label"/>
<var>
<var-name>test</var-name>
<var-value>((problemCheck == null) or (*this* != null))</var-value>
</var>
</field>
<field prop="pdesc" depends="onlywhen">
<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="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?

Immediately--as soon as the file is saved

As soon as the application is restarted

After one minute--as soon as the file is saved

Not until the application is redeployed

Upon the next request sent to the ActionServlet

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

91. How are <form-bean> entries used in a typical Struts application?

A single <form-bean> entry usually maps to several diverse HTML or JSP pages.

A <form-bean> entry determines which ActionMapping is used.

A <form-bean> entry determines whether JSP or HTML is used.

A <form-bean> entry is used only in Struts 1.0 or earlier applications.

A <form-bean> entry determines which ActionForm is used.

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 retrieves the source code for org.apache.struts.action.ActionMapping


and adds the custom 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.

Referring to the above, assuming mapping is an instance of ActionMapping, which forward


usage displays page details.html?

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?

Subclass the PropertyResourcesFactory class and implement the createResources


method to retrieve the values from the database.

Subclass the MessageResourcesFactory class and implement the createResources


method to retrieve the values from the database.

Subclass the MessageResourcesConfig class and implement the getFactory method to


retrieve the values from the database.

Export this database table to a key/value mapped property resource bundle


and define the location of this file with <message-resources>.

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.

<set-property property="STOP_ON_FIRST_ERROR" value="false"/>

Change the configuration to: <set-property property="stopOnFirstError"


value="true"/>.

Change the configuration to: <set-property property="stopOnFirstError" value="0"/>.

Change the configuration to: <set-property property="stopOnFirstError"


value="false"/>.

Change the configuration to: <set-property property="continue" value="true"/>.

Referring to the above, assuming TestUploadForm extends ActionForm, what else should
TestUploadForm define?

An integer to store the file size

A String to store the file name

A byte array to store the file contents

A FormFile type variable to store a reference to the file

A multipart media type

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:

<action path="/login" type="com.test.struts.LoginAction">


<forward name="success" path="/test.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>

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 requires a recompile for Technique 1.

A change to the test.jsp file name requires an application restart for Technique 1.

A change to the test.jsp file name requires a recompile for Technique 2.

A change to the test.jsp file requires an application restart for Technique 1.

A change to the test.jsp file name requires a recompile for Technique 1.

99. What do Struts Wildcard Mappings allow the developer to do?

To define a generic set of mappings that can be used across all actions

To define a complete set of actions for the Struts application

To define a complete set of modules for the Struts application

To define a limited set of JSP files for the Struts application

To increase performance of the the Struts application

100. Assuming a Struts application only has support for French, which one of the following

correctly defines the resource bundle?

<message-resources key="default" parameter="com.test.ApplicationResources"/>


<message-resources key="default_fr"
parameter="com.test.ApplicationResources_fr"/>

<message-resources key="default_fr_only"
parameter="com.test.ApplicationResources_fr"/>

<message-resources key="default" parameter="com.test.ApplicationResources"/>

<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?

In the event of a NullPointerException, an instance of ActionException using the key


exception.null.error is created if the NullPointerException is caught within the
LoginAction class.

Using declarative exceptions like exception.null.error eliminates the need


for NullPointerException try / catch blocks to be coded within the
LoginAction class.

The exception handler exception.null.error catches all NullPointerExceptions for only


/homePage.jsp.

NullPointerExceptions that occur within LoginAction are bypassed because of this


definition.

The exception handler exception.null.error catches all NullPointerExceptions for the


application.

102. <action path="/test" type="com.test.TestAction" >

Referring to the above, how does the developer map all unmapped requests to the
TestAction class?

The developer specifies <action path="/test" type="com.test.TestAction"


unknown="*">.

The developer specifies <action path="/test" type="com.test.TestAction"


unknown="false">.

The developer specifies <action path="/test" type="com.test.TestAction"


default="false">.

The developer specifies <action path="/test" type="com.test.TestAction"


default="true">.

The developer specifies <action path="/test" type="com.test.TestAction"


unknown="true">.

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?

<set-property property="definitions-parser-validate" value="true" />

<set-property property="parser-validate" value="true" />

<set-property property="definitions-parser-validate" value="false" />

<set-property property="moduleAware" value="false" />

<set-property property="local-only" value="true" />

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?

Using Technique 1 eliminates the need for the TestAction class.

Changes to the test.jsp file require a server restart for Technique 2.

Changes to the test.jsp file require a recompile for Technique 2.

Using Technique 2 eliminates the need for the TestAction class.

Changes to the test.jsp file require a recompile for Technique 1.

105. Which one of the following codes retrieves the same form information for every request

made by all clients?

MyForm form = (MyForm)pageContext.getAttribute("form_name",


PageContext.SESSION_SCOPE);

MyForm form = (MyForm)pageContext.getAttribute("form_name",


PageContext.SERVLET_SCOPE);

MyForm form = (MyForm)pageContext.getAttribute("form_name",


PageContext.APPLICATION_SCOPE);

MyForm form = (MyForm)pageContext.getAttribute("form_name",


PageContext.PAGE_SCOPE);

MyForm form = (MyForm)pageContext.getAttribute("form_name",


PageContext.REQUEST_SCOPE);

105.

Referring to the above, based on the testForm definition, how does the developer implement
the form bean?

The developer ensures the form bean is of type


org.apache.struts.action.DynaValidatorActionForm and eliminate the use of the <formproperty> tags.

The developer ensures the form bean is of type


org.apache.struts.action.ValidatorActionForm and eliminate the use of the <formproperty> tags.

The developer ensures the form bean is of type


org.apache.struts.action.DynaActionForm.

The developer ensures the form bean is of type


org.apache.struts.action.DynaValidatorForm and eliminate the use of the <formproperty> tags.

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 {

private TestMgr etMgr = null;

public ActionForward viewDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request,


HttpServletResponse response)
throws Exception{
TestForm ef = (TestForm)form;
// retrieve Test id from the request
String TestId = request.getParameter(RequestParams.Test_ID);
TestMgr etMgr = getTestMgr();
//retrieve Test by id
TestInfo eInfo = TestMgr.getTestById(getTestContext(request), new Long(TestId).longValue());
// map TestInfo object to TestForm object

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 generateToken(), saveToken(), and isTokenValid to


detect this condition.

The developer uses isCancelled() to determine if the cancel button was pressed.

The developer uses saveErrors() to determine if this condition is encountered

107.

Referring to the above, which one of the following actions does the developer take to ensure
integrity with the struts-config.xml?

The developer adds an init param setting configFactory to validating.

The developer adds an init param setting validating to true.

The developer deploys the application with J2EE 1.4 compliance.

The developer adds an init param setting integrity to true.

The developer adds an init param setting convertNull to true.

108. <bean:define id="copy" name="test"/>

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?

Check for default values in the ApplicationResources

Check for missing resources in the ApplicationResources

Substitute null values for spaces in the ApplicationResources

Prepare the application for functional testing

Prepare the application for production deployment

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?

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@! page language="java" %>

<%@! taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@

<%@ page language="java" %>

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)

114. label.help=Help is available {0} {1}.

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?

ActionMessages msg1 = new ActionMessages("clear");


Action.saveErrors(session, msg1);

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 a 4 and a 6.

This property requires 1 to 9 digits and must contain a 4 or a 6.

This property requires 1 to 9 digits and must contain either a 4 or a 6 but not both.

This property requires 4 to 6 digits and must contain a zero.

This property requires 4 to 6 digits and must not contain a zero.

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 include Struts automated validation.

The developer wants to use a different type of collection from the default.

The developer wants to lazily initialize the testMap property.

The developer wants to specify a List type for the collection since this is not the
default.

The developer wants to create an immutable testMap property.

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"?

String age = formBean.get("age");

String age = request.getSession().getAttribute("age");

String age = (String)request.getAttribute("age");

String age = (String)formBean.get("age");

String age = getServletContext().(String)formBean.get("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 defining the DownloadAction in the struts-config.xml file and setting the


DEFAULT_BUFFER_SIZE to the incoming size on the request parameter.

By subclassing the DispatchAction, defining this in the struts-config.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?

The developer subclasses ValidatorPlugIn class.

The developer defines a methodParams attribute consisting of Object, ActionForward,


Field, ActionErrors and HttpServletRequest.

The developer defines a methodParams attribute consisting of Object, FieldChecks,


Field, ActionErrors, and HttpServletRequest.

The developer subclasses the FieldChecks class.

The developer defines a methodParams attribute consisting of Object,


ValidatorAction, Field, ActionErrors, and HttpServletRequest.

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?

Code to check for session state

Local variables shared by each server thread

Secure Sockets Layer (SSL) code

Public key infrastructure code

Code to verify balance and payment information

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.

Correct the tag <logic:iterate> to specify scope=application.

Correct the tag <logic:iterate> to specify scope=application and the <logic:present>


tag to specify scope=request.

Correct the tag <logic:iterate> to specify scope=session and the


<logic:present> tag to specify scope=application

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.

Design the application to set the session attribute to Action.LOCALE_KEY to null to


accept the default page language

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.

A Model 2 Struts architecture can have multiple controller servlets.

A Model 1 Struts architecture consists of centralized control.

A Model 2 Struts architecture consists of decentralized control.

Struts Model 2 MVC architecture has JSP as a controller for processing request.

125. Which one of the following is true regarding an ActionRedirect?

An ActionRedirect is a subclass of ForwardConfig and can accept a ForwardConfig


instance on a constructor to copy the configuration.

An ActionRedirect performs the same function as an ActionForward.

ActionForward and ActionRedirect both support adding parameters at runtime.

The ActionRedirect method getOriginalPath() will return all values added by the
addParameter() method.

An ActionRedirect is a subclass of RedirectConfig and can be cloned using the


ForwardConfig constructor

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 cancelled


to perform the delete and the message save

By subclassing the DispatchAction class and overriding the method unspecified to


perform the delete and the message save

By subclassing the DispatchAction class and overriding the method execute to perform
the delete and the message save

By subclassing the MappingDispatchAction class and creating a method called


processCancel to perform the delete and the message save

By subclassing the DispatchAction class and overriding the method dispatchMethod to


perform the delete and the message save

127. JSP contains the tag:


<html:messages/>
at the top of the page.
Referring to the above, which one of the following methods allows the Action to display all
messages in the session scope?

saveErrors(HttpServletRequest, ActionMessages);

saveMessages(HttpServletRequest, ActionMessages);

saveMessages(ServletRequest, ActionMessages);

saveErrors(HttpSession, ActionMessages);

saveMessages(HttpSession, ActionMessages);

128.
public class LoginAction extends Action {

private UserMgr userMgr = null;


/**
*
*/
public ActionForward execute (ActionMapping mapping, ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {

ActionForward forward = new ActionForward();


LoginForm loginForm = (LoginForm) form;
loginForm.reset();
// Call services to login the user
MRepContext ctx = userMgr.login(null, loginForm.getLoginName(),
loginForm.getPassword());
if ( ctx == null) {
// Forward control to the appropriate 'failure' URI (change name as desired)
forward = mapping.findForward("failure");
} else {
HttpSession session = request.getSession();
session.setAttribute(SessionParams.MREP_CONTEXT, ctx);
// Forward control to the appropriate 'success' URI (change name as desired)
forward = mapping.findForward("success");
}
// Finish with
return (forward);
}
/**
*
* @param uMgr
*/
public void setUserMgr(UserMgr uMgr){
this.userMgr = uMgr;
}
}

Using the sample above and assuming the loginForm.reset() method was not defined, what
happens when actionForm.reset() is invoked?

The application throws a ClassCastException.

The application throws a NullPointerException.

The loginForm values are reset to the default values.

The form values are initialized with the default reset() implementation. (Not
sure)

The Java virtual machine throws an IllegalStateException.

129.

Assuming the DialogLoginActionComponent performs a user authentication and the user


should only have to authenticate once for multiple sessions, which one of the following
changes to the action mapping property allows the user to always remain logged in?

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 state of the Model component depends on the View component.

The View component behavior is determined by the contents of the Model.

The Model component interacts with the Controller component by using the View as an
aspect adapter.

The Model component behavior is determined by the contents of the View.

The Controller component behavior depends on the View component

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?

protected DispatchAction dispatcher


= new DispatchAction(this, ActionDispatcher.DEFAULT_FLAVOR);

protected DispatchAction dispatcher


= new DispatchAction(this, ActionDispatcher.DISPATCH_FLAVOR);

protected ActionDispatcher dispatcher


= new ActionDispatcher(this, ActionDispatcher.MAPPING_FLAVOR);

protected ActionDispatch dispatcher


= new ActionDispatch(this, ActionDispatcher.MAPPING_FLAVOR);

protected DispatchAction dispatcher


= new DispatchAction(this, ActionDispatcher.MAPPING_FLAVOR);

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?

return (new ActionForward(/logon.jsp?timeout=yes));

return (new ActionForward("/logon.jsp?timeout=yes"));

ActionForward af = new ActionForward("/logon.jsp");


af.addParameter("timeout", "yes");
return af;

return (new ActionRedirect("/logon.jsp?timeout=yes"));

return (new ActionRedirect(/logon.jsp?timeout=yes));

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 extends the configuration of ActionServlet by adding additional functionality.

It can have only one configuration file for all module definitions.

It can be associated with multiple names.

It is mandatory in a typical struts application.

134.

to the example configuration in struts-config.xml shown above, how does the application
process this exception?

The application uses the java.lang.NullPointerExceptionHandler.

The invalid configuration does not allow the Struts application to start.

The application uses the com.test.LoginExceptionHandler.

The application throws a java.lang.RuntimeException.

The application produces a java.langIllegalStateException.

135. DynaActionForm Definition

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 throws java.lang.IllegalStateException.

The application sets the value of formValues with the values from testForm.

The application throws java.lang.ArrayOutOfBoundsException.

The application throws java.lang.IllegalArgumentException.

The application throws java.lang.NullPointerException.

136. ActionForward Signatures

public final class TestDispatchAction extends DispatchAction {


public ActionForward insert(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return (mapping.findForward("insertNext"));
}
public ActionForward update(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return (mapping.findForward("updateNext"));

}
}
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;

af is set to new ActionForward();


af is set to DispatchAction.dispatchMethod (mapping, form, request, response);
af is set to new ActionForward("null");
af is set to DispatchAction.cancelled(null,null);

137. Resource Bundle Specification

<message-resources key="general" parameter="general"/>


<message-resources key="specific" parameter="specific"/>
Assuming the keys:
welcome.txt=Welcome Back!
welcome.txt=Welcome Back Power user!
exist in separate resource bundles called general and specific, which one of the following
displays the "Power User" message?
<bean:message name="specific" arg0="welcome.txt"/>
<bean:message name="specific" key="welcome.txt"/>
<bean:message bundle="general" key="welcome.txt"/>

<bean:message bundle="specific" key="welcome.txt"/>


<bean:message key="specific" bundle="welcome.txt"/>

Potrebbero piacerti anche