Which of the following techniques would correctly put a bean into application scope? (You can assume that any necessary page directives are present and correct elsewhere in the JSP page.) (Choose one.)

Which of the following techniques would correctly put a bean into application scope? (You can assume that any necessary page directives are present and correct elsewhere in the JSP page.) (Choose one.) 



a. <jsp:useBean id="app1" class="webcert.ch07.examp0701.AddressBean" scope="application" />
b. <% AddressBean ab5 = new AddressBean();
pageContext.setAttribute("app5", ab5); %>
c. <jsp:useBean name="app6" class="webcert.ch07.examp0701.AddressBean" scope="application" />




Answer: A

Which statements are BEST describe isErrorPage attribute of <%@ page isErrorPage=....%> directive?

Which statements are BEST describe isErrorPage attribute of <%@ page isErrorPage=....%> directive?




a. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
b. Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original exception that occurred.
c. Specifies the MIME type of the data in the response to the client. The default type is text/html.
d. Specifies the class from which the translated JSP will be inherited. This attribute must be a fully qualified package and class name.



Answer: B

Which of the following is a valid standard action that can be used by a jsp page to import content generated by another JSP file named another.jsp?

Which of the following is a valid standard action that can be used by a jsp page to import content generated by another JSP file named another.jsp? 



a. <jsp:include page='another.jsp'/>
b. <jsp:import page='another.jsp'/>
c. <jsp:include file='another.jsp'/>
d. <jsp:import file='another.jsp'/>



Answer: A

Which statements are BEST describe Action?

Which statements are BEST describe <jsp:include> Action?



a. Specifies the relative URI path of the resource to include. The resource must be part of the same Web application.
b. Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed.
c. Forwards request processing to another JSP, servlet or static page. This action terminates the current JSP's execution.
d. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean.






Answer: B

Which statements are BEST describe id attribute of Action?

Which statements are BEST describe id attribute of <jsp:useBean id=..... /> Action?




a. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is case sensitive.
b. The scope in which the Java object is accessible—page, request, session or application. The default scope is page.
c. The fully qualified class name of the Java object.
d. The name of a bean that can be used with method instantiate of class java.beans.Beans to load a JavaBean into memory.
e. The type of the JavaBean. This can be the same type as the class attribute, a superclass of that type or an interface implemented by that type. The default value is the same as for attribute class. A ClassCastException occurs if the Java object is not of the type specified with attribute type.





Answer: A

Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.

Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.

<% int sum = 0;
for(j = 0; j < 10; j++) { %>
// XXX --- Add j to sum
<% } %>
// YYY --- Display the sum

Which statement when placed at the location XXX can be used to compute the sum?

a. <% sum = sum + j %>
b. <% sum = sum + j; %>
c. <%= sum = sum + j %>
d. <%= sum = sum + j; %>





Answer: B

Which of these is true about include directive? Select the one correct answer.

Which of these is true about include directive? Select the one correct answer. 



a. The included file must have jsp extension.
b. The XML syntax of include directive in <jsp:include file="fileName"/> .
c. The content of file included using include directive, cannot refer to variables local to the original page.
d. When using the include directive, the JSP container treats the file to be included as if it was part of the original file.





Answer: D

Which statements are BEST describe page implicit object of jsp file?

Which statements are BEST describe page implicit object of jsp file?




a. This javax.servlet.jsp.JspWriter object writes text as part of the response to a request. This object is used implicitly with JSP expressions and actions that insert string content in a response.
b. This java.lang.Object object represents the this reference for the current JSP instance.
c. This javax.servlet.jsp.PageContext object hides the implementation details of the underlying servlet and JSP container and provides JSP programmers with access to the implicit objects discussed in this table.
d. This object represents the response to the client. The object normally is an
instance of a class that implements HttpServletResponse (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a class that implements javax.servlet.ServletResponse.
e. This object represents the client request. The object normally is an instance of a class that implements HttpServletRequest (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a subclass of javax.servlet.ServletRequest.




Answer: B

Which of these is a correct fragment within the web-app element of deployment descriptor? Select the one correct answer

Which of these is a correct fragment within the web-app element of deployment descriptor? Select the one correct answer 



a. <exception> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </exception>
b. <error-page> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </error-page>
c. <error-page> <exception> mypackage.MyException </exception-type> <location> /error.jsp </location> </error-page>
d. <error-page> <exception-type> mypackage.MyException</exception-type> </error-page>
e. <error-page> <servlet-name> myservlet</servlet-name> <exception-type> mypackage.MyException</exception-type> </error-page>
f. <exception> <servlet-name> myservlet</servlet-name> <exception-type> mypackage.MyException</exception-type> </exception>




Answer: B

Which method of ReportGeneratorServlet will be called when the user clicks on the URL shown by the following HTML. Assume that ReportGeneratorServlet does not override the service(HttpServletRequest, HttpServletResponse) method of the HttpServlet class.

Which method of ReportGeneratorServlet will be called when the user clicks on the URL shown by the following HTML.
Assume that ReportGeneratorServlet does not override the service(HttpServletRequest, HttpServletResponse) method of the HttpServlet class. 




a. doGet(HttpServletRequest, HttpServletResponse);
b. doPost(HttpServletRequest, HttpServletResponse);
c. doHead(HttpServletRequest, HttpServletResponse);
d. doOption(HttpServletRequest, HttpServletResponse);




Answer: A

Which of the following is correct statement?

Which of the following is correct statement?




a. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext.
b. The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server.
c. The getNamedDispatcher(String) defined in HttpServletRequest class takes the name of the servlet and returns an object of RequestDispatcher class




Answer: A

Which statement about JMS is true?

Which statement about JMS is true?



a. JMS supports Publish/Subcribe
b. JMS enhances access to email services
c. JMS uses JMX to create a connectionFactory



Answer: A

Which is the CORRECT statement about JMS?

Which is the CORRECT statement about JMS?



a. JMS uses JNDI to find destination
b. JMS enhances access to email services
c. JMS uses JMX to create a connectionFactory



Answer: A

A developer wants to achieve the following two behaviors for an EJB 3.0 session bean: (1) If the client calls a business method with a transaction context, the container will invoke the enterprise bean's method in the client's transaction context. (2) If the client calls a business method without a transaction context, the container will throw the javax.ejb.EJBTransactionRequiredException. Which transaction attribute should be used?

A developer wants to achieve the following two behaviors for an EJB 3.0 session bean:
(1) If the client calls a business method with a transaction context, the container will invoke the enterprise
bean's method in the client's transaction context.
(2) If the client calls a business method without a transaction context, the container will throw the
javax.ejb.EJBTransactionRequiredException.
Which transaction attribute should be used?



a. MANDATORY
b. SUPPORTS
c. NOT_SUPPORTED





Answer: A

Which statement about an entity instance lifecycle is correct?

Which statement about an entity instance lifecycle is correct?




a. A new entity instance is an instance with a fully populated state.
b. A detached entity instance is an instance with no persistent identity.
c. A removed entity instance is NOT associated with a persistence context.
d. A managed entity instance is the instance associated with a persistence context.




Answer: D

Which statement about entity manager is true?

Which statement about entity manager is true?




a. A container-managed entity manager must be a JTA entity manager.
b. An entity manager injected into session beans can use either JTA or resource-local transaction control.
c. An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses JTA transaction control.





Answer: A

A developer is working on a user registration application using EJB 3.0. A business method registerUser in stateless session bean RegistrationBean performs the user registration. The registerUser method executes in a transaction context started by the client. If some invalid user data causes the registration to fail, the client invokes registerUser again with corrected data using the same transaction. Which design can meet this requirement?

A developer is working on a user registration application using EJB 3.0. A business method registerUser in stateless session bean RegistrationBean performs the user registration.
The registerUser method executes in a transaction context started by the client. If some invalid user data causes the registration to fail, the client invokes registerUser again with corrected data using the same transaction. Which design can meet this requirement?




a. Have registerUser method call EJBContext.setRollbackOnly() method after registration fails.
b. Have registerUser method throw javax.ejb.EJBTransactionRequiredException after registration fails.
c. Have registerUser method throw EJBException without marking the transaction for rollback, after registration fails.
d. Create an application exception with the rollback attribute set to false and have registerUser method throw it after registration fails.




Answer: D

What do you need to create a EJB3 session bean?

What do you need to create a EJB3 session bean?




a. Annotate the session bean with @Session
b. Annotate the session bean with @SessionBean
c. Annotate the session bean with @Stateful or @Stateless



Answer: C

A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB 3.0 session beans need to access this business logic. Which design approach can achieve this requirement?

A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans.
Some EJB 3.0 session beans need to access this business logic.
Which design approach can achieve this requirement?



a. Add adapted home interfaces to EJB 3.0 session beans to make EJB 3.0 and EJB 2.1 session beans interoperable.
b. Add EJB 3.0 business interfaces to existing EJB 2.1 session beans and inject references to these business interfaces into EJB 3.0 session beans.
c. No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.




Answer: C

Which statement is true about management of an EJB's resources?

Which statement is true about management of an EJB's resources?




a. The reference to home object is obtained through JNDI to improve maintainability and flexibility.
b. The reference to the remote object is obtained through JNDI to improve maintainability and flexibility.





Answer: A

Which statements are BEST describe prefix attribute of <%@ taglib prefix=...%>directive of JSP file?

Which statements are BEST describe prefix attribute of <%@ taglib prefix=...%>directive of JSP file?




a. Specifies the relative or absolute URI of the tag library descriptor.
b. Specifies the required prefix that distinguishes custom tags from built-in tags. The prefix names jsp, jspx, java, javax, servlet, sun and sunw are reserved.
c. Allows programmers to include their own new tags in the form of tag libraries. These libraries can be used to encapsulate functionality and simplify the coding of a JSP.
d. The scripting language used in the JSP. Currently, the only valid value for this attribute is java.





Answer: B