Java EE 6 Web Component Developer Certified Expert Exam

QUESTION NO: 30

A method call inside your servlet has thrown an IOException resulting from a lost network connection to a necessary resource. The servlet has determined that it will be unable to operate successfully fen few minutes, but expects to be able to resume operation after that period. How should this situation handled?

A. The servlet should re-throw the exception to the web container.

B. The servlet should throw a servletException to the web container.

C. The servlet should throw an unavailableException to the web container.

D. The servlet should redirect to an error page that reports the exception message.

E. The servlet should retry the request until the method returns successfully.

Answer: C

Reference: http://jcp.org/aboutJava/communityprocess/first/jsr053/servlet23_PFD.pdf (page 26, topic: 2.3.3.2, first paragraph)

QUESTION NO: 31

During initialization, a servlet finds that the database connection it requires is unavailable. As the system designer, you know that the database start up completes several minutes after the web- container initializes the servlet. How should this be handled?

A. Retry the connection until it is successful, then allow the init () method to complete.

B. Throw a ServletException

C. Throw the IOException

D. Throw an UnavailableException

Answer: D

Reference: http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets6.html

QUESTION NO: 32

A servlet wishes to indicate that it is unable to initialize at the present time, but that the initialization might succeed at some future time. Which is true?

A. This cannot be expressed. A servlet either initializes correctly or fails.

B. This expression is not necessary. If a servlet fails to initialize, the container will try again later each time a request is received that attempts to invoke that servlet.

C. The servlet should delay until it is ready to complete initialization successfully.

D. The servlet should throw an UnavailableException

E. The servlet should throw a servletException

Answer: E

QUESTION NO: 33

You are implementing a model component. You realize that an IOException might arise if you lose connection to the database. How should you address this?

A. Implement multipathing to provide redundant connectivity to the database, thereby avoiding that risk of connection failure.

B. Provide an error handler page, and use the page directive in the invoking ISP to redirect to that page if the error arises.

C. Use the JSTL <c:catch> tag to take control if the exception arises.

D. Surround the problem area with a try/catch block and implement appropriate recovery or fallback behavior.

Answer: C

Reference: http://www.ibm.com/developerworks/java/library/j-jstl0318/ (topic: exception handling)

QUESTION NO: 34

Which is a valid value for the enum EmptyRoleSemantic in Javax.servlet.annotation.ServletSecurity?

A. ADMIT

B. PERMIT

C. EXCLUDE

D. DENYALL

E. ALLOWALL

Answer: B

Reference: http://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/annotation/ServletSecurity.EmptyRoleSemantic.html

QUESTION NO: 35

Given the annotation for MyServlet:

@WebServlet{"/abc")

@ServletSecurity (value=@HttpConstraint)

public class Myservlet extends Httpservlet {

Which two are true? (Choose two)

A. No protection of user data must be performed by the transport.

B. All user data must be encrypted by the transport.

C. Access is to be denied independent of authentication state and identity.

D. Only authenticated users are to be permitted.

E. Access is to be permitted independent of authentication state and identity.

Answer: B, C

QUESTION NO: 36

Which of the following annotations relate to security in a servlet?

(i) @WebSecurity

(ii) @RolesAllowed

(iii) @WebConstraint

(iv) @HttpConstraint

(v) @Servletsecurity

A. (i) only

B. (i) and (iii)

C. (iv) and (v)

D. (iii) and (v)

E. (ii) and (iv)

Answer: C

QUESTION NO: 37

Which element of a web application deployment descriptor <web-resource-collection> element is used to specify a HTTP method to which the corresponding <security-constraint> will not apply?

A. <exclude-http-method>

B. <neglect-http-method>

C. <http-method-omission>

D. <http-method-excluded>

E. <exceptional-http-method>

Answer: C

Reference: http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd (search http-method-omission)

QUESTION NO: 38

Which two statements are true about the security-related tags in a valid Java EE deployment descriptor? (Choose two)

A. Every <security-constraint> tag must have at least one <http-method> tag.

B. A <security-constraint> tag can have many <web-resource-collection> tags.

C. A given <auth-constraint> tag can apply to only one <web-resource-collection> tag.

D. A given <web-resource-collection> tag can contain from zero to many <url-pattern> tags.

E. It is possible to construct a valid <security-constraint> tag such that, for a given resource user roles can access that resource.

Answer: B, E

QUESTION NO: 39

A cookie may be set to be an HttpOnly cookie. Setting a cookie to be HttpOnly results in (Choose two)

A. Client to not expose the cookie to client side scripting code

B. Does not work with https protocol

C. prevent certain types of cross-site scripting attacks

D. There is no such thing as an HttpOnly cookie

Answer: A, C

Reference: http://docs.oracle.com/javaee/6/api/javax/servlet/http/Cookie.html

QUESTION NO: 40

A popular Ajax framework and its companion widget library contain several hundreds of files of different types (.js, .ess, .html). Your company has mandated that all its web applications use only specific versions of this framework approved by IT and repackaged internally as jar files. Furthermore, web applications should only include the entire jar, without subsetting or modification.

Where should the framework's files be placed inside a jar file to enable this kind of reuse?

A. under resources

B. under META-INF/resources

C. under META-INF/web-contents

D. under WEB-INF/resources

Answer: B

Reference: http://ocpsoft.com/opensource/create-common-facelets-jar/ (check the box with the update)

QUESTION NO: 41

Which two actions protect a resource file from direct HTTP access within a web application? (Choose two)

A. placing it in the /secure directory

B. placing it in the /WEB-INF directory

C. placing it in the /META-INF/secure directory

D. creating a <web-resource> element within the deployment descriptor

E. creating a <secure-resource> element within the deployment descriptor

Answer: B, C

QUESTION NO: 42

In which two locations can library dependencies be defined for a web application? (Choose two)

A. the web application deployment descriptor

B. the /META-INF/dependencies.xml file

C. the /META-INF/MANIFEST.MF manifest file

D. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath

Answer: C, D

QUESTION NO: 43

The jquery_1_3_2.jar file contains the JQuery Ajax framework in its META-INF/ resources directory. Where should the jar file be placed inside the web application to ensure the resources it contains are accessible by clients?

A. WEB-INF/classes

B. WEB-INF/jar

C. WEB-INF/lib

D. WEB INF/resources

Answer: C

Reference: http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html (topic: web modules, third paragraph)

QUESTION NO: 44

Given a jar file packaged with three web fragments with names X, Y and Z respectively.

Which of the following deployment descriptor, web.xml, snippets correspond to the web fragment processing orders of X, Y, Z?

(i) <absolute-ordering>

<name>X</name>

<name>Y</name>

<name>Z</name>

</absolute-ordering>

(ii) <absolute-ordering>

<name>X</name>

<name>Y</name>

</absolute-ordering>

(iii) <absolute-ordering>

</others>

<name>Y</name>

<name>Z</name>

</absolute-ordering>

(iv) <absolute-ordering>

<name>X</name>

</others>

<name>Z</name>

</absolute-ordering>

(v) <absolute-ordering>

<name>X</name>

<name>Y</name>

</others>

</absolute-ordering>

A. (i) only

B. (i) and (ii)

C. (i) and (iv)

D. (i), (iii), (iv) and (v)

Answer: C

Reference: http://blogs.oracle.com/swchan/entry/servlet_3_0_web_fragment

QUESTION NO: 45

Which defines the welcome files in a web application deployment descriptor?

A. <welcome>

<welcome- file >/ welcome - jsp</welcome-file>

</welcome>

<welcome>

<welcome-file>/index-html</welcome-file>

</welcome>

B. <we1come-file-list>

<welcome-file> welcome .jsp</welcome-file>

<welcome-file>index.html</welcome-file>

</welcome-file-list>

C. <welcome>

<welcome-file>welcome.jsp</welcome </we1come >

</welcome >

<welcome-file>index.html<//welcome-file>

</we1come >

D. <we1come-file-list>

<welcome-file> welcome .jsp</welcome-file>

<welcome-file>/index.html</welcome-file>

</welcome-file-list>

E. <welcome>

<welcome-file>

<welcome-name> welcome </welcome-name>

<location> welcome.jsp </location>

</welcome-file>

<welcome-file>

<welcome-name>index</welcome-name>

<location> index </location>

</welcome-file>

</welcome>

Answer: B

QUESTION NO: 46

Which code snippet specifies the metadata for a servlet with:

(i) url mapping “/mytest”’

(ii) Initial parameter with name “debug” and value “10”’

(iii) Support asynchronous operation?

A. @WebServlet("/mytest")

@InitParam(name-"debug" va1ue = "10")

@Asynchronous

public class TestServlet extends HttpServlet {}

B. @WebServlet (“/myset”)

@WebParam(name = “debug” value = “10”)

Public class testServlet {}

C. @WebServlet (urlPatterns = { / “mytest”},

Initparams = {@InitParam (name = “debug”, value = “10”) }, supportAsync = true)

public class TestServlet extends HttpServlet {}

D. @WebServlet (urlPatterns = { / “mytest”},

Initparams = {@InitParam (name = “debug”, value = “10”) }, asyncSupported = true)

public class TestServlet extends HttpServlet {}

E. @WebServlet (urlPatterns = { / “mytest”},

Initparam = @WebInitParam (name = “debug”, value = “10”), supportAsync = true)

public class testServlet {}

Answer: D

QUESTION NO: 47

Which annotation specifies the metadata as a javax.servlet.http.HttpSessionListener?

A. @Listener

B. @WebListener

C. @WebSessionListener

D. @HttpSessionListener

Answer: A

Reference: http://docs.oracle.com/cd/E12840_01/wls/docs103/webapp/annotateservlet.html (table 8-1, third row)

QUESTION NO: 48

You are creating a new ISP page and you need to execute some code that acts when the- page is first executed, but only once.

Which three are possible mechanisms for performing this initialization code? (Choose three)

A. In the init method.

B. In the jspInit method.

C. In the constructor of the JSP's Java code.

D. In a JSP declaration, which includes an initializer block.

E. In a JSP declaration, which includes a static initializer block.

Answer: B, D, E

QUESTION NO: 49

You are creating a web form with this HTML:

11. <form action="sendOrder.jsp">

12. <input type="text" name="creditCard">

13. <input type="text" name="expirationDate">

14. <input type="submit">

15. </form>

Which HTTP method is used when sending this request from the browser?

A. GET

B. PUT

C. POST

D. SEND

E. FORM

Answer: A

QUESTION NO: 51

Your web application requires the ability to load and remove web files dynamically to the web container’s file system?

Which two HTTP methods are used to perform these actions? (Choose two)

A. PUT

B. POST

C. SEND

D. DELETE

E. REMOVE

F. DESTROY

Answer: A, D

QUESTION NO: 52

A web application wants to expose to its clients an operation that results in a transaction being performed across several systems, for example the transfer of money from one bank account to another

Which HTTP method should it use?

A. GET

B. HEAD

C. OPT IONS

D. POST

Answer: D

Reference: http://en.wikipedia.org/wiki/POST_(HTTP )

QUESTION NO: 53

A Client wants to retrieve a representation of a resource, e.g. an XML document, localized according to the preferences of the user. Each user is allowed to specify one or more languages, in order of preference. Such preferences are application independent.

How can the Client send language preference Information to the Server using a standard HTTP facility?

A. In the request body

B. In a request header

C. In the request line

D. In the request URL

Answer: B

Reference: http://www.w3.org/International/questions/qa-lang-priorities.en.php (Check the answer, first paragraph)

QUESTION NO: 54

Which JSTL code snippet can be used to import content from another web resource?

A. <c:import url = “foo.jsp”/>

B. <c:import page = “foo.jsp”/>

C. <c:include url = “foo.jsp”/>

D. <c:include page = “foo.jsp”/>

E. Importing cannot be done in JSTL. A standard action must be used instead.

Answer: A

QUESTION NO: 55

In a jsp-centric shopping cart application cart application to move a client’s home address of Customer object into the shipping address of the order object. The address data is stored in a value object class called Address with properties for: street address, city, province, country, and postal code.

Which two code snippets can be used to accomplish this goal?

A. <c:set var='order' property='shipAddress'

value='${client.homeAddress}' />

B. <c:set target='${order}' property='shipAddress'

value='${client.homeAddress}' />

C. <jsp:setProperty name='${order}' property='shipAddress'

value='${client.homeAddress}' />

D. <c:set var='order' property='shipAddress'>

<jsp:getProperty name='client' property='homeAddress' />

</c:store>

E. <c:set target='${order}' property='shipAddress'>

<jsp:getProperty name='client' property='homeAddress' />

</c:set>

F. <c:setProperty name='${order}' property='shipAddress'>

<jsp:getProperty name='client' property='homeAddress' />

</c:setProperty>

Answer: B, E

QUESTION NO: 56

You are creating a JSP page to display a collection of data. This data can be displayed in several different ways so the architect on your project decided to create a generic servlet that generates a comma delimited string so that various pages can render the data in different ways. This servlet takes on request parameter: objoctID. Assume that this servlet is mapped to the URL pattern: /WEB-INF/data.

In the JSP you are creating, you need to split this string into its elements separated by commas and generate an HTML <ul> list from the data.

Which JSTL code snippet will accomplish this goal?

A. <c:import varReader='dataString' url='/WEB-INF/data'>

<c:param name='objectID' value='${currentOID}' />

</c:import>

<ul>

<c:forTokens items'${dataString.split(",")}' var='item'>

<li>${item}</li>

</c:forTokens>

</ul>

B. <c:import varReader='dataString' url='/WEB-INF/data'>

<c:param name='objectID' value='${currentOID}' />

</c:import>

<ul>

<c:forTokens items'${dataString}' delims=',' var='item'>

<li>${item}</li>

</c:forTokens>

</ul>

C. <c:import var='dataString' url='/WEB-INF/data'>

<c:param name='objectID' value='${currentOID}' />

</c:import>

<ul>

<c:forTokens items'${dataString.split(",")}' var='item'>

<li>${item}</li>

</c:forTokens>

</ul>

D. <c:import var='dataString' url='/WEB-INF/data'>

<c:param name='objectID' value='${currentOID}' />

</c:import>

<ul>

<c:forTokens items'${dataString}' delims=',' var='item'>

<li>${item}</li>

</c:forTokens>

</ul>

Answer: D

QUESTION NO: 57

Which JSP standard action can be used to import content from a resource called foo.jsp?

A. <jsp:import file='foo.jsp' />

B. <jsp:import page='foo.jsp' />

C. <jsp:include page='foo.jsp' />

D. <jsp:include file='foo.jsp' />

E. <jsp:import>foo.jsp</jsp:import>

F. <jsp:include>foo.jsp</jsp:include>

Answer: C

QUESTION NO: 58

Refer to the Exhibit.

083-c-38

Assuming the tag library in the exhibit is imported with the prefix forum, which custom tag invocation procedures a transaction error in a jsp page?

A. <forum:message from="My Name" subject="My Subject" />

B. <forum:message subject="My Subject">

My message body.

</forum:message>

C. <forum:message from="My Name" subject="${param.subject}">

${param.body}

</forum:message>

D. <forum:message from="My Name" subject="My Subject">

<%= request.getParameter( "body" ) %>

</forum:message>

E. <forum:message from="My Name"

subject="<%= request.getParameter( "subject" ) %>">

My message body.

</forum:message>

Answer: D

Site Search:

Close

Close
Download Free Demo of VCE
Exam Simulator

Experience Avanset VCE Exam Simulator for yourself.


Simply submit your e-mail address below to get started with our interactive software demo of your free trial.


Enter Your Email Address

Free Demo Limits: In the demo version you will be able to access only first 5 questions from exam.