QUESTION 1
APIs for dynamically registering servlets and filters can be called at:
A. Context initialization time
B. Any time
C. There is no way to dynamically register servlets and filters
D. Context destruction time
E. Injected into a servlet context
Answer: A
QUESTION 2
ServletRegistration.Dynamic can be used to configure (Choose two)
A. Filter mappings
B. add init params
C. set asyncSupported to true
D. add Listeners
Answer: AB
QUESTION 3
A web application wants to register a new servlet at runtime using one of the servletContext.addServlet methods.
In the implementation of which method is it legal to perform this operation?
A. AsyncListner.oncomplete
B. Servlet.init
C. ServletContextListener.contextInitialize
D. ServletrequestListener.contextInitialize
Answer: C
QUESTION 4
You want to create a filter for your web application and your filter will implement .servlet.Filter.
Which two statements are true? (Choose two)
A. Your filter class must implement an init method and a destroy method.
B. Your filter class must also implement javax.sarvlat.FilterChain.
C. When your filter chains to the next filter, it should pass the same arguments it received in its doFilter method.
D. The method that your filter invokes on the object it received that implements javax – servlet.Filterchain can invoke either another filter or a servlet.
E. Your filter class must implement a doFilter method that takes, among other things, an HttpServletRequest object and an HttpServletresponse object.
Answer: AD
QUESTION 5
You have a simple wpb application that has a single Front Controller servlet that dispatches to JSPs generate a variety of views. Several of these views require further database processing to retrieve the necessary order object using the orderID request parameter. To do this additional processing, you pass the request first to a servlet that is mapped to the URL pattern /WEB – INF / retrieveOrder.do. in the deployment descriptor. This servlet takes two request parameters, the ordered and the jspID and the jspURL. It handles the database calls to retrieve and build the complex order objects and then it dispatches to the jspURL.
Which code snippet in the Front Controller servlet dispatches the request to the order retrieval servlet?
A. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
= context.getRequestDispathcher (“/WEB – INF / retrieveOrder.do”); view.forward(request, response)
B. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
Dispatcher view
= request.getDispatcher (“.WEB – INF / retrieveOrder.do”); View.forwardRequest (request, response);
C. String T= “/WEB – INF / retrieveOrder.do?orderID = %&;jspURl = %s”; String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forward (request, response) ;
D. String T= “/WEB – NF / retrieveOrder.do?orderID = %&;jspURl = %s”; String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forwardRequest (request, response) ;
Answer: C
QUESTION 6
Given the JavaBean class:
public class MyBean {
private Boolean roasted = false;
public MyBean () {}
public Boolean isRoasted () { returned roasted }
public void setRoasted (Boolean roasted) { this.roasted = roasted; ]
}
Assume a controller has created an instance of this bean, called setRoasted (true), and inserted the bean into the application scope using the name “myBean”.
A JSP contains these two tags:
<jsp: useBean id = “aBean” class = “MyBean” scope = “page” \ />
<jsp: getProprty name = “aBean” property = “roasted” \ />
Which is true?
A. the page will include the output false
B. the page will include the output
C. the page will report that the property roasted does not exist
D. the page will report that the syntax of the useBean tag is incorrect
E. the page will report that the syntax of the getProperty tag ls incorrect
Answer: E
QUESTION 7
A developer chooses to avoid using singieThreadModel but wants to ensure that data If; 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 sarvletContext object.
E. Store the data in the ServletRequest object.
Answer: AE
QUESTION 8
You have a use in your web application that adds several session-scoped attributes. At the end of the use case, one of these objects, the manage attribute, is removed and then it needs to decide which of the other session-scoped attributes to remove.
How can this goal be accomplished?
A. The object of the manager attribute should implement the HttpSessionBindingListener and it should call the removeAttribute method on the appropriate session attributes.
B. The object of the manager attribute should implement the HttpSessionListenar and it should call the removeAttribute method on the appropriate session attributes.
C. The object of the manager attribute should implement the HttpSessionBindingListener rind it should call the deleteAttribute method on the appropriate session attributes.
D. The object of the manager attribute should implement the HttpsessionListener and it should call the deleteAttribute method on the appropriate session attributes.
Answer: A
QUESTION 9
The Squeaky Beans Inc. shopping application was initially developed for a non-distributed environment. The company recently purchased the Acme Application Server, which supports distributed Httpsession objects. When deploying the application to the server, the doployer marks it as distributable in the web application deployment descriptor to take advantage of this feature.
Given this scenario, which two must be true? (Choose two)
A. The J2EE web container must support migration of objects that implement serializable.
B. The J2EE web container must use the native JVM Serialization mechanism for distributing HttpSesaion objects.
C. As per the specification, the J2EE web container ensures that distributed Httpsassion objects will be stored in a database.
D. Storing references to Enterprise JavaBeans components in the HttpSession object might NOT supported by J2EE web contain.
Answer: AD
QUESTION 10
Given an HttpServletRequest request and an httpServletResponse response:
41. HttpSession session = null;
42. / / insert code here
43. if (session = = null) {
44. / / do something if session does not exist
45. } else {
46. / / do something if session exists
47. }
To implement the design intent, which statement must be inserted at line 42?
A. session = response.getSession ();
B. session = request.getSession ();
C. session = request.getSession (true);
D. session = request.getSession (false);
E. session = request.getSession (“jsessionid”);
Answer: D
QUESTION 11
Users of your web application have requested that they should be able to set the duration of their sessions. So for example, one user might want a webapp to stay connected for an hour rather than the webapp’s default of fifteen minutes; another user might want to stay connected for a whole day.
Furthermore, you have a special login servlet that performs user authentication and retrieves the object from the database. You want to augment this code to set up the user’s specified session duration.
Which code snippet in the login servlet will accomplish this goal?
A. User user = / / retrieves the user objects object from the database session.setDurationInterval (user.getSessionDuration());
B. User user = / / retrieves the User objects from the database session.setInactiveInterval (user.getSessionDuration());
C. User user = / / retrieves the user objects object from the database session.setInactiveInterval (user.get.SessionDuration());
D. User user = / / retrieves the user objects object from the database session.setDuration (user.getSessionDuration());
E. User user = / / retrieves the user objects object from the database session.setMaxInactiveInterval (user.getSessionDuration());
F. User user = / / retrieves the user objects object from the database
session.setMaxDurationInterval (user.getSessionDuration());
Answer: E
Passing your Oracle 1Z0-899 Exam by using the latest 1Z0-899 Exam Dump Full Version: http://www.braindump2go.com/1z0-899.html