310-083 Sun Certified Web Component Developer for J2EE 5 Set 6

You want to create a valid directory structure for your Java EE web application, and you want to

put your web application into a WAR file called MyApp.war. Which two are true about the WAR

file? (Choose two.)

A. At deploy time, Java EE containers add a directory called META-INF directly into the MyApp

directory.

B. At deploy time, Java EE containers add a file called MANIFEST.MF directly into the MyApp

directory.

C. It can instruct your Java EE container to verify, at deploy time, whether you have properly

configured your application's classes.

D. At deploy time, Java EE containers add a directory call META-WAR directly into the MyApp

directory.


Options are :

  • A,B
  • B,D
  • A,C
  • A,D

Answer : A,C

310-083 Sun Certified Web Component Developer for J2EE 5 Set 7

A developer is designing a multi-tier web application and discovers a need to log each incoming

client request. Which two patterns, taken independently, provide a solution for this problem?

(Choose two.)

A. Transfer Object

B. Service Locator

C. Front Controller

D. Intercepting Filter

E. Business Delegate

F. Model-View-Controller


Options are :

  • A,B
  • D,E
  • C,D
  • B,C

Answer : C,D

Servlet A forwarded a request to servlet B using the forward method of RequestDispatcher. What

attribute in B's request object contains the URI of the original request received by servlet A?


Options are :

  • REQUEST_URI
  • javax.servlet.request_dispatcher.request_uri
  • javax.servlet.forward.REQUEST_URI
  • javax.servlet.forward.request_uri
  • javax.servlet.request_dispatcher.REQUEST_URI

Answer : javax.servlet.forward.request_uri

Given:

11. <servlet>

12. <servlet-name>catalog</servlet-name>

13. <jsp-file>/catalogTemplate.jsp</jsp-file>

14. <load-on-startup>10</load-on-startup>

15. </servlet>

Which two are true? (Choose two.)

A. Line 13 is not valid for a servlet declaration.

B. Line 14 is not valid for a servlet declaration.

C. One instance of the servlet will be loaded at startup.

D. Ten instances of the servlet will be loaded at startup.

E. The servlet will be referenced by the name catalog in mappings.


Options are :

  • D,E
  • A,E
  • B,E
  • C,E

Answer : C,E

310-083 Sun Certified Web Component Developer for J2EE 5 Set 8

Which two are characteristics of the Intercepting Filter pattern? (Choose two.)

A. It provides centralized request handling for incoming requests.

B. It forces resource authentication to be distributed across web components.

C. It reduces coupling between presentation-tier clients and underlying business services.

D. It can be added and removed unobtrusively, without requiring changes to existing code.

E. It allows preprocessing and postprocessing on the incoming requests and outgoing responses.


Options are :

  • A,B
  • D,E
  • B,C
  • C,D

Answer : D,E

Given an HttpServletRequest request:

22. String id = request.getParameter("jsessionid");

23. // insert code here

24. String name = (String) session.getAttribute("name");

Which three can be placed at line 23 to retrieve an existing HttpSession object? (Choose three.)

A. HttpSession session = request.getSession();

B. HttpSession session = request.getSession(id);

C. HttpSession session = request.getSession(true);

D. HttpSession session = request.getSession(false);

E. HttpSession session = request.getSession("jsessionid");


Options are :

  • A,B,C
  • A,D,E
  • A,C,D
  • A,B,D

Answer : A,C,D

A developer is designing a multi-tier web application and discovers a need to hide the details of

establishing and maintaining remote communications from the client. In addition, because the

business and resource tiers are distributed, the application needs to minimize the inter-tier network

traffic related to servicing client requests. Which design patterns, working together, address these

issues?


Options are :

  • Business Delegate and Intercepting Filter
  • Front Controller and Service Locator
  • Model-View-Controller and Intercepting Filter
  • Front Controller and Transfer Object
  • Front Controller and Service Locator

Answer : Front Controller and Service Locator

310-090 Sun Certified Business Component Developer for J2EE Set 1

A developer is designing a web application that must support multiple interfaces, including:

an XML web service for B2B

HTML for web-based clients

WML for wireless customers

Which design pattern provides a solution for this problem?


Options are :

  • Chain of Responsibility
  • Session Facade
  • Business Delegate
  • Data Access Object
  • Model-View-Controller

Answer : Model-View-Controller

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


Options are :

  • C,D
  • A,B
  • A,C
  • B,C

Answer : C,D

Given a Filter class definition with this method:

21. public void doFilter(ServletRequest request,

22. ServletResponse response,

23. FilterChain chain)

24. throws ServletException, IOException {

25. // insert code here

26. }

Which should you insert at line 25 to properly invoke the next filter in the chain, or the target

servlet if there are no more filters?


Options are :

  • chain.forward(request, response);
  • chain.doFilter(request, response);
  • request.forward(request, response);
  • request.doFilter(request, response);

Answer : chain.doFilter(request, response);

310-090 Sun Certified Business Component Developer for J2EE Set 10

A developer for the company web site has been told that users may turn off cookie support in their

browsers. What must the developer do to ensure that these customers can still use the web

application?


Options are :

  • The developer can ignore this issue. Web containers are required to support automatic URL rewriting when cookies are not supported
  • The developer must provide an alternate mechanism for managing sessions and abandon the HttpSession mechanism entirely.
  • The developer must add the string ?id= to the end of every URL to ensure that the conversation with the browser can continue.
  • The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIs

Answer : The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIs

A developer is designing a web application which extensively uses EJBs and JMS. The developer

finds that there is a lot of duplicated code to build the JNDI contexts to access the beans and

queues. Further, because of the complexity, there are numerous errors in the code. Which J2EE

design pattern provides a solution for this problem?


Options are :

  • Business Delegate
  • Business Delegate
  • Command
  • Transfer Object
  • Session Facade
  • Transfer Object

Answer : Transfer Object

In a JSP-centric shopping cart application, you need to move a client's home address of the

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 JSP code snippets can be used to accomplish this goal? (Choose two.)

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>


Options are :

  • A,E
  • B,E
  • D,E
  • C,E

Answer : B,E

310-090 Sun Certified Business Component Developer for J2EE Set 11

Which JSTL code snippet produces the output "big number" when X is greater than 42, but

outputs "small number" in all other cases?


Options are :

  • big number small number
  • big number small number
  • big number small number
  • big number small number
  • big number small number

Answer : big number small number

Which two are characteristics of the Front Controller pattern? (Choose two.)

A. It simplifies remote interfaces to distributed objects.

B. It promotes cleaner application partitioning and encourages reuse.

C. It provides an initial point of contact for handling all related requests.

D. It reduces maintainability due to the increased complexity of the design.

E. It provides loosely coupled handlers that can be combined in various permutations


Options are :

  • D,E
  • A,B
  • C,D
  • B,C

Answer : B,C

You have built your own light-weight templating mechanism. Your servlets, which handle each

request, dispatch the request to one of a small set of template JSP pages. Each template JSP

controls the layout of the view by inserting the header, body, and footer elements into specific

locations within the template page. The URLs for these three elements are stored in requestscoped

variables called, headerURL, bodyURL, and footerURL, respectively. These attribute

names are never used for other purposes. Which JSP code snippet should be used in the

template JSP to insert the JSP content for the body of the page?


Options are :

Answer :

310-090 Sun Certified Business Component Developer for J2EE Set 12

Your web application uses a simple architecture in which servlets handle requests and then

forward to a JSP using a request dispatcher. You need to pass information calculated in the

servlet to the JSP for view generation. This information must NOT be accessible to any other

servlet, JSP or session in the webapp. Which two techniques can you use to accomplish this goal?

(Choose two.)

A. Add attributes to the session object.

B. Add attributes on the request object.

C. Add parameters to the request object.

D. Use the pageContext object to add request attributes.

E. Add parameters to the JSP's URL when generating the request dispatcher


Options are :

  • D,E
  • B,E
  • C,E
  • A,E

Answer : B,E

You have built a web application with tight security. Several directories of your webapp are used

for internal purposes and you have overridden the default servlet to send an HTTP 403 status

code for any request that maps to one of these directories. During testing, the Quality Assurance

director decided that they did NOT like seeing the bare response page generated by Firefox and

Internet Explorer. The director recommended that the webapp should return a more user-friendly

web page that has the same look-and-feel as the webapp plus links to the webapp's search

engine. You have created this JSP page in the /WEB-INF/jsps/error403.jsp file. You do NOT want

to alter the complex logic of the default servlet. How can you declare that the web container must

send this JSP page whenever a 403 status is generated?


Options are :

  • 403 /WEB-INF/jsps/error403.jsp
  • 403 /WEB-INF/jsps/error403.jsp
  • 403 /WEB-INF/jsps/error403.jsp
  • 403 /WEB-INF/jsps/error403.jsp

Answer : 403 /WEB-INF/jsps/error403.jsp

Squeaky Beans Inc. hired an outside consultant to develop their web application. To finish the job

quickly, the consultant created several dozen JSP pages that directly communicate with the

database. The Squeaky business team has since purchased a set of business objects to model

their system, and the Squeaky developer charged with maintaining the web application must now

refactor all the JSPs to work with the new system. Which pattern can the developer use to solve

this problem?


Options are :

  • Intercepting Filter
  • Transfer Object
  • Service Locator
  • Business Delegate

Answer : Business Delegate

310-090 Sun Certified Business Component Developer for J2EE Set 2

After a merger with another small business, your company has inherited a legacy WAR file but the

original source files were lost. After reading the documentation of that web application, you

discover that the WAR file contains a useful tag library that you want to reuse in your own webapp

packaged as a WAR file.

What do you need to do to reuse this tag library?


Options are :

  • Simply rename the legacy WAR file as a JAR file and place it in your webapp's library directory.
  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the WAR, and place that WAR file in your webapp's WEB-INF directory.
  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.
  • Unpack the legacy WAR file, move the TLD file to the META-INF directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.

Answer : Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.

You are creating a content management system (CMS) with a web application front-end. The JSP

that displays a given document in the CMS has the following general structure:

1. <%-- tag declaration --%>

2. <t:document>

...

11. <t:paragraph>... <t:citation docID='xyz' /> ...</t:paragraph>

...

99. </t:document>

The citation tag must store information in the document tag for the document tag to generate a

reference section at the end of the generated web page.

The document tag handler follows the Classic tag model and the citation tag handler follows the

Simple tag model. Furthermore, the citation tag could also be embedded in other custom tags that

could have either the Classic or Simple tag handler model.

Which tag handler method allows the citation tag to access the document tag?


Options are :

  • public void doTag() { Tag docTag = findAncestor(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID); }
  • public void doStartTag() { JspTag docTag = findAncestorWithClass(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID); }
  • public void doStartTag() { Tag docTag = findAncestor(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID); }
  • public void doTag() { JspTag docTag = findAncestorWithClass(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID); }

Answer : public void doTag() { JspTag docTag = findAncestorWithClass(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID); }

Given a portion of a valid Java EE web application's directory structure:

MyApp

|

|-- File1.html

|

|-- Directory1

| |-- File2.html |

|-- META-INF

|-- File3.html

Sun 310-083 Exam

BrainDumps.com 124

You want to know whether File1.html, File2.html, and/or File3.html will be directly accessible by

your web client's browsers.

Which statement is true?


Options are :

  • Only File2.html and File3.html are directly accessible
  • All three files are directly accessible.
  • Only File1.html and File3.html are directly accessible
  • Only File2.html is directly accessible
  • Only File1.html is directly accessible.
  • Only File3.html is directly accessible.
  • Only File1.html and File2.html are directly accessible.

Answer : Only File1.html and File2.html are directly accessible.

310-090 Sun Certified Business Component Developer for J2EE Set 3

Given this fragment from a Java EE deployment descriptor:

341. <error-page>

342. <exception-type>java.lang.Throwable</exception-type>

343. <location>/mainError.jsp</location>

344. </error-page>

345. <error-page>

346. <exception-type>java.lang.ClassCastException</exception-type>

347. <location>/castError.jsp</location>

348. </error-page>

If the web application associated with the fragment above throws a ClassCastException.

Which statement is true?


Options are :

  • The container invokes mainError.jsp.
  • Neither mainError.jsp nor castError.jsp is invoked.
  • The container invokes castError.jsp.
  • The deployment descriptor is invalid.

Answer : The container invokes castError.jsp.

A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated

in a thread-safe manner. Which two can support this design goal? (Choose two.)

A. Store the data in a local variable.

B. Store the data in an instance variable.

C. Store the data in the HttpSession object.

D. Store the data in the ServletContext object.

E. Store the data in the ServletRequest object.


Options are :

  • D,E
  • A,E
  • C,E
  • B,E

Answer : A,E

Given:

String value = getServletContext().getInitParameter("foo");

in an HttpServlet and a web application deployment descriptor that contains:

<context-param>

<param-name>foo</param-name>

<param-value>frodo</param-value>

</context-param>

Which two are true? (Choose two.)

A. The foo initialization parameter CANNOT be set programmatically.

B. Compilation fails because getInitParameter returns type Object.

C. The foo initialization parameter is NOT a servlet initialization parameter.

D. Compilation fails because ServletContext does NOT have a getInitParameter method.

E. The foo parameter must be defined within the <servlet> element of the deployment descriptor.

F. The foo initialization parameter can also be retrieved using

getServletConfig().getInitParameter("foo").


Options are :

  • A,D
  • A,B
  • A,C
  • A,E

Answer : A,C

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


Options are :

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

Answer :

Which two from the web application deployment descriptor are valid? (Choose two.)

A. <error-page>

<exception-type>*</exception-type>

<location>/error.html</location>

</error-page>

B. <error-page>

<exception-type>java.lang.Error</exception-type>

<location>/error.html</location>

</error-page>

C. <error-page>

<exception-type>java.lang.Throwable</exception-type>

<location>/error.html</location>

</error-page>

D. <error-page>

<exception-type>java.io.IOException</exception-type>

<location>/error.html</location>

</error-page>

E. <error-page>

<exception-type>NullPointerException</exception-type>

<location>/error.html</location>

</error-page>


Options are :

  • D,E
  • A,B
  • C,D
  • B,C

Answer : C,D

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions