You are on page 1of 54

OCEJWCD 6 Mock Questions - 1

1. A web.xml for a web application contains the following:

<login-config> <auth-method>FORM</auth-method> <realm-name>sales</realm-name> <form-login-config> <form-login-page>/formlogin.html</form-login-page> <form-error-page>/formerror.html</form-error-page> </form-login-config> </login-config> What should formlogin.html contain? Select 1 correct option. A. A base 64 encoded username and password B. A header that prompts the browser to pop up the username/password dialog C. A form that POSTs to j_security_check url D. Any html page that does not require the user to login E. Code to redirect the user to the login page
2. Which of the following are valid values for the <auth-method> element of the deployment descriptor?

Select 2 correct options. A. DIGEST B. CLIENT-CERT C. SECURE D. NONE
3.You want to add third party classes bundled as a JAR file and a couple of your own classes to a web application. Which directories would you place them in?

Select 1 correct option. A. AR file in WEB-INF/lib and class files in WEB-INF/classes B. JAR file in WEB-INF/classes/lib and class files in WEB-INF/classes C. both in WEB-INF/classes D. both in WEB-INF E. JAR file in WEB-INF/jars and class files in WEB-INF/classes
4.Write the name of the deployment descriptor tag that allows you to write a description for a <context-param> element. Please do not add angle brackets. 5. Which of the following statements are correct?

Select 3 correct options. A. Authorization means determining whether one has access to a particular resource or not B. Authentication means determining whether one has access to a particular resource or not C. Authentication means proving whether one is what one claims to be D. Data Integrity means that the data is not modified in transit between the sender and the receiver E. Data Integrity means that the data cannot be viewed by anybody other than it's intended recipient
6. Your web application named "FWorks" uses SpecialMath.class. This is an unbundled class and is not contained in any jar file. Where will you keep this class file?

Select 1 correct option. A. FWorks/WEB-INF B. FWorks/WEB-INF/classes C. FWorks/WEB-INF/lib/classes

D. FWorks/classes E. FWorks/WEB-INF/lib
7. Which jsp tag can be used to retrieve a property of a bean?

Select 1 correct option. A. jsp:useBean B. jsp:useBean.property C. jsp:useBean.getProperty D. jsp:getProperty E. jsp:property
8. Associate the events with appropriate listener interface:

Drag and drop the matching listener. i. session is activated or passivated ii. session is timed out iii. an attribute is replaced in the session iv. a session is created Select items A.HttpSessionListener B.HttpSessionBindingListener C.HttpSessionActivationListener D.None of these
9. Given the code of doGet() method of a servlet (see exhibit). The data should be sent to the client only if loginUser() returns a non null userid. Otherwise a status of SC_FORBIDDEN should be sent. What can be placed at //1 to fulfill this requirement?

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String userId = loginUser(req); //this method takes the credentials from the request and logs in the user. if(userId == null) { // 1 Should send SC_FORBIDDEN } else { PrintWriter out = response.getWriter(); generateAndPublishData(out); //this method writes appropriate date to out. } } Select 3 correct options A. req.getRequestDispatcher("errorpage.jsp").dispatch(req, res, HttpServletResponse.SC_FORBIDDEN); B. throw new ServletException(HttpServletResponse.SC_FORBIDDEN); C. res.setStatus(HttpServletResponse.SC_FORBIDDEN); D. res.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not authorized."); E. res.sendError(HttpServletResponse.SC_FORBIDDEN);

10. Which of the following elements of web.xml affect the whole web application instead of a specific servlet?

Select 1 correct option A.content-type B.init-param C.listener D.application E.app-config
11.Which of the following statements regarding <jsp:useBean> action are correct?

Select 2 correct options. A.It must have an 'id' attribute. B.If 'beanName' attribute is present, 'type' must also be present. C.It must have a 'scope' attribute. D.If 'class' attribute is present, 'type' must also be present.
12. Identify the implicit objects available to EL expressions.

Select 4 correct options A.requestScope B.application C.header D.page E.pageScope F.pageContext
13. Populate the blanks with appropriate examples given in the options.

comment directive declaration scriptlet custom tag expression select the items A. <tags:simple name='bob' /> B.<%=request.getParameter("name")%> C.<%request.getParameter("name");%> D.<jsp:directive.include file='hello.jsp' /> E.<%-- String x = "123" --%> F.<%!String x = "123"; %>
14. Which of the following XML fragments correctly defines a role named "manager" in web.xml?

1.<security-role>manager</security-role> 2.<security-role rolename=manager></security-role> 3.<security> <role-name>manager</role-name> </security> 4. <security-role> <role-name>manager</role-name> </security-role> A.1 B.2 C.3 D.4
15. Which of the following statements is correct regarding HttpSessionBindingListener interface?

Select 1 correct option. A.The valueBound() method is called BEFORE the object becomes accessible through HttpSession.getAttribute() B.The valueUnbound() method is called BEFORE the object is removed from the

HttpSession C.The valueReplaced() method is called BEFORE the object is replaced with another object in the session D.None of these
16. Consider the following HTML code. Which method of MyFirstServlet will be invoked when you click on the url shown by the page?

<html> <body> <a href="/myapp/servlet/MyFirstServlet">Make me say Hello World!</a> </body> <html> Select 1 correct option. A.doGet B.doGET C.post D.doPost E.doPOST
17. Your jsp page connects to the database and retrieves the data. It also formats the data and displays it to the client. Any of these operations can throw exceptions but you do not want to catch them all in this page and so you have written another jsp page that is meant to handle any kind of exceptions. How would you associate that error page named "error.jsp" with this page?

Select 2 correct options. A.Add <%@errorPage="error.jsp"%> in this page B.Add <%@page errorPage="error.jsp"%> in this page C.Add <%@page isErrorPage="true"%> in error.jsp D.Add <%@isErrorPage="true"%> in error.jsp
18. You have to send a gif image to the client as a response to a request. How will you acquire the 'out' variable to do this?

Select 1 correct option. A.PrintWriter out = response.getPrintWriter(); B.PrintWriter out = response.getWriter(); C.FileOutputStream out = response.getServletOutputStream(); D.ServletOutputStream out = response.getOutputStream(); F.ServletOutputStream out = response.getServletOutputStream("image/gif");
19. Which of the given statements are correct regarding the following JSP page code?

<jsp:useBean id="mystring" class="java.lang.String" /> <jsp:setProperty name="mystring" property="*" /> <%=mystring%> Assume that the request for this page contains a parameter mystring=hello. Select 1 correct option. A.It will print "" B.It will print "hello" C.It will not compile D.It will throw exception at runtime
20. Select the correct sequence of actions that a servlet container performs before servicing any request.

A.Instantiate listeners defined in the deployment descriptor B.Initialize filters defined in the deployment descriptor C.Initialize servlets that are set to load on startup D.Call the contextInitialized method on the listeners implementing ServletContextListener interface

21.Which of the following is a valid life cycle event listener interface but is NOT configured in the web.xml?

Select 1 correct option. A.HttpSessionListener B.SessionActivationListener C.HttpSessionBindingListener D.ContextAttributeListener E.SessionAttributeListener
22. How can you retrieve the data sent by the FORM displayed by following HTML page code?

<html> <body> <form action="/myapp/SaveServlet" method="POST"> <input type="file" name="name"> <input type="submit" value="POST"> </form> </body> </html> Select 2 correct options. A.request.getParameter("name"); B.request.getAttribute("name"); C.request.getInputStream(); D.request.getReader(); E.request.getFileInputStream();

OCEJWCD 6 Mock Questions - 1 (Answers)
1)C 2)A,B 3)A 4)description or <description> 5)A,C,D 6)B 7)D 8) i. session is activated or passivated -C ii. session is timed out -A,B iii. an attribute is replaced in the session - D iv. a session is created - A 9)C,D,E 10)C 11)A,B 12)A,C,E,F 13) comment -E directive - D declaration -F scriptlet -C custom tag -A expression - B 14)D 15)A 16)A

A.Using the implicit variable error B.None of the above 2. Which listener interface would you implement? Select 1 correct option A. .Which of the following statements are correct for a custom tag that can take any number of arbitrary attributes? Select 2 correct options.17)B.<generator:random><%getParameter("value")%></generator:random> E.SKIP_BODY B.Tag.EVAL_BODY_AGAIN E.HttpServletContextListener E.HttpServletListener 4.service() B.lang. How can you access the Throwable object that refers to the exception in myerror.Using the implicit variable request.you are using a tag library with prefix "generator".None of these because the class of the implicit variable is not java. This tag generates a random number and sets it to a variable named "value".jsp has been invoked as a result of an exception from another JSP page. B. String value).ServletListener B.BodyTag.GET .BodyTag.C 21)C 22)C.%> <%=value%></generator:random> D.Tag.You want to get notified whenever there is a change in the attribute list of the ServletContext of your web application.The tag element in the TLD file for the tag must have <dynamicattributes>true</dynamic-attributes>. Which of the following pairs of HTTP method and HttpServlet class method are a valid combination for a request and the request handler method? Select 2 correct options.<generator:random><%=value%></generator:random> C.<generator:random><% int value.doPost() C.doGet() E.ServletContextListener C.Which of the following are valid return values for doStartTag() method? Select 3 correct options.B.EVAL_BODY_INCLUDE D.SKIP C.POST .ServletContextAttributeListener D.jsp. A. A.tagext. A.Using the implicit variable throwable E.2 1.A JSP page myerror.service() 3.D OCEJWCD 6 Mock Questions .doPost() D.jsp? Select 1 correct option. which supports a tag named "random".Throwable 5.POST .The class implementing the tag must implement javax.DynamicAttributes interface. A. D.servlet.The body-content element for the tag in the TLD file must have a value of JSP. C.C 18)D 19)A 20)A.<generator:random>value</generator:random> B.Tag.The tag handler must implement the method setAttribute(String key.GET .Using the implicit variable exception D.error C. Which of the following will output this value in the page? Select 1 correct option.D.EVAL_BODY_BUFFERED 6.GET .

Which interface and method should be used to retrieve a servlet initialization parameter value? Select 1 correct option.None of the above is correct as every tag has to have a body 8.ServletConfig : getInitParameter(String name) C.<util:transpose></util:transpose> C. A. 12.enthu.User bean referred by 'userBean' variable in request scope with an ID of "user" from within a servlet.Which of the following defines the class name of a tag in a TLD? Select 1 correct option.class 9. B.<taglib:util:transpose /> E.false E.putAttribute("user".request.request.put(userBean. A. userBean).ServletConfig : getInitParameterNames(String name) 11.ServletContext : getInitParameter(String name)) D.ServletConfig : getParameter(String name) B. (Assume that transpose is a valid tag in the given tag library. F. "user").<util:transpose/> B.tag-class C.setAttribute("user".request.E. A.tag-class-name B.request. userBean).put("user". D.Assuming that <%@ taglib uri="/utils" prefix="util" %> occurs before the use of the custom tags of the tag library named utils.) Select 2 correct options. userBean). identify the possibly valid empty custom tag declarations. A. "user"). You need to put a com.empty C.setParameter(userBean.A JSP page sets a dynamic attribute using <jsp:setDynamicAttribute> action 7. "user").blank B.What should be the value of <body-content> subelement of element <tag> in a TLD file if the tag should not have any contents as its body? Select 1 correct option.The <body-content> subelement itself should be absent 10. Which of the following statements accomplishes this task? Select 1 correct option. E.add(userBean.<util:transpose>200</util:transpose> D.class-name D.null D.Dynamic attributes cannot have request time expression values F.request.request.ServletConfig : getInitParameters(String name) E. C. A.Consider the following code: public class MyTagHandler extends TagSupport { public int doStartTag() throws JspException { try { //insert code here } .

getOut().print("hello").application C.JspWriter out = getPageContext(). } } Which of the following options. A.You are given a tag library that has: 1.Which of the following is a correct JSP declaration for a variable of class java.<doc-root> E.Which of the following elements are mandatory under the <web-app> element of a deployment descriptor? Select 1 correct option.pageContext B.catch(Exception e){ } return super.getWriter()). E.<%@ Date d = new Date() %> C. 16.JspWriter out = new JspWriter(pageContext.Which of the following implicit variables should be used by a jsp page to access a page initialization parameter? Select 1 correct option.page 17. out. A.None of these. out.config D.<myTL:getMenu subject='<myTL:getHeading report="1"/>'/> .JspWriter out = pageContext.<app-name> C.MAX_INT) 15.print("hello").<doctype> B.<myTL:getMenu subject="Finance"/> B. B.<%$ Date d = new Date() %> 14.doStartTag(). A.JspWriter out = pageContext.getWriter().Which method can be invoked on a session object so that it is never invalidated by the servlet container automatically? Select 1 correct option.JspWriter out = getPageContext(). out. A.setTimeOut(-1) B. 2. out. 13. out. A tag named getMenu that takes an attribute 'subject' which can be a dynamic value.setTimeOut(0) D.getOut().<myTL:getMenu subject="<myTL:getHeading report=1/>"/> C.<%! Date d = new Date() %> B. A tag named getHeading that takes an attribute 'report'.<%! Date d = new Date(). %> D.<servlet> D.print("hello").Date? Select 1 correct option.MAX_INT) C. A. A. Which of the following are correct uses of this library? Select 3 correct options.setMaxInactiveInterval(Integer.print("hello").setMaxInactiveInterval(-1) E. D.print("hello").setTimeOut(Integer.util.context E. when inserted in the above code causes the value "hello" to be output? Select 1 correct option.getWriter(). C.

E.println("<td>"+it. i<5. A.%> <myTL:getMenu subject="<%=subject%>"/> E. for(. however. you need the taglib directive in the JSP pages.Which of the following are valid iteration mechanisms in jsp? 1. C.hasNext()) { out.<% String subject="HR". } %> 2.You do not need the taglib directive. <% i++. 19.jar. <% int i = 0.iterator().xml to specify the mapping for <taglib-uri> to the location of this jar file.<myTL:getHeading report="2"/> 18.i<5. } %> </table> 5.None of these.xyzcorp.next()+</td></tr>").com/htmlLib</uri> What can you do to access this library from your JSP pages Select 1 correct option.You can directly access the tags of this library from the JSP pages without any taglib directive. <% int i = 0. <jsp:for loop='5'> "Hello World" </jsp:for> 3.D. i++) { %> "Hello World". <table> <% Iterator it = aSet. B.You are working with a tag library which is packaged in a jar file named htmlutil. D. This jar file also contains a META-INF/htmlutil.println("<tr><td>"+(++i)+"</td>"). } %> 4. <jsp:scriptlet> for(int i=0.There is no need for the <taglib> element in the web. while(it. while(i<5) { "Hello World" i++. int i = 0. i++) { </jsp:scriptlet> <jsp:text>"Hello World!"</jsp:text> <jsp:scriptlet> } .xml. out.tld file which has a uri element as follows: <uri>http://www.You must define the <taglib> element in the web.xml. but you do need to specify the <taglib> element in the web.

3 D..0 compliant container will automatically generate an implicit tag library for a set of tag files.sessionScope C.The tag library descriptor for a tag library may be kept in WEB-INF/taglib..The parameter class should be HttpSessionAttributeEvent.4 E. A. 22.initParam 23. <role> <role-name>manager</role-name> </role> 3. which is defined in the servlet container.1 B.params E. A.0 compliant container is guaranteed to generate implicating mapping for JSTL tag libraries.4 21.public void attributeChanged(.The tag library descriptor for a tag library must be kept in META-INF/taglib.A JSP 2.The parameter class should be HttpSessionEvent. A.2 C. A.Consider the following usage of a custom tag in a JSP page: . Your web application wants to make use of a role named 'manager'. Which of the following statements are correct? public class MyHSAListener implements HttpSessionAttributeListener { public void attributeAdded(HttpSessionBindingEvent e){ } public void attributeRemoved(HttpSessionBindingEvent e){ } } Select 1 correct option..Which of the following statements are correct regarding tag libraries? Select 1 correct option. C. <role>manager</role> 4.The tag library descriptor for a tag library not packaged as a jar file may be kept anywhere in /tld directory of the web application's document root 24.){ } must be added. B.paramValues D. Which of the following XML fragments must occur in the deployment descriptor of your web application? 1.It will compile as it is.A JSP 2.Consider the class shown in exhibit. A. B. D. if the tag library is packaged in a jar file..cookie F.3 D.2 C.1 B. E.public void attributeReplaced(.tld. E.</jsp:scriptlet> Select 3 correct option.5 20. D.request B. <role name='manager' /> 2.Identify the implicit objects available to EL expressions Select 4 correct options. C. <security-role> <role-name>manager</role-name> </security-role> Select 1 correct option.tld. if the tag library is packaged in a jar file.){ } must be added.

None of these. B. A. E.getInputStream("data.A Student object will not be created if it is not available it the session.getResourceAsStream("WEB-INF/data.xyz. F.html? Select 1 correct option. B.zip"). 25. A.getResourceAsStream("WEB-INF/data. E.The Student object will be passed to the studentTag tag handler.Servlet Container calls the init method on a servlet instance . ensures that stockindices.InputStream is = context.<jsp:include file='nasdaq.InputStream is = config.jsp. C.The Student object will NOT be passed because no variable named student is defined.zip").Assuming that the Servlet Container has just called the destroy() method of a servlet instance.Any resources that this servlet might hold have been released.InputStream is = context.page B. 27.If the request is from the user whose session has expired.<jsp:useBean id="student" scope = "session" class="com.None of the requests can EVER be serviced by this instance. A.InputStream is = context.InputStream is = config.html' /> D. 29.JSP B.You are developing a jsp page named stockindices. D. cannot be passed as attributes to custom tags.<jsp:forward page='nasdaq. Which of the following lines.All threads created by this servlet are done. C. C. D.Application objects such as com.The <body-content> subelement itself may be absent.The init() method has been called on this instance.For a tag to accept any valid jsp code as its body. B. A. Select 1 correct option. E. 26. which is updated every ten minutes by some other process. E.getInputStream("/WEB-INF/data.For each request to the servlet that causes a new session to be created.Student.For each request to the servlet that causes a new thread to be created.Only once in the life time of the servlet instance.For each request to the servlet.. C.Student" /> <mytaglib:studentTag student='student' /> Which of the following statements are correct? Select 1 correct option. A. D.<jsp:include page='nasdaq.html in the middle of the page.request C.Identify the implicit objects accessible to a jsp page that can store objects accessible across multiple requests.pageContext 30.<%@include file='nasdaq.text E.application E.The servlet container time out has exceeded for this servlet instance.html' /> .jsp.xyz. which of the following statements are correct? Select 2 correct options.html' /> E. 28.jsp C.zip while servicing a request? Assume that config refers to the ServletConfig object of the servlet and context refers to the ServletContext object of the servlet.zip"). Select 2 correct options.html' %> C.zip"). A. This jsp page needs to use a HTML page named nasdaq.zip"). B. A. what should be the value of <body-content> for this tag's taglib descriptor? Select 1 correct option. Select 1 correct option.Initialy when the servlet instance is create and then at request time if the request is from the user whose session has expired.Which of the given options can be used in a servlet code that needs to access a binary file kept in WEB-INF/data.any D.html' %> B.session D. when added to stockindices.<%@include page='nasdaq. D..jsp uses the latest nasdaq.getResourceAsStream("/WEB-INF/data.

D 30)C OCEJWCD 6 Mock Questions . A.If the doStartTag() returns SKIP_BODY D. Regarding the processing of a BodyTag handler. in which of the following cases a BodyContent object will be "pushed" into the pageContext? Select 1 correct option.If the doStartTag() returns EVAL_BODY_BUFFERED C. <tag-lib> .3 1.D.D 26)E 27)C 28)D 29)C.F 23)D 24)E 25)C.Which of the following deployment descriptor snippets would you use to declare the use of a tag library? 1.E 6)C.2 (Answers) 1)B 2)B.E. A. It increases network performance by introducing one coarse grained remote call for multiple finer grained network calls C.If the doStartTag() returns EVAL_BODY_INCLUDE B.E 20)D 21)A 22)B.E 18)B 19)C.OCEJWCD 6 Mock Questions .B 8)B 9)B 10)B 11)D 12)A 13)C 14)D 15)E 16)C 17)A.C.It increase server throughput by utilizing the CPU better E.D 7)A. B.It increases complexity by increasing the number of remote interfaces.If the doStartTag() DOES NOT return SKIP_BODY E.D.C.D 3)C 4)C 5)A.It reduces network traffic by introducing one coarse grained remote call for multiple finer grained network calls D.A BodyContent object it is always created and pushed no matter what doStartTag() returns 2.Which of the following apply to Transfer Object design pattern? Select 2 correct options.It increases design overhead due to versioning issues 3.

<taglib> <taglib-uri>http://abc.net/ourlib.net/ourlib.5 . A.<uri>http://abc.1 B.net/ourlib.tld</uri> <location>/WEB-INF/ourlib.net/ourlib.tld</taglib-location> </taglib> 4.4 E. <taglib> <uri>http://abc. <taglib> <tagliburi>http://abc.tld</location> </taglibmap> Select 1 correct option.net/ourlib.tld</location> </taglib> 5.tld</uri> <location>/WEB-INF/ourlib.tld</location> </tag-lib> 2. <taglibmap> <uri>http://abc.tld</location> </taglib> 3.3 D.2 C.tld</uri> <tagliblocation>/WEB-INF/ourlib.tld</uri> <location>/WEB-INF/ourlib.tld</taglib-uri> <taglib-location>/WEB-INF/ourlib.

IOException</exception-type> <page-location>/html/Test.Book must have a public no args constructor C.Book" type="java.io.io.Book must have a public constructor but there is no requirement on arguments.Business View E.html</location> </error-page> 2.4. this page is serviced to the browser. <error-page> <exception-type>java. 6.This statement is wrong as type attribute is invalid.html</location> </error-page> 3.IOException</exception-class> <location>/html/Test.View Logic B.html</page-location> </error-page> 4.Model View Controller D. A. A.Business Delegate 5.Book must have a public getInstance() method. <error-page> . For this jsp code to compile and run which of the given options should be true? <jsp:useBean class="com.bookstore.Front Controller C.IOException</exception> <location>/html/Test.Object" id="book" /> Select 1 correct option.Which of the following design patterns is used to separate the task of writing the GUI screens and business logic? Select 1 correct option.Your servlet may throw IOException while processing a request.This statement will always throw an exception at runtime no matter what you do to Book class. <error-page> <exception-class>java. Which of the following XML fragments correctly specify the mapping: 1.lang. B. You want to define an error page in your deployment descriptor so that whenever IOException is thrown. <error-page> <exception>java. E. D.io.

A. A.4 E.getSession(false). A.Select the tag that comes directly under the <web-app> tag of a web.getSession(false).Consider the following JSP code (See exhibit).html</location> </exception> Select 1 correct option.IOException</exception-type> <location>/Enthuse/html/Test.5 7.io.It will print Hello! .1 B.listener-class E.context-listener-class D. } else request.<exception-type>java.setAttribute("count".getAttribute("count"). What will it print for the very first request to this page as well as the web application that contains this page? <html><body> <% Integer count = (Integer) request. if(count != null ) { out.listener C. <exception> <exception-type>java.println(count). %> Hello! </body></html> Select 1 correct option.3 D.servlet-context-listener B.2 C.IOException</exception-type> <location>/Enthuse/html/Test.html</location> </error-page> 5.io.xml and that is used to specify a class whose object will be sent notifications when changes occur to the SevletContext? Select 1 correct option. new Integer(1)).context-listener 8.

E.abc.None of these.E OCEJWCD 6 Mock Questions .getSession(sid).3 (Answers) 1)C 2)B. 9. B. B. D.HttpSession session = request.BankServlet</servlet-class> <security-role-ref> <role-name>manager</role-name> <role-link>supervisor</role-link> </security-role-ref> </servlet> Which of the following statements are correct? Select 1 correct option.isUserInRole() method.The role of "manager" must be defined in the servlet container.C 3)C 4)B 5)B 6)D 7)B 8)B 9)A.HttpSession session = HttpSession.isUserInRole() method. The application must provide interfaces for HTML as well as XML and should be maintainable.getSession().HttpSession session = request.getSession(sid). C. A. OCEJWCD 6 Mock Questions .You are designing a complex webapp that uses multi tier architecture.The servlet code can use "manager" or "supervisor" as a parameter in request.getSession(false). C. A.Data Access Object .xml code snippet: <servlet> <servlet-name>BankServlet</servlet-name> <servlet-class>com. E. A.Which design pattern would you use? Select 1 correct option.4 1.isUserInRole() method. C.The servlet code should use "manager" as a parameter in request.getSession(true).HttpSession session = request.HttpSession session = request.Consider the following web.It will not compile.It will print Hello and will set the count attribute in the session. D.D. Which of the options will retrieve the HttpSession associated with the request? (Assume that the session has already been created.bankapp.It will throw a NullPointerException at request time.The servlet code should use"supervisor" as a parameter in request. The following line of code exists in the doGet method of Servlet: String sid = request. 2.getParameter("jsessionid").) Select 3 correct options. D.B.

Password is transmitted either in encrypted text or in plain text depending on the browser.InputStream B.This mechanism can be used over HTTPS.net.tag 4.Identify the elements that help describe the attribute characteristics of a JSP custom tag in a TLD file.Bimodal DataAccess 6.java. 5.Business Deligate C.include E.Resource and java.Password is transmitted in an encrypted form.code> <html> <body> <% String a = "aaa".Which of the following directives are applicable ONLY for tag files? Select 3 correct options.Transfer Object D. D.Business Delegate C.B. %> <%! String a = "AAA".io.java.java.MVC D.HTML FORM is used to capture the username and password of the user.Which pattern allows you to replace the presentation logic without much impact on the data representation? Select 1 correct option.Model View Controller B.Remote Method Invocation E. A.import F. A.io.Password is transmitted as plain text.io. A.URL and java.InputStream E.Resource and java. %> .io. %> <% String b = "bbb".variable C.attribute B. B.io.rtexprvalue E.description D.io. C.URL and java. A.net. E. %> <%! String b = "BBB".Which of the following are correct about FORM based authentication mechanism? Select 3 correct options.java.class 7.name C. A.getResourceAsStream() methods.FileInputStream 8.java.File and java.value B.BufferedInputStream C.page D.InputStream D.io.getResource() and ServletContext.println(a+b).Transfer Object 3.Consider the following jsp code: .Select the correct return types for ServletContext.Data Access Object E. Select 3 correct options. %> <% out.io. Select 1 correct option.

aaabbb B. A.CONFIDENTIAL B.SECURE D.AAAbbb D.Consider the tag handler class shown in exhibit.getOut().Compilation error! 9.Write the parent element of <session-timeout> element.ENCRYPTED E.Hello B.println("In doAfterBody()").Which of the following are valid values for the <transport-guarantee> element? Select 3 correct options.Which of the following HTTP protocol methods is eligible to produce unintended side effects upon multiple identical invocations beyond those caused by single invocation? . A. 12.None of the above.Hello In doAfterBody() World! D. A. 11.Hello In doAfterBody() E. } } Select 1 correct option.Hello World! C.NONE 10.AAABBB E.INTEGRAL C.aaaBBB C.</body> </html> What will be the output? Select 1 correct option. What will be printed when the above tag is used as follows in a jsp page: Hello <mylib:mytag> World!</mylib:mytag> public class MyTag extends TagSupport { public int doAfterBody() { try { pageContext. } catch(Exception e) { } return SKIP_BODY.

SmilyTag</tag-class> <description> Replaces emoticons such as :).app.Select 1 correct option. A. A.app.HEAD D.enthuware. and :( </description> <body-content>tagdependent</body-content> <attribute> <name>name</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> with images.setContentType E.OPTIONS 13. B.POST C.setAttribute D. Options.getParameter("dbname").Consider the following description of a tag in a TLD: <tag> <name>SmilyTag</name> <tag-class>com.<jsp:useBean id="mybean" beanName="my.Which of the following lines can be used to retrieve a servlet initialization parameter "dbname" from the init() method of a servlet? public void init() { String dbname = //1 : Insert line here } Select 2 correct options.MyBean" class="my.getInitParameterValue("dbname").getServletConfig().Which method of ServletResponse would you use to set its content type? Select 1 correct option. . E.True B.getInitParameter("dbname"). A.setParameter B.PUT E. 14.setHeader C. :D. 16.GET B.None of the above.getInitParameter("dbname"). D.getServletConfig().False 15.getInitParameter("dbname").ctags.getServletContext().MyBean" /> is a valid useBean declaration. A. C.

A. while(enum.getParameter(obj)).hasMoreElements()) { Object obj = enum. } %> 4.hasMoreElements()) { String obj = (String) enum.It must have a body D.It may be used as an empty tag.nextElement().hasMoreElements()) { String obj = (String) enum. E.nextElement(). <% Enumeration enum = request.getParameters().getParameterNames(). C.getParameterNames(). while(enum. its value must be dynamic.It must implement BodyTag interface. } %> 3.It is an empty tag. while(enum.</tag> Which of the following statements regarding the above tag are correct? Select 2 correct options. <% Enumeration enum = request.getParameterNames().nextElement(). B.hasMoreElements()) { Object obj = enum.getParameter(obj)). But if present. 17. } %> 2.getParameter(obj)). out. out.println(request.It may take an attribute named 'name'. %> .nextElement().println(request.Which of the following jsp fragments will print all the parameters and their values present in a request? 1. <% Enumeration enum = request.println(request. <% Enumeration enum = request. while(enum. out.

20. A. A.code> public void doGet(HttpServletRequest req.<% int k = 10.<%@ page language="java" import="com.How can you ensure the continuity of the session while using HttpServletResponse.page C.A Tag Handler implements BodyTag interface.3 D.sendRedirect() method when cookies are not supported by the client? Select 1 correct option. %> <% } %> 5. consider the following code for the doGet() method of a servlet for the same web application.<%! int k = 10 %> B. .Given: You have configured a listener class (see exhibit) in web.By enconding the redirect path with HttpServletResponse.2 C. B.<%=somevariable%> D.nextElement().Any number of times.By using HttpServletRequest.getParameter(obj)%> <% } %> Select 2 correct options.abc.hasMoreElements()) { String obj = (String) enum.xml of a web application.getParameter(obj). E. <% Enumeration enum = request. How many times its doAfterBody method may be called? Select 1 correct option.1 B. Now.error B.<%@ taglib uri="http://www.getParameterNames().encodeURL() method. A.Which of the following statements are valid JSP directive? Select 2 correct options.encodeURL() method.1 D.*"%> 19. A. %> C.Which of the following are valid implicit variables in a JSP page? Select 2 correct options.encodeURL() method.BodyTag does not support doAfterBody.root E.<%=request.this D. B.0 or 1 E.4 E.By using HttpSession. HttpServletResponse res) { .0 C. C. while(enum.com/tags/util" prefix="util" %> E. %> <%=request.5 18.abc.By using HttpServletResponse.By using hidden parameters. 22.context 21. A. D.encodeRedirectURL() method.

com/tags/util" prefix="util" %> E.Which of the following interfaces declares the methods jspInit() and jspDestroy()? Select 1 correct option. A.<%@ page %> B.out.getContext().PageContext 26.HttpSession B. 23.servlet.abc.abc. D. key).<%! taglib uri="http://www.sce. A. B.javax.abc.*.servlet.jsp.HttpJspServlet 24.jsp.javax. // 1 Insert code here.jsp.this.getServletContext().JSP B.jsp.setAttribute("key".javax.Which of the following classes hides the implementation details and provides a standard API to the services provided by the servlet container to a jsp page? Select 1 correct option. public class MyListener implements ServletContextListener { public void contextInitialized(ServletContextEvent sce) { Integer key = new Integer(100).setAttribute("key".setAttribute("key".getAttribute("key").getServletContext().JspPage D.servlet.<%@ taglib uri="http://www.servlet.com/tags/util" prefix="util" %> C.getContext().JspServlet C.<%$ page language="java" import="com. E. } public void contextDestroyed(ServletContextEvent sce) { } } Select 1 correct option.*"%> 25.javax.this.getServletContext().sce.html"%> D.<% include file="/copyright. key). //2 } Which option can be inserted at //1 in the listener code so that servlet code at //2 prints 100? import javax.HttpJspPage E. A.JspPage D. A.Which of the following statements are correct JSP directives? Select 2 correct options.System. key).println(this.servlet. key). key).Servlet C. C.jsp.javax.setAttribute("key".this.setAttribute("key".ServletContext E.Which of the following are true regarding the parameters defined using the <context-param> element of a deployment descriptor? .servlet.

Catch the exception.True B.Servlet B.xml C.By calling finalize() on session object.Which of the following is a sensible way of sending an error page to the client in case of a business exception that extends from java.Human" scope="application"/> In which type of object will this bean be kept? Select 1 correct option. B. A. B. wrap it into ServletException and define the 'business exception to error-page' mapping in web. A.You cannot.xml D. and define the 'ServletException to error-page' mapping in web.E 5)A 6)B.Don't catch the exception and define the 'exception to error-page' mapping in web. 28.B.HttpSession C.E .D 7)C 8)A 9)A.Don't do anything. wrap it into ServletException.Business delegate pattern should be used to enable communication between the JSP code and the enterprise javabeans.E 10)session-config 11)A 12)B 13)D 14)B 15)B.False OCEJWCD 6 Mock Questions .4 (Answers) 1)A 2)C 3)A. A.By calling expunge() on session object.ServletConfig E.ServletContext D.Catch the exception and use RequestDispatcher to forward the request to the error page.They are accessible from multiple threads simultaneously and from any servlet of the web application. A.By calling invalidate() on session object. B. the servlet container will automatically send a default error page 30. It can only be expunged automatically after session timeout expires.How can you explicitly expunge the session object? Select 1 correct option.B.lang.They can be modified using the setAttribute() method.D 17)C. A.Select 2 correct options.F 4)A.B.They can be modified using the setParameter() method.C.D 16)B.They are thread safe. D.Catch the exception. C.By calling delete() on session object E.They can be modified using the setInitParameter() method. D. Options. E. 27.xml E.You have declared a useBean tag as: <jsp:useBean id="man" class="animal.Exception? Select 2 correct options.ApplicationContext 29. C.

A String containing "image/gif.5 1.A Header object containing..None of these. You need to send large amount of binary data from the browser to a servlet to be processed. you want to attach a file while sending email through a web based system).doStartTag B. name as "Accept" and value as "image/gif". A..For each request to the servlet that causes a new thread to be created.PUT 3. image/bmp What will be returned when the servlet code calls request. D.A Header object containing.) B.Which of the following methods may be called on a custom tag handler that implements IterationTag interface? Select 2 correct options.A String array containing "image/gif".Assume that the following header is present in a request sent to a servlet: Accept: image/gif.doInitBody E. B.18)D. name as "Accept" and value as "image/gif. image/jpeg.For each request to the servlet that causes a new session to be created.A String array containing "image/gif"" D.If the request is from the user whose session has expired.GET B. (Say.Initialy when the servlet instance is create and then at request time if the request is from the user whose session has expired. 4. A.addHttpSessionAttributeListener(.doAfterBody D. C..POST C.An object of a class implementing this interface is automatically configured when it is added to the session. A.doEvalBody . A. image/jpeg.C 30)A OCEJWCD 6 Mock Questions .HIDDEN E.For each request to the servlet B.By calling HttpSession.Only once in the life time of the servlet instance E. 5. image/bmp" 2. image/jpeg. What HTTP method would you use? Select 1 correct option. C.. Select 1 correct option.doBodyTag C. image/bmp".C 21)E 22)E 23)C 24)A..By calling HttpSession. A.B 27)B 28)C 29)A.E 19)B 20)B. F. image/bmp".addAttributeListener(.D 25)E 26)A. "image/jpeg". D.getHeader("Accept")? Select 1 correct option.HEAD D..Servlet Container calls the init method on a servlet instance . E.) C.Which of the following is a possible way to configure an HttpSessionAttributeListener? Select 1 correct option.

printStackTrace(). B.getRequestDispatcher("Login.jsp is requested by an unauthorized user? <web-app> .This code will work just fine.jsp: <html> <body> <jsp:include page="/jsp/protected. } } Select 2 correct options.xml defines a mapping between a servlet and a URL pattern? Select 1 correct option. A. // 2 } catch(Exception e) { e. A.servlet-url C.Which of the following elements of web.url_mapping D.getRequestDispatcher("Login. res).getServletContext(). D.url_pattern E. C.forward(req.Following is the code for doGet() method of TestServlet.This will compile but will not work as expected.getRequestDispatcher("Login. 8. // 1 rd.mapping B.It will compile but not work properly if //1 is replaced with: RequestDispatcher rd = req.xml snippet shown in the exhibit. Now consider the code for a jsp file named unprotected.jsp").This will not compile.servlet-mapping 7.jsp" /> </body> </html> Which of the following statements hold true when unprotected. HttpServletResponse res) { try { RequestDispatcher rd = this.jsp").jsp").It will compile and will work properly if //1 is replaced with: RequestDispatcher rd = req.Consider the web. Which of the given statements about it are correct? public void doGet(HttpServletRequest req. E.6.

The call to include will be ignored E.*"@%> 13.> B.application for both E.<%@ forward .<jsp:include .<%@ page import="java. </web-app> Select 1 correct option.A servlet explicitly calls invalidate() on a session object.....<%@ page java="java.. <security-constraint> <web-resource-collection> <web-resource-name>test</web-resource-name> <url-pattern>/jsp/protected.jsp will be executed but it's output will not be included in the response D.include . A.util...util.> E.An exception will be thrown C. A..The user will be prompted to enter user name and password B.pageContext and config B.util..<%@import java.The container is shutdown and brought up again B.Which of the following implicit variables should be used by a jsp page to access a resource and to forward a request to another jsp page? Select 1 correct option.Consider the following contents for two JSP files: .A servlet explicitly calls invalidate() on a session object..*"%> D. 12.Which of the following JSP elements can have a <jsp:param .> element in its body? Select 1 correct option...application and config C. D. A.config for both 11.> C.protected.<%@ page import="java.util.*"@%> C.jsp</url-pattern> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> </security-constraint> .None of these 9...No request comes from the client for more than "session timeout" period...*"@%> E.> 10.Your jsp page uses classes from java.config and pageContext D.<jsp:directive..In which of the following situations will a session be definitely invalidated? Select 3 correct options./> D. A.<%@ include . C.util.util package.* %> B.<jsp:action .<%import="java. Which of the following statement would allow you to import the package? Select 1 correct option A.

companyhome.When companyhome. HttpResponse).jsp: <html><body> Welcome to ABC Corp! <%@ page errorPage="simpleerrorhandler." as well as "Todays News" B. E.jsp: <%@ page errorPage="advancederrorhandler.post(HttpRequest. C..companynews.doPost(HttpRequest. D.servicePost(HttpRequest. Assume that RegisterServlet <html> <body> <form action="/myapp/RegisterServlet"> <input type="text" name="method" value="POST"> <input type="text" name="name"> <input type="password" name="password"> <input type="submit" value="POST"> </form> </body> </html> Select 1 correct option. the output will contain "welcome.Which method of RegisterServlet will be called when the user clicks on "Submit" button for the following form. But you have not yet decided whether the business rules will be fully . A.jsp" %> </body></html> In file companynews. HttpResponse).jsp will not compile D.jsp will not compile C.jsp" %> <h3>Todays News</h3> Which of the following statements are correct? Select 1 correct option A.You are building the server side of an application and you are finalizing the interfaces that you will provide to the client side. HttpResponse).jsp" %> <%@ include file="companynews. B.None of these 14. 15.None of the above. HttpResponse).jsp is requested.Both the files will compile but will throw an exception at runtime.In file companyhome.doPOST(HttpRequest. E..

<login-config> <auth-method>CLIENT-CERT</auth-method> <realm-name>test</realm-name> </login-config> 2.Business Delegate D.jsp</form-error-page> </form-login-config> </login-config> .implemented as stored procedures or in the java code.jsp</form-error-page> </form-login-config> </login-config> 3.Which of the following XML frgaments correctly define the <login-config> element of web. Which design pattern you should use to mitigate this concern? Select 1 correct option. <login-config> <auth-method>FORM</auth-method> <realm-name>test</realm-name> <form-login-config> <form-login-page>/jsp/login.jsp</form-login-page> <form-error-page>/jsp/error. A.) 1.Transfer Object 16.Model View Controller B.Facade E.xml? (See Exhibit. <login-config> <auth-method>CLIENT-CERT</auth-method> <realm-name>test</realm-name> <form-login-config> <form-login-page>/jsp/login.Data Access Object C.jsp</form-login-page> <form-error-page>/jsp/error.

18.Make the class of the object implement HttpSessionBindingListener B.Retrieving an image B. What would you do to accomplish this? Select 1 correct option A.Only way is to configure a HttpSessionAttributeListener in the deployment descriptor 19.DataOutputStream . A.JspWriter E. what is the type of the implicit variable 'out'? Select 1 correct option.Authentication and Authorization E.You want to do some calculations within the object whenever it is added to the session. <login-config> <auth-method>FORM</auth-method> <realm-name>test</realm-name> </login-config> 5.Submitting a form not containing login or other critcal information D.PrintStream C.2 C.4 E. A.5 17.Privacy D.OutputStream B.Authorization B.What are the following deployment descriptor elements used for? <login-config> <security-constraint> <security-role> Select 1 correct option. <login-config> <auth-method>SECURE</auth-method> <realm-name>test</realm-name> </login-config> Select 3 correct options.Make the class of the object implement HttpSessionListener D.Updating a database 20.In the case of JSP pages.Configure a HttpSessionAttributeListener in deployment descriptor C.4. A.Authentication C.GET method is not suitable for which of the following operations? Select 2 correct option.Retrieving a zip file C.1 B.Submitting a login form E.3 D.Data integrity.PrintWriter D. A.Configure a HttpSessionActivationListener in deployment descriptor E.

Match the following.21.util.*"/> B. %> 22.html</location> </error-page> 2.%> <jsp:directive. <error-page> <exception-type>java.util. You want to define an error page in your deployment descriptor so that whenever IOException is thrown.page import="java. this page is serviced to the browser.<directive.<jsp:page import="java.Consider the following tag occuring in a JSP page: <%@page import="java.Your servlet may throw IOException while processing a request. Which of the following XML fragments correctly specify the mapping: 1.*"%> Which of the following is the XML equivalent of the above tag? Select 1 correct option.<%jsp:directive.util.<jsp:directive.<page import="java.*"/> E.String x = "123" --%> <%!String x = "123".html</page-location> </error-page> .io.util.html</location> </error-page> 3.page import="java.IOException</exception-class> <location>/html/Test.*"%> D.IOException</exception-type> <page-location>/html/Test. <error-page> <exception>java.page import="java.getParameter("name").util.*"/> 23.jsp' /> <%-.*"/> C. A.io.getParameter("name")%> <%request. <error-page> <exception-class>java.io.util.IOException</exception> <location>/html/Test.include file='hello. Comment directive declaration scriptlet Custom tag expression <tags:simple name='bob' /> <%=request.

<security-role rolename=manager></security-role> 3.2 C. <security-role> <role-name>manager</role-name> . <security> <role-name>manager</role-name> </security> 4.encodeURL() method. E.encodeRedirectURL() method.By using HttpSession.By using hidden parameters.By using HttpServletResponse.html</location> </exception> A.sendRedirect() method when cookies are not supported by the client? Select 1 correct option A.How can you ensure the continuity of the session while using HttpServletResponse. <error-page> <exception-type>java. B.IOException</exception-type> <location>/Enthuse/html/Test.html</location> </error-page> 5.io.xml? 1.1 B.4 E. C.By enconding the redirect path with HttpServletResponse.IOException</exception-type> <location>/Enthuse/html/Test. D.By using HttpServletRequest.encodeURL() method. <exception> <exception-type>java. <security-role>manager</security-role> 2.io.3 D.5 24.Which of the following XML fragments correctly defines a role named "manager" in web.encodeURL() method 25.4.

Which of the following statements are correct? <?xml version="1. Which of the following is a correct use of this tag? Select 1 correct option.//DTD Web Application 2.sun.3 D.<fib:sequenceengine>20</fib:sequenceengine> .getParameter(String name.dtd"> <web-app> <servlet> <servlet-name>TestServlet</servlet-name> <jsp-file>/requestinfo.a is sent to this web application named test. A.getParameterNames().a C.You are using a tag library with prefix "sequenceengine" which supports a tag named "fib". C.4//EN" "http://java.4 26.<sequenceengine:fib>20</sequenceengine:fib> B. 27. A.1 B.Consider the code for the web.0" encoding="ISO-8859-1"?> <!-.getParameter(String name).</security-role> Select 1 correct option.Which of the following methods of HttpServletRequest can be used to retrieve the parameter values sent from the browser? Select 2 correct options A. String defaultValue).2 C.getParameters(String name).com/dtd/web-app_2_4. This tag expects a parameter named "limit" of type int.RequestPath of this request will be /test//aaa/abc.xml for a web application (See exhibit).This request will be serviced by requestinfo.None of these.a B. 28.Assume that DOCTYPE is valid --> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems.getParameterValues(String name). A.Path Info of the request will be /aaa/abc. Inc. D. E.jsp E. B.ContextPath of this request will be /test/aaa D.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>TestServlet</servlet-name> <url-pattern>*. Assume that a request: http://localhost:8080/test/aaa/abc.a</url-pattern> </servlet-mapping> </web-app> Select 1 correct option.

IUser" /> C.xml C.jsp' /> declaration <%!String x = "123".servlet.<jsp:useBean id="user" type="myco.getParameter("name").E 20)D 21)comment <%-.6 1.User" /> D.util.By specifying a mapping between exception class and the resource in web.<fib:sequenceengine limit="20"></fib:sequenceengine> 29.ServletException D.User" class="myco.getParameter("name")%> 22)E 23)D 24)B 25)D 26)A. %> scriptlet <%request.5 (Answers) 1)D 2)B 3)D 4)D 5)A.util.User" /> E.Which constant is used to notify the container to reevaluate the custom tag's body? .How can you redirect the request from a servlet to another resource if the servlet encounters an exception? Select 2 correct options A.<jsp:useBean name="user" class="myco. B.String x = "123" --%> directive <jsp:directive.User" /> B.This can be done only if the exception is a subclass of javax.C 17)D 18)A 19)D.D 12)C 13)B 14)E 15)C 16)A.D 27)D 28)D 29)B.include file='hello.User" type="myco.interfaces.D 30)A.B.B.<jsp:useBean id="user" beanName="myco.C 6)E 7)C.<sequenceengine:fib limit="20"></sequenceengine:fib> E.%> custom tag <tags:simple name='bob' /> expression <%=request.E OCEJWCD 6 Mock Questions .E 8)E 9)A 10)D 11)B.<jsp:useBean id="user" class="myco.<jsp:useBean id="user" beanName="myco.util.This cannot be done unless the exception is caught in the servlet.C.<sequenceengine:fib attribute-name="limit" attributevalue="20"></sequenceengine:fib> D.Which of the given options correctly declare a useBean tag? Select 3 correct options A.C.IUser" /> OCEJWCD 6 Mock Questions .interfaces.This can be done even if the exact class of the exception is not known at compile time 30.

Can be used to declare a JavaBean instance in a JSP page C. ServletResponse res) 4. Can be used to generate HTML code to embed an applet on a web page D. Value Object B. 3. Provides translation-time instructions to the JSP engine. ServletResponse res) { // Do something } } A. A. import javax. } public void destroy() { // Do something } public void service(ServletRequest req. Method //5 is necessary for this code to compile 5. Method //1 is necessary for this code to compile B. Data Access Object . EVAL_BODY_AGAIN D. import javax. public class MyServlet extends GenericServlet { public void init() { // Do something } public void init(ServletConfig config) throws ServletException{ // Do something super.*. Which of the following statements regarding the JSP action tag are TRUE? Please select three correct answers. EVAL_BODY_INCLUDE 2. ServletResponse res) E.http.Which of the following methods can be used to pass request to another servlet to handle by using the RequestDispatcher? Please select two correct answers. ServletResponse res) D.init(config). process(ServletRequest req. ServletResponse res) C. Which pattern is normally used to encapsulate database SQL statement? //1 //2 //3 //4 //5 Please select one correct answer. request(ServletRequest req.servlet. what would be the output you can expect to see on the web page? Please select one correct answer. language is a standard JSP action. forward(ServletRequest req. A. Given the following code snippet. EVAL_BODY B. B. EVAL_BODY_TAG C.servlet.*. dispatch(ServletRequest req. A. ServletResponse res) B. User-defined actions can be created E. Method //2 is necessary for this code to compile C. Data Value Object C. Method //4 is necessary for this code to compile E.Please select one correct answer. Line //3 is necessary for this code to run D. include(ServletRequest req. A.

the code will generate run-time error. A.The method is called by the server (via the service method) to allow a servlet to handle a POST or GET request. Model View Controller B. If MAX_AGE = -1 the cookie is not stored persistently E. example/WEB-INF B. If MAX_AGE = -1. If MAX_AGE = 10 the cookie will expire after 600 seconds.For special character used in request URI.The method is called by the server (via the service method) to allow a servlet to handle a POST request D. If MAX_AGE = 10 the cookie will expire after 10 seconds.Which statements are TRUE regarding the HttpServlet method doPost(HttpServletRequest req. Business Delegate D. D. example/lib C. example/WEB-INF/classes E. getInitParameterValue(String name) 11. C. Operations requested through this method will NEVER have side effects.The method is called by the server (via the service method) to allow a servlet to handle a POST or PUT request B. Business Delegate 6. int MAX_AGE. C. Data Access Object C. Business Object E.D. 7. HttpServletResponse res)? Please select two correct answers. example/META-INF/lib 13.addCookie(cookie).Which of the following design pattern is used to reduce the amount of network traffic when transferring data? Please select one correct answer A. If MAX_AGE = 0 the cookie will be deleted. 8. Value Object 9. getParameter(String name) B. A. The ampersand (&) is used to separate name/value pairs. example/WEB-INF/lib D. The dash sign (-) is used to separate the name and value.Which of the following method is used to retrieve the value associated to the init parameter defined in the init-param tag? Please select one correct answer. which of the following statements are correct? Please select two correct answers. Which of the following statements are TRUE for the code given below? Please select three correct answers.What is the authentication type which uses digital certificates as a security mechanism for a web based application? 10. Cookie cookie = new Cookie("user". The percent sign (%) is used to start a query string. A. D. getParameters() D.setMaxAge(MAX_AGE). A. response. In which directory you will most likely find the file myBaseUtil.The method is called by the server (via the service method) to allow a servlet to handle a GET request E. 12. F. user). B. B.The method allows the client to send data of unlimited length to the Web server a single time. cookie.jar? Please select two correct answers. getInitParameter(String name) C.Which of the following requirements are needed for FORM based authentication in a web based application? . A. The plus sign (+) is used to fill blank space C.

Which of the following is NOT an authentication method used by a web container? Please select one correct answer. DIGEST C.util. log(int code.* 18. 14.lang. A. The form method must be POST. F.True B.* D. SSL D.jsp for web application with context path as "tech"? Please select one correct answer. <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/hello/*. <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>hello/*</url-pattern> </servlet-mapping> 15. BASIC B. log(String msg) B. getParameterValues(String name) E. HttpSession object. The name attribute for the username must be j_username D.False 17. B.Please select four correct answers. A. Which of the following methods will enable you to get one or more values from a request object? Please select two correct answers. The name attribute for the password must be j_password. javax. E. The session attribuite j_sessionid must be set.tagext.jsp</url-pattern> </servlet-mapping> D. A. <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/hello/index.servlet. <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping> B.jsp.Which of the following deployment descriptor snippet will map the following request URI: /tech/hello/index. C. getAllParameters() D. java. A. Which methods can be used for writing logging message to servlet log file? Please select two correct answers. Which of the following packages are implicitly imported in the JSP page? Please select three correct answers.servlet.servlet. The action or url must be j_security_check. getParameters(String name) C.* E. FORM 19.jsp</url-pattern> </servlet-mapping> C.jsp.* B. Client side cookie must be enabled. getParameter(String name) B. A. A. A. String msg) . URL rewriting and Hidden value. javax. getAllAttributes() 16. java. The four methods for session management in the context of web-based application are: Cookie.* C. javax. Is the following statement TRUE or FALSE? Please select one correct answer.

error.servet. C. Throwable t) 20.setAttribute("<%= theKey %>". %> session.servet. //2 session.error. There will have output as theValue at //4 23.servet. splitable 21. Which of the following are VALID servlet error attributes? Please select three correct answers...error. "<%= theValue %>"). session. There will have output as null at //4.. There will have compilation error at //2 and //3.query 22.getAttribute(theKey) %> //3 //4 //1 A. javax. javax. </taglib> B.. The code compiles but might have runtime NullPointerException at //1 B..getAttribute("<%= theKey %>"). String theValue = "value". distributable C.status_code B.. A. Which statement is TRUE about the following jsp code snippet? Please select one correct answer. <%= session. <% String theKey = "key"..xml to mark a web application to be suitable for running between multiple systems. </taglib> C. <tag> <name>myTag</name> <tag-class>MyTag</tag-class> </tag> . multiple B.Which tag is used in web. <taglib> .C. <taglib> . log(String msg.error.servet. A..removeAttribute(theKey). String msg. Which of the following are VALID taglib configuration? Please select three correct answers.message E.servet. D. A. log(int code. transferrable E. resource-ref D.uri D. javax. Throwable t) D. javax.error. <tag> <name>myTag</name> <tag-class>MyTag</tag-class> <body-content>SERVLET</body-content> </tag> . <taglib> . Please select one correct answer. javax.exception C.

context-attrib 26. The session attribute has default value as true B. A... taglib> . <tag> <name>myTag</name> <tag-class>MyTag</tag-class> <attribute> <name>name</name> </attribute> </tag> . </taglib> 24. what would be the output you can expect to see on the web page? Please select one correct answer..lang. param-name B. The buffer attribute has default value as 8kb C. context-value F. The isErrorPage attribute has default value as false F. param-value E..String</type> </attribute> </tag> .. <tag> <name>myTag</name> <tag-class>MyTag</tag-class> <tei-class>MyTagInfo</tei-class> <body-content>JSP</body-content> <attribute> <name>name</name> <required>true</required> <rtexprvalue>true</rtexprvalue> <type>java. The pageEncoding attribute has default value as ISO-8859-1 25.. A. <taglib> .Which of the following deployment descriptor tags are used for context level parameter initialization? Please select three correct answers. <tag> <name>myTag</name> <tei-class>MyTagInfo</tei-class> <body-content>JSP</body-content> </tag> . context-name C. The autoflush attribute has default value as false D.. context-param D. </taglib> E.. Given the following code snippet..... </taglib> D. The isThreadSafe attribute has default value as true E..Which of the following statement is FALSE regarding JSP page directive attributes default value? Please select one correct answer.. // Calling servlet: .

println("I am called by others!"). IOException { PrintWriter out = res.println("<HTML><BODY>").close(). A.Which of the following method is called upon the initialization of a servlet context? Please select one correct answer A. out.model. out.Which statement is NOT true about the SingleThreadModel interface? Please select one correct answer A. D. 28. <jsp:useBean beanName="TestUser" class="com.setContentType("text/html").getWriter().User" /> E.model.println("</BODY></HTML>").The servlet container will ensure there will be only one instance of the servlet at a time if the servlet implements this interface E.test.include(req.public void doGet(HttpServletRequest req."I am called by others!" C."I am calling others!" B. XML equivalent for JSP page directive <%@ page buffer="16kb" %> is <jsp:page buffer="16kb"/> 30. contextInitialize(ServletContext e) D.model. out. contextInitial(ServletContext e) C.Class variables are not protected by this interface.XML equivalent for JSP expression <%= expression %> is <jsp:expression>expression</jsp:expression> B.User" /> B. Which of the following statements are TRUE? Please select three correct answers A. XML equivalent for JSP include directive <%@ include file="url" %> is <jsp:include file="url"/>. PrintWriter out = res.servlet.XML equivalent for JSP declaration <%! declaration %> is <jsp:declaration>declaration</jsp:declaration>.model. Which statement is TRUE regarding the following code? Please select one correct answer. . HttpServletResponse res) throws ServletException.User" /> D. <jsp:useBean beanName="TestUser" class="com. out. out.model.*. IOException { res.User" /> 31.User" /> C.<jsp:useBean id="user" beanName="TestUser" type="com. but instance variables are protected.test.An IOException is thrown 27. contextInitializing(ServletContextEvent e) B.test. contextInitialize(ServletContextEvent e) E. res). no two threads will execute concurrently in the servlet's service method C.If a servlet implements this interface.By implementing this interface it ensures that servlets handle only one B.getWriter().<jsp:useBean id="user" beanName="TestUser" class="com.test. Please select CORRECT JSP useBean declaration methods Please select three correct answers A. <jsp:useBean id="user" type="com.An IllegalStateException is thrown E. } // Target servlet: protected void doGet(HttpServletRequest req. HttpServletResponse res) throws ServletException.Both "I am calling others!" and "I am called by others!" D.XML equivalent for JSP scriptlet <% scriptlet %> is <jsp:scriptlet>scriptlet</jsp:scriptlet> C. rd.test. import javax.This interface has no methods D. where url must be relative E.getRequestDispatcher("/MyServlet").println("I am calling others!"). contextInitialized(ServletContextEvent e) 29. RequestDispatcher rd= req.

Variable bufferOne at //1 is NOT thread-safe.jsp /images/logo.import javax.close().class B.IOException{ HttpSession session = req. out.println("</body>").io. out.Variable bufferTwo at //2 is NOT thread-safe C.Both D and E 32. } A.servlet.gif /WEB-INF/web.getWriter(). /index.jsp /images/logo.getSession().http. java.gif /WEB-INF/web. static StringBuffer bufferTwo = new StringBuffer(). res.xml /WEB-INF/jar/basic.gif /META-INF/web. out. HttpServletResponse res) throws java.gif /WEB-INF/web. //1 //2 //3 //4 A. out.Variable session at //4 is NOT thread-safe F.Variable req at //3 is NOT thread-safe E. out.html /login. out.io.Select sample web application file listing with appropriate directory structure Please select two correct answers. /index. public class MyHttpServlet extends HttpServlet implements SingleThreadModel { StringBuffer bufferOne = new StringBuffer().html /login. protected void doGet(HttpServletRequest req. out.xml /WEB-INF/lib/basic. out. B.Both A and B D.println("<head>").println("<html>").jar /WEB-INF/classes/Test.PrintWriter out = res.html /login. /index.println("<body>").html /login.jar /WEB-INF/classes/Test.class D.*.xml .jsp /images/logo.println("<title>This is my servlet!</title>").setContentType("text/html"). index.xml /WEB-INF/classes/basic.println("</head>").println("</html>").jsp /images/logo.jar /WEB-INF/classes/Test.class C.

index. Context attributes 34.Port name 36. /index. A. Which of the following element is not included in a URL? Please select one correct answer A. HttpSessionBindingListener B.class E.jar /WEB-INF/classes/Test. _jspDestroy() 35. Static variables D. HttpSessionChangedListener 37.jar /WEB-INF/classes/Test. jspService().xml /WEB-INF/jsp/login. _jspService(). Class variables E. HttpSessionListener E.jsp /images/logo.gif /WEB-INF/web. HttpSessionListener D. Local variables B. _jspDestroy() D. Client ip B. Instance variables C.html /login.jsp /WEB-INF/lib/basic. A. Which of the following data element will definitely be thread-safe? Please select one correct answer A.gif /META-INF/web. Which of the following best describes the life cycle of a JSP? Please select one correct answer. jspInit(). jspDestroy() B. SessionBindingListener C.Protocol C.class F. JSP is compiled JSP is translated into a servlet code Servlet is loaded into memory Servlet instance is created D./WEB-INF/jar/basic.jar /WEB-INF/classes/Test. jspInit(). JSP page is translated into a servlet code Servlet is loaded into memory Servlet code is compiled Servlet instance is created C. JSP page is translated into a servlet code Servlet code is compiled Servlet is loaded into memory Servlet instance is created B. . _jspService().Query string E. jspService(). Which of the following listeners is notified when a session is initialized? Please select one correct answer. A. _jspInit().xml /WEB-INF/lib/basic.html /images/logo. jspDestroy() C. Select the correct order that JSP methods are invoked by servlet container Please select one correct answer.class 33.Server Name D. _jspInit().

jsp</form-login-page> <form-error-page>/error.</description> <role-name>Manager</role-name> </security-role> C.service B. <security-constraint> <web-resource-collection> <web-resource-name>SecureStuff</web-resource-name> <url-mapping>/servlet/secure</url-mapping> <http-method>POST</http-method> </web-resource-collection> </security-constraint> D. A. <security-constraint> <web-resource-collection> <web-resource-name>SecureStuff</web-resource-name> </web-resource-collection> <auth-constraint> <role-name>Broker</role-name> </auth-constraint> </security-constraint> 40.filter E. Please identify the three methods declared in javax. JSP page is translated into a servlet code Servlet code is compiled Servlet instance is created Servlet is loaded into memory 38.JSP is loaded into memory Servlet code is compiled Servlet instance is created Servlet is loaded into memory E.jsp</form-error-page> </login-config> </login-config> B. Please select one correct answer docbase = c:/temp/ context path = /test .destroy D. <security-role> <description>My description. A.Filter Please select three correct answers.servlet.doFilter 39. please construct the full path for the servlet.init C. <security-constraint> <auth-constraint> <role-name>Broker</role-name> </auth-constraint> </security-constraint> E. <login-config> <auth-method>FORM</auth-method> <login-config> <form-login-page>/login.Which of the following deployment descriptor segments are VALID for security-related configuration of a web application? Please select two correct answers.Based on the following information.

Sending credit card number E. .alias name = MyMail servlet-name = com.Searching record in a database 47. A.Retrieving an image D.c:/temp/mail/test/com/jiris/common/util/MailServlet.TRACE E.Inserting a record into a database B. Object obj) C. addAttribute(String name.c:/temp/test/mail/com/jiris/common/util/MailServlet.doEndTag() 45. A.HttpServlet B.util.sendError(int code.POST C.doInitBody() C.c:/temp/mail/com/jiris/common/util/MailServlet.Which of the following are CORRECT ways to define inactive period of 5 minutes of a session before the server invalidates it? Please select two correct answers A.sendError(int code.class C.c:/temp/test/com/jiris/common/util/MailServlet.log(String msg) B.Accessing a static page C.Which of the following methods are used to send an error page to the client? Please select two correct answers A.HEAD D. String obj) B. Throwable t) C. Object obj) E.The ServletContext object are accessible from which of the following objects? Please select three correct answers.doStartTag() B. setAttribute(String name. Which request method will be invoked for the following code? Please select one correct answer.<session-timeout>5</session-timeout> B.ServletResponse 42.common. setAttribute(String name.Which of the following requests should be performed by using a POST method? Please select two corretion.class 41. String msg. putAttribute(String name.class B. Object obj) 43.class D.Which of the following method might be invoked more than one time? Please select one correct answer A. String msg) E.<session-timeout>300</session-timeout> .GenericServlet C.Which of the following method is used to store object into a request object? Please select one correct answer A.jiris.HttpSession D. addObject(String name.ServletConfig E.doAfterBody() D.sendError(int code) D. Throwable t) 46.code> <html> <body> <form action=´/servlet/comment´> <p>Please provide your comment here:</p> <input type=´text´ size=´40´ name=´Comment´> <input type=´submit´ value=´Submit´> </form> </body> <html> A.PUT 44.log(String msg. String obj) D.MailServlet url-pattern = /mail/* A.GET B.

key type. jsp:useBean.EVAL_BODY_AGAIN in the doAfterBody() method..C. By putting database-specific SQL code into a separate layer as DAO layer.id C.doGet(HttpServletRequest req.) method to pass the request to another servlet to handle. serial number.. jsp:setProperty.doGet(ServletRequest req.D jsp:bean declares the use of a JavaBean instance in a JSP page. You need to call super. jsp:forward. 48.getPage(ServletRequest req.6 (Answers) 1)C To notify the container to reevaluate the custom tag's body. the control is still with the current servlet. say 30 minutes B.What is the method declaration for the method used in the HttpServlet class that handles the HTTP GET request? Please select one correct answer A. HttpServletResponse res) D. 2)B.. 6)A.C.uri B.init(config) if you override this method.. for include(. jsp:plugin 3)B. the control is passing to target servlet.A session can be invalidated by which of the following: Please select three correct answers A.Client side user closes the browser C.E You need to override the service() method when you extends GenericServlet. 5)B A Data Access Object pattern is used to encapsulate database access functions. A.After a default period of inactivity.B 7)C. ServletResponse res) B.E 8)D 9)Client-Cert The correct answer is CLIENT-CERT which stands for client certificate... Standard action types : jsp:include.location 49.D .value F.)..).invalidate(5).setMaxInactiveInterval(300).setMaxInactiveInterval(5). say 10 minutes D.prefix E.After a specified period of inactivity. HttpServletResponse res) OCEJWCD 6 Mock Questions .Which are the two mandatory attributes for JSP taglib directive? Please select two correct answers. 4)C.session.name D. It requires the client to provide a digital certificate containing information about the issuer.session.D You can use either forward(. you must return a value of IterationTag. Custom tags (taglibs) allow user-defined actions to be created. D. ServletResponse res) C. it is easy to modify it without affecting business logic layer. signature. Answer A is incorrect because the action JSP tag provides request-time instructions to the JSP engine.service(HttpServletRequest req. etc 10)B 11)A.C.. thus increase code manageability.session. jsp:getProperty.Explicitly invalidate a session through method calls 50. E. jsp:plugin instructs the JSP engine to generate appropriate HTML code for embedding applets on a web page.) or include(.Client side user machine crashes E. While for forward(.

A.E 31)B 32)A.getWriter().E 50)C OCEJWCD 6 Mock Questions .D.C.D 46)A.res.C..F 33)A 34)B 35)A 36)C 37)A 38)B.C 30)A. .").empty().remove().D.res.println("Unable to find resource. //1 response. when inserted at //1.D 49)A.D 42)D 43)A 44)C 45)C. } Which of the following lines.D 26)C 27)D 28)E 29)A.E 14)C 15)A.B.C. Consider the following code: public void doGet(HttpServletRequest req.D 18)C 19)A.clear().E 40)B 41)A.C 20)B 21)A.7 1. will ensure that an IllegalStateException is NOT thrown? Select 1 correct option.C.C.12)C 13)B.sendError(404).C.C.D 48)A. C.D 47)A. out. HttpServlerResponse res) { PrintWriter out = res.E 39)B.D 22)C 23)A.E 24)C 25)A.D 16)A 17)A. B.B.res.

FORM D.COMMITTED) 2. the output will contain "welcome.com/tags/util" prefix="util" %> E. In the doGet() of SecondServlet: .if(!res.None of these 4.html"%> D.D.GET C.jsp will not compile C.getRequestDispatcher("SecondServlet"). response).jsp will not compile D.HEAD 5.Consider the following code snippets.jsp" /> </body></htm> <%@ page errorPage="simpleerrorhandler. What will be displayed on the browser when a GET request is sent to FirstServlet assuming that the buffer is large enough to hold all the data before sending the data to the client? In the doGet() of FirstServlet: PrintWriter out = response.Both the files will compile but will throw an exception at runtime E. rd.forward(request. A..Which HTTP method is used in FORM based Authentication? Select 1 correct option.<%! taglib uri="http://www. out.*"%> 3. B.Consider the following contents for two JSP files: 1 In file companyhome.When companyhome. RequestDispatcher rd = response.abc.<% include file="/copyright.println("<html><body>Page 1")." as well as "Todays News".com/tags/util" prefix="util" %> C.<%$ page language="java" import="com.jsp" %> In file companynews.jsp is requested.getWriter().<%@ taglib uri="http://www.POST B.<%@ page %> B.jsp: <%@ page errorPage="advancederrorhandler. A.jsp" %> <h3>Todays News</h3> Select 1 correct option.jsp: <html><body> Welcome to ABC Corp! <jsp:include page="companynews.getStatus() != res.if( res.companynews.companyhome. A.isCommitted()) E..abc.abc.Which of the following statements are correct JSP directives? Select 2 correct options.

getField("email") of HttpServletRequest D.Which of the given options are equivalent? Select 2 correct options.getParameters("email") of HttpServlet 10.</jsp:scriptlet> D.Only Page2 C. Any of these operations can throw exceptions but you do not want to catch them all in this page and so you have written another jsp page that is meant to handle any kind of exceptions.jsp"%> in this page. C. D. A.println("<br>Page 2</body></html>"). 9.Add <%@isErrorPage="true"%> in error.<jsp:code>Hashtable ht = new Hashtable().sessionDestroyed() of HttpSessionListener C. which method is invoked on a session attribute implementing an appropriate interface? Select 1 correct option. %> B.Consider the HTML code shown in the exhibit. B.<% Hashtable ht = new Hashtable().getParameter("email") of ServletRequest B. A.Add <%@errorPage="error.Only Page1 B. A.valueUnbound() of HttpSessionAttributeListener D.What will the following JSP page print? <% { %> .valueUnbound() of HttpSessionListener 8.<jsp:scriptlet>Hashtable ht = new Hashtable()</jsp:scriptlet> 7.<jsp:scriptlet>Hashtable ht = new Hashtable().When a session becomes invalid.jsp"%> in this page. It also formats the data and displays it to the client.jsp.Add <%@page errorPage="error. 6.jsp.getParameterValues("email") of ServletRequest C.valueUnbound() of HttpSessionBindingListener E.Your jsp page connects to the database and retrieves the data. How would you associate that error page named "error.PrintWriter out = response. Which of the following method calls can retrieve the "email" value sent from the browser? <html><body> <form action="/myapp/servlet/EmailCatcherServlet"> Please enter your email: <input type="text" name="email"> <input type="submit"> </form> </body></html> Select 2 correct options. A. A.Page1 and Page2 D.getFormValue("email") of HttpServletRequest E.<%= Hashtable ht = new Hashtable() %> C.</jsp:code> E.jsp" with this page? Select 2 correct options. out.Add <%@page isErrorPage="true"%> in error.sessionInvalidated() of HttpSessionListener B.IllegalStateException at Runtime.getWriter(). Select 1 correct option.

It will print "Hello" C.OPTIONS E. .Which HTTP method would you use to test the validity.The Function class must have a function with the signature: public String transformString(String arg).The Function class may have any method of the type: public static XXX(String s). but the method name (ie.StringBuffer" /> sb.jsp page. which is not present in the request. XXX) must be mapped to "transformString" in web..append("Hello"). but the method name (ie. <function> <name>transform</name> <function-class>com.A function has been defined in a tag library descriptor as follows: <taglib> . XXX) must be mapped to "transform" in web.jsp" page.It will not compile because StringBuffer is not a bean E. 1.String transformString(String)</functionsignature> </function> . A.None of these 11. B..It will not compile because <jsp:useBean> cannot be used inside a block D. or modification time of a hyperlink? Select 1 correct option.In your report.<jsp:useBean id="sb" class="java. you want to include the output of "customer. It will print null B.xml.lang. accesibility.xml.The Function class must have a method with the signature: public String transform(String arg). Which of the following code snippents does this.PUT 12.The Function class may have any method of the type: public static XXX(String s).None of these 13. A. E.enthu. <% } %> <%=sb%> Select 1 correct option.. D.HEAD D. C.POST C. But this page requires an additional parameter "custid".Functions</function-class> <function-signature>java.GET B. </taglib> Which of the following statements are correct? Select 1 correct option..lang. A.

15.The String value of the imported content can be made available for use outside of the tag in 'var' variable.jsp" param-name="custid" param-value="1234"/> 4. C. A. <jsp:include page="customer. A.You cannot pass binary data to the server B.jsp" custid="1234"/> 2. <jsp:include page="customer. <jsp:include page="customer.import tag is useful to convert URL when cookies are not supported by the client. A.It important to note that response of a POST request are never cached.You can only reply with the HEADER information in the response. 1. B. E.jsp"> <jsp:param name="custid" value="1234"/> </jsp:include> Select 1 correct option.3 D.jsp"> <jsp:param> <name>custid</name> <value>1234</value> </jsp:param> </jsp:include> 3.You cannot send multiple values for one parameter to the server D.2 C.You cannot send unlimited (or a lot of) data to the server C.If the url contains a relative path. then the resource must exist in the same webapp.The parameters will be appended to the URL as a query string 16. <taglib> <taglib-uri>/binomial</taglib-uri> <taglib-location>/WEB-INF/MathLib.<jsp:include page="customer.Which of the following statements are correct regarding the import tag of JSTL? Select 2 correct options.tld</taglib-location> </taglib> . E.import tag is more efficient than jsp:include action in the case when large amount of data is imported only to be given to another tag.4 14. D.The content imported by the import tag can be made available only through a String object.What are the implications of using the HTTP GET method for a form submission? Select 3 correct options.1 B.

jar</taglib-location> </taglib> 3. <taglib author="ABCINC"> <taglib-uri>/binomial</taglib-uri> <taglib-location>/WEB-INF/MathLib.2 C.tld</taglib-location> </taglib> 4.Consider the jsp code: <html> <head> <% int k = 0.1 B.5 17. <taglib> <taglib-uri>/binomial</taglib-uri> <taglib-location>/WEB-INF/MathLib. <taglib name="ABC_MATH_LIB"> <taglib-uri>/binomial</taglib-uri> <taglib-location>/WEB-INF/MathLib.3 D. <taglib id="ABC_MATH_LIB"> <taglib-uri>/binomial</taglib-uri> <taglib-location>/WEB-INF/MathLib.jar</taglib-location> </taglib> 5. %> </head> <body> </body> .4 E.tld</taglib-location> </taglib> Select 3 correct options.2. A.

This tag generates a random number and sets it to a variable named "value". Select 3 correct options A. Which of the following will output this value in the page? Select 1 correct option A.abc.login(request) %> E. } %> 22.doGet() D.println(i).URL rewriting E.<%@ String uid = LoginHelper. 21.HttpSessionEvent C.login(request).bankapp.Which of the following are valid JSP scriptlets? Select 2 correct options. A.Consider the following web.<generator:random><%getParameter("value")%></generator:random> E.HttpAttributeEvent 19.HttpSessionBindingEvent E.<generator:random><% int value.constructor of the servlet.HttpAttributeChangeEvent D.login(request) %> B._jspService() E.BankServlet</servlet-class> <security-role-ref> <role-name>manager</role-name> <role-link>supervisor</role-link> </security-role-ref> </servlet> . 18. which supports a tag named "random".<%! String uid = LoginHelper.Identify the techniques that can be used to implement 'sessions' if the client browser does not support cookies.None of the above.You are using a tag library with prefix "generator".Hidden form fields D.Using Http headers B.<% for(int i=0.xml code snippet: <servlet> <servlet-name>BankServlet</servlet-name> <servlet-class>com. i< 10.init() C. 20.Which event is received by a registered listener when an attribute is added to HttpSession? Select 1 correct option A. C.<generator:random><%=value%></generator:random> C.<% String uid = LoginHelper.HttpSessionChangeEvent B. i++) { out.login(request) %> D.Using https protocol. %> C.<generator:random>value</generator:random> B.<% String uid = LoginHelper.%> <%=value%></generator:random> D.This will not compile as you cannot put jsp code in the <head> element B.</html> In which method of the generated servlet will the declaration for 'k' be placed? Select 1 correct option A.It cannot be done without cookie support.

Which design pattern would you use? Select 1 correct option.include E.Resource and java.MVC D.Transfer Object 23. Select 3 correct options.name C.Transfer Object D.You are designing a complex webapp that uses multi tier architecture.io.getResource() and ServletContext. A. A. Select 1 correct option. C.The servlet code can use "manager" or "supervisor" as a parameter in request.java.Data Access Object E.rtexprvalue E.Which pattern allows you to replace the presentation logic without much impact on the data representation? Select 1 correct option. A.isUserInRole() method C. 25.InputStream B.tag 24.Which of the following statements are correct? Select 1 correct option.InputStream E.File and java.URL and java.Model View Controller B.isUserInRole() method D.java.Select the correct return types for ServletContext. A.The servlet code should use"supervisor" as a parameter in request.io. A.io.io.The servlet code should use "manager" as a parameter in request.isUserInRole() method B.getResourceAsStream() methods.HTML FORM is used to capture the username and password of the user B. The application must provide interfaces for HTML as well as XML and should be maintainable.Password is transmitted as plain text.import F.page D.io.net.java.Password is transmitted either in encrypted text or in plain text depending on the browser E.Business Delegate C.FileInputStream .attribute B.Resource and java.description D. A.This mechanism can be used over HTTPS.Which of the following are correct about FORM based authentication mechanism? Select 3 correct options.Remote Method Invocation E.Business Deligate C.Data Access Object B.io.variable C.java.net.Identify the elements that help describe the attribute characteristics of a JSP custom tag in a TLD file.java.value B.class 27. A.Password is transmitted in an encrypted form D.InputStream D.None of these 22.Which of the following directives are applicable ONLY for tag files? Select 3 correct options.Bimodal DataAccess 26.io.URL and java.io.BufferedInputStream C.The role of "manager" must be defined in the servlet container E.

Method name is correct but it should also be static. E.D 3)A 4)A 5)B 6)A.setParameter B.getInitParameterValue("dbname").getInitParameter("dbname").C 15)A.C .SECURE D.E 16)A. A.Which of the following are valid values for the <transport-guarantee> element? Select 3 correct options.getServletConfig().getInitParameter("dbname").Which method of ServletResponse would you use to set its content type? Select 1 correct option.B 10)E 11)C 12)E The Function class must have a method with signature: public static String transformString(String arg). A is incorrect. OCEJWCD 6 Mock Questions .getServletContext().C 9)A. B is incorrect.CONFIDENTIAL B.NONE 29.setHeader C.B.getInitParameter("dbname"). D. 13)D 14)A.28.None of the above 30. B.ENCRYPTED E. C. The method name must be the same as given in <function-signature> element.INTEGRAL C. A.C 7)D 8)B.getServletConfig().getParameter("dbname").Which of the following lines can be used to retrieve a servlet initialization parameter "dbname" from the init() method of a servlet? public void init() { String dbname = //1 : Insert line here } Select 2 correct options.B.setContentType E.7 (Answers) 1)D 2)A.setAttribute D. A.

C. A is incorrect. D is incorrect.17)D This is a scriptlet and they always go inside the service method. they are local to the request.F B Valid only for tag files. You can put JSP code anywhere 18) D Following is the mapping of Listeners and their corresponding events.B. .E 29)D 30)B.D An attribute element describes the attribute for a tag. This allows plug and play between back end logic and the front end.D Calling getServletConfig() from the init() method returns the ServletConfig object for this servlet and calling getInitParameter(." means the same data is represented in different ways.HttpSessionAttributeListener and HttpSessionBindingListener.E A is incorrect.) on the ServletConfig object returns the value of that parameter.E C is incorrect This is done in HTTP Digest authentication mechanism 25)A A is correct. type?. 23) A.. For example. C is correct Remember that this is a non-standard and obsolete way. <security-role-ref> is used to map the role names hard coded in the servlet code to the actual role names defined in the servlet container. the presentation of data) knows how to present the data and so can be replaced with another view without any impact on the data representation. A view (ie.xml for Tomcat. 19) B C is incorrect It'll give an exception saying value is not initialized! 20) B.B.D B is correct Unlike HTTP. It does not have an ending semicolon C is incorrect. ie. <!ELEMENT attribute (name. This allows plug and play between the data container (the DB) and data requestor. D is incorret include directive is valid for regular JSP file also E is incorrect No such directive 24)A. @ is used for directives 22)A D is incorrect "supervisor" must be defined in the container. B is incorrect. rtexprvalue?. use HttpSessionBindingEvent. This can only be done in an application specific way and requires that the page has a form.should provide XML and HTML interfaces. required? .. HTTPS uses SSL which is a stateful protocol. ! is used for declarations D is incorrect. 22)C The statement ". description?) > 27)C 28)A.. therefore this is MVC.C. HttpSessionListener : HttpSessionEvent HttpSessionAttributeListener : HttpSessionBindingEvent HttpSessionBindingListener : HttpSessionBindingEvent Observe that both ...B. Following is its definition. 26)B. in conf/tomcat-users. 21)B..