SCWCD-20

05/13/2008

0 Comments

 

A JSP page can receive context initialization parameters through the deployment descriptor of the web application.

a True

b False

Answer: a

 
When writing a TLD, which tags would you use to surround fnName(int num), a Java method declared in a separate class?

a <function-signature></function-signature>

b <function-name></function-name>

c <method-class></method-class>

d <method-signature></method-signature>

e <function-class></function-class>

Answer: a

 
Which of the options locate the bean equivalent to the following action? (Select three)

<jsp:useBean id="address" class="AddressBean" scope="request" />

a request.getAttribute("address");

b request.getParameter("address");

c getServletContext().getRequestAttribute("address");

d pageContext.getAttribute("address",PageContext.REQUEST_SCOPE);

e pageContext.getRequest().getAttribute("address");

f pageContext.getRequestAttribute("address");

g pageContext.getRequestParameter("address");

Answers: a, d, and e

 

You are given a tag library that has a tag named printReport. This tag may accept an attribute, department, which cannot take a dynamic value. Which of the following are correct uses of this tag? (Select two)

a <mylib:printReport/>

b <mylib:printReport department="finance"/>

c <mylib:printReport attribute="department" value="finance"/>

d <mylib:printReport attribute="department"

attribute-value="finance"/>

e <mylib:printReport>

<jsp:attribute name="department" value="finance" />

</mylib:printReport>

Answers: a and b

 

Which of the following methods is never called for handler classes that implement only the Tag interface? (Select one)

a setParent()

b doStartTag()

c doAfterbody()

d doEndTag()

Answer: c

   
Which of the following values is invalid inside a SimpleTag’s <bodycontent> subelement? (Select one)

a JSP

b scriptless

c tagdependent

d empty

Answer: a

 
You are designing an application that is required to display the data to users through HTML interfaces. It also has to feed the same data to other systems through XML as well as WAP interfaces. Which design pattern would be appropriate in this situation? (Select one)

a Interface Factory

b Session Facade

c Transfer Object

d Model-View-Controller

e Factory

Answer: d

 

SCWCD-19

05/13/2008

0 Comments

 

Consider the following HTML page code:
<html>
<body>
 <form name="data" action="/servlet/DataServlet" method="POST">
 <input type="text" name="name">
 <input type="submit" name="submit">
 </form>
 </body>
</html>
 Identify the two methods that can be used to retrieve the value of the name parameter when the form is submitted.

a getParameter("name");

b getParameterValue("name");

c getParameterValues("name");

d getParameters("name");

e getValue("name");

f getName();

Answers: a and c

 

Your web application, named simpletax, depends on a third-party JAR file named taxpackage.jar. Where would you keep this file? (Select one)

a simpletax

b simpletax/WEB-INF

c simpletax/WEB-INF/classes

d simpletax/WEB-INF/lib

e simpletax/WEB-INF/jars

f simpletax/WEB-INF/thirdparty

Answer: d

 
Which deployment descriptor element is used to specify a ServletContext- Listener? (Select one)

a <context-listener>

b <listener>

c <servlet-context-listener>

d <servletcontextlistener>

e <servletcontext-listener>

Answer: b
 


Which of the following method calls will ensure that a session will never be expunged by the servlet container? (Select one)

a session.setTimeout(0);

b session.setTimeout(-1);

c session.setTimeout(Integer.MAX_VALUE);

d session.setTimeout(Integer.MIN_VALUE);

e None of these.

Answer: e

   
Which of the following deployment descriptor elements is used for specifying the authentication mechanism for a web application? (Select one)

a security-constraint

b auth-constraint

c login-config

d web-resource-collection

Answer: c

  Which of the following correctly declares that the current page is an error page and also enables it to take part in a session? (Select one)

a <%@ page pageType="errorPage" session="required" %>

b <%@ page isErrorPage="true" session="mandatory" %>

c <%@ page errorPage="true" session="true" %>

d <%@ page isErrorPage="true" session="true" %>

e None of the above.

Answer: d

 

SCWCD-18

05/13/2008

0 Comments

 

Which two of the following expressions won’t return the header’s accept field?

a ${header.accept}

b ${header[accept]}

c ${header['accept']}

d ${header["accept"]}

e ${header.'accept'}

Answers: b and e

 

Consider the following code:
<html>
<body>

<jsp:useBean id="address" class="AddressBean" scope="session" />

state = <jsp:getProperty name="address" property="state" />
 </body>
</html>

Which of the following are equivalent to the third line above? (Select three)

a <% state = address.getState(); %>

b <% out.write("state = "); out.print(address.getState()); %>

c <% out.write("state = "); out.print(address.getstate()); %>

d <% out.print("state = " + address.getState()); %>

e state = <%= address.getState() %>

f state = <%! address.getState(); %>

Answers: b, d, and e

   
Consider the following <taglib> element, which appears in a deployment descriptor of a web application:
<taglib>

<taglib-uri>/accounting</taglib-uri>
 <taglib-location>/WEB-INF/tlds/SmartAccount.tld</taglib-location>
 </taglib>
Which of the following correctly specifies the use of the above tag library in a JSP page? (Select one)

a <%@ taglib uri="/accounting" prefix="acc"%>

b <%@ taglib uri="/acc" prefix="/accounting"%>

c <%@ taglib name="/accounting" prefix="acc"%>

d <%@ taglib library="/accounting" prefix="acc"%>

e <%@ taglib name="/acc" prefix="/accounting"%>

Answer: a

 
At a minimum, which of the following interfaces are required to create an iterative custom tag? (Select one)

a Tag

b Tag and IterationTag

c Tag, IterationTag, and BodyTag

d TagSupport

e BodyTagSupport

Answer: b

 

Which of the following methods need to be invoked in a SimpleTag to provide iterative processing? (Select one)

a setDynamicAttribute()

b getParent()

c getJspBody()

d doTag()

e getJspContext()

Answer: d


   

What are the benefits of using the Business Delegate pattern? (Select three)

a It implements the business service functionality locally to improve performance.

b It shields the clients from the details of the access mechanism, such as CORBA or

RMI, of the business services.

c It shields the clients from changes in the implementation of the business services.

d It provides the clients with a uniform interface to the business services.

e It reduces the number of remote calls and reduces network overhead.

Answers: b, c, and d

 

SCWCD-17

05/13/2008

0 Comments

 

Your servlet class depends on a utility class named com.abc.TaxUtil. Where would you keep the TaxUtil.class file? (Select one)

a WEB-INF

b WEB-INF/classes

c WEB-INF/lib

d WEB-INF/jars

e WEB-INF/classes/com/abc

Answer: e

   
Which method is used to retrieve an initialization parameter from a Servlet- Context? (Select one)

a Object getInitParameter(int index)

b Object getParameter(int index)

c Object getInitParameter(String name)

d String getInitParameter(String name)

e String getParameter(String name)

Answer: d

 

Which of the following methods will expunge a session object? (Select one)

a session.invalidate();

b session.expunge();

c session.destroy();

d session.end();

e session.close();

Answer: a

 

Identify the authentication mechanisms that are built into the HTTP specification. (Select two)

a Basic

b Client-Cert

c FORM

d Digest

e Client-Digest

f HTTPS

Answers: a and d

 
Write the name of the method that you can use to initialize variables declared in a JSP declaration in the space provided. (Write only the name of the method. Do

not write the return type, parameters, or parentheses.)

a [_____________]

Answer: jspInit
 


The implicit variable config in a JSP page refers to an object of type: (Select one)

a javax.servlet.PageConfig

b javax.servlet.jsp.PageConfig

c javax.servlet.ServletConfig

d javax.servlet.ServletContext

Answer: c

 
 
Consider the contents of two JSP files: File 1: test1.jsp <html><body> <% pageContext.setAttribute("ninetyNine", new Integer(99)); %> //1 </body></html> File 2: test2.jsp The number is <%= pageContext.getAttribute("ninetyNine") %> Which of the following, when placed at line //1 in the test1.jsp file, will allow the test2.jsp file to print the value of the attribute when test1.jsp is requested? (Select one)

a <jsp:include page="test2.jsp" />

b <jsp:forward page="test2.jsp" />

c <%@ include file="test2.jsp" %>

d None of the above because objects placed in pageContext have the page scope

and cannot be shared with other components.

Answer: c

 

SCWCD-16

05/13/2008

0 Comments

 

Which tags tell the web container where to find your TLD file in your filesystem?

a <taglib-directory></taglib-directory>

b <taglib-uri></taglib-uri>

c <taglib-location></taglib-location>

d <tld-directory></tld-directory>

e <taglib-name></taglib-name>

Answer: c

 
Which of the following gets or sets the bean in the ServletContext container object? (Select one)

a <jsp:useBean id="address" class="AddressBean" />

b <jsp:useBean id="address" class="AddressBean" scope="application" />

c <jsp:useBean id="address" class="AddressBean" scope="servlet" />

d <jsp:useBean id="address" class="AddressBean" scope="session" />

e None of the above.

Answer: b

 

Which of the following is a valid taglib directive? (Select one)

a <%@ taglib prefix="java" uri="sunlib"%>

b <%@ taglib prefix="jspx" uri="sunlib"%>

c <%@ taglib prefix="jsp" uri="sunlib"%>

d <%@ taglib prefix="servlet" uri="sunlib"%>

e <%@ taglib prefix="sunw" uri="sunlib"%>

f <%@ taglib prefix="suned" uri="sunlib"%>

Answer: f

 
Which of the following interfaces are required at a minimum to create a simple custom tag with a body? (Select one)

a Tag

b Tag and IterationTag

c Tag, IterationTag, and BodyTag

d TagSupport

e BodyTagSupport

Answer: a

 
 
If placed inside the body of a custom tag, which of the following statements won’t produce “9”? (Select one)

a ${3 + 3 + 3}

b "9"

c <c:out value="9">

d <%= 27/3 %>

Answer: d

 

Which of the following statements are correct? (Select two)

a The Transfer Object pattern ensures that the data is not stale at the time of use.

b It is wise to make the Transfer Object immutable if the Transfer Object represents

read-only data.

c Applying the Transfer Object pattern on EJBs helps to reduce the load on enterprise

beans.

d A Transfer Object exists only on the server side.

Answers: b and c

You need to send a GIF file to the browser. Which of the following lines should be called after (or before) a call to response.getOutputStream()? (Select one)

a response.setContentType("image/gif"); Before

b response.setContentType("image/gif"); After

c response.setDataType("image/gif"); Before

d response.setDataType("image/gif"); After

e response.setStreamType("image/gif"); Before

f response.setStreamType("image/gif"); After

Answer: a

 

SCWCD-15

05/13/2008

0 Comments

 

Which of the following lines would initialize the out variable for sending a Microsoft Word file to the browser? (Select one)

a PrintWriter out = response.getServletOutput();

b PrintWriter out = response.getPrintWriter();

c OutputStream out = response.getWriter();

d PrintWriter out = response.getOuputStream();

e OutputStream out = response.getOuputStream();

f ServletOutputStream out = response.getServletOutputStream();

Answer: e

   

What file is the deployment descriptor of a web application named BankApp stored in? (Select one)

a BankApp.xml

b bankapp.xml

c server.xml

d deployment.xml

e WebApp.xml

f web.xml

Answer: f

 

Which method is used to retrieve an attribute from a ServletContext? (Select one)

a String getAttribute(int index)

b String getObject(int index)

c Object getAttribute(int index)

d Object getObject(int index)

e Object getAttribute(String name)

f String getAttribute(String name)

g String getObject(String name)

Answer: e

 
Which of the following methods will be invoked on a session attribute that implements appropriate interfaces when the session is invalidated? (Select one)

a sessionDestroyed of HttpSessionListener

b attributeRemoved of HttpSessionAttributeListener

c valueUnbound of HttpSessionBindingListener

d sessionWillPassivate of HttpSessionActivationListener

Answer: c


  
Which of the following actions would you take to prevent your web site from being attacked? (Select three)

a Block network traffic at all the ports except the HTTP port.

b Audit the usage pattern of your server.

c Audit the Servlet/JSP code.

d Use HTTPS instead of HTTP.

e Design and develop your web application using a software engineering methodology.

f Use design patterns.

Answers: a, c, and d

 

Which of the following exceptions may be thrown by the _jspService() method? (Select one)

a javax.servlet.ServletException

b javax.servlet.jsp.JSPException

c javax.servlet.ServletException and javax.servlet.jsp.JSPException

d javax.servlet.ServletException and java.io.IOException

e javax.servlet.jsp.JSPException and java.io.IOException

Answer: d

 

Which of the following implicit objects can you use to store attributes that need to be accessed from all the sessions of a web application? (Select two)

a application

b session

c request

d page

e pageContext

Answers: a and e

 

Identify the JSP equivalent of the following code written in a servlet. (Select one)

RequestDispatcher rd = request.getRequestDispatcher("world.jsp");

rd.forward(request, response);

a <jsp:forward page="world.jsp"/>

b <jsp:action.forward page="world.jsp"/>

c <jsp:directive.forward page="world.jsp"/>

d <%@ forward file="world.jsp"%>

e <%@ forward page="world.jsp"%>

Answer: a

 
    SCWCD Sets


    Archives

    May 2008
    April 2008