hello quizlet
Home
Subjects
Expert solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
SE_Kỳ 4_PRJ321 (Java Web)
Flashcards
Learn
Test
Match
Flashcards
Learn
Test
Match
Terms in this set (320)
Which of the following statements are correct about the status of the Http response? Select the one correct answer
A. A status of 200 to 299 signifies that the request was successful.
B. A status of 300 to 399 is informational messages.
C. A status of 400 to 499 indicates an error in the server
D. A status of 500 to 599 indicates an error in the client.
A
Classes HttpServlet and GenericServlet implement the ___ interface.
A. Servlet
B. Http
C. HttpServletRequest
D. HttpServletResponse
A
You have to send a gif image to the client as a response to a request. Which of the following calls will you have to make?
A. response.setContentType("image/gif");
B. response.setType("application/gif");
C. response.setContentType("application/bin");
D. response.setType("image/gif");
A
Consider the code of ReportServlet servlet of a web application. Assuming generateReport() is valid method and have no problems, which of the following statement about these servlet is true?
A. ReportServlet will throw exception at runtime.
B. ReportServlet.java won't compile.
C. ReportServlet.java will compile and run without any problems.
C
Which method of ReportGeneratorServlet will be called when the user clicks on the URL shown by the following HTML.
Assume that ReportGeneratorServlet does not override the service(HttpServletRequest, HttpServletResponse) method of the HttpServlet class.
(Choose one)
A. doGet(HttpServletRequest, HttpServletResponse);
B. doPost(HttpServletRequest, HttpServletResponse);
C. doHead(HttpServletRequest, HttpServletResponse);
D. doOption(HttpServletRequest, HttpServletResponse);
A
What will be the outcome of executing the following code?
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
response.setContentLength(6);
PrintWriter out = response.getWriter();
out.write("What's your name? ");
out.write("" + response.isCommitted());
}
A. Won't execute because of a compilation error.
B. An IllegalArgumentException is thrown.
C. An IllegalStateException is thrown.
D. A blank page is returned to the client.
E. "What's" is returned to the client.
F. "What's your name?" is returned to the client.
E
Following is the code for doGet() and doPost() methods of TestServlet.
Which of the statement is correct?
A. This will only work for HTTP GET requests
B. This will only work for HTTP POST requests
C. This will work for HTTP GET as well as POST requests.
D. It'll throw an exception at runtime, as you cannot call doGet() from doPost().
E. It'll throw an exception at runtime only if a POST request is sent to it.
C
Which of the following is indicated by URL, which is used on the Internet?
A. Information resources(sources) on the Internet
B. E-mail addresses for use in the Internet
C. IP addresses of servers connected to the Internet
D. Owners of PCs connected to the Internet
A
Identify correct statement about a WAR file.(Choose one)
A. It is an XML document.
B. It cannot be unpackaged by the container.
C. It is used by web application developer to deliver the web application in a single unit.
D. It contains web components such as servlets as well as EJBs.
D
See the extract from web.xml of web application "mywebapp" on server named myserver, runs on port 8080:
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/bservlet.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletC</servlet-name>
<url-pattern>*.servletC</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletD</servlet-name>
<url-pattern>/dservlet/*</url-pattern>
</servlet-mapping>
Given that a user enters the following into her browser, which (if any) of the mapped servlets will execute? (Choose one.)
http://myserver:8080/mywebapp
A. ServletA
B. ServletB
C. ServletC
D. ServletD
A
A parameter is defined in a <context-param> element of the deployment descriptor for a web application. Which of the following statements is correct?
A. It is accessible to all the servlets of the webapp.
B. It is accessible to all the servlets of all the webapps of the container.
C. It is accessible only to the servlet it is defined for.
A
A .................... manages the threading for the servlets and JSPs and provides the necessary interface with the Web server.
A. Web Container
B. EJB Container
C. Servlets
D. Applets
A
A ________has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.
A. Cookie
B. Session
C. Request
D. Response
A
Which of the following method calls can be used to retrieve an object from the session that was stored using the name "roleName"?
A. getObject("roleName");
B. getValue("roleName");
C. get("roleName");
D. getAttribute("roleName");
E. getParameter("roleName");
D
Which is NOT a standard technique for a session be definitely invalidated?
A. The container is shutdown and brought up again.
B. No request comes from the client for more than "session timeout" period.
C. A servlet explicitly calls invalidate() on a session object.
D. If the session time out is set to 0 using setMaxInactiveInterval() method.
D
Which method can be invoked on a session object so that it is never invalidated by the servlet container automatically?
A. setMaxInactiveInterval(-1)
B. setTimeOut(Integer.MAX_INT)
C. setMaxInactiveInterval(Integer.MAX_INT)
D. setTimeOut(-1)
A
Session death is more likely to come about through a time-out mechanism. If there is no activity on a session for a predefined length of time, the web container invalidates the session.
A. True
B. False
A
What are the different scope values for the ‹jsp:useBean›? (Choose one correct answer)
A. session, page, application, request
B. session, page, application, global
C. session, page, application, context
D. session, page, response, request
A
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/Final/test.jsp?name=John. The test.jsp contains the following code.
<% String myName=request.getParameter("name");%>
<% String test= "Welcome " + myName; %>
<%=test%>
What is the output?
A. The page display "Welcome John"
B. The program gives a syntax error because of the statement
<% String myName=request.getParameter("name");%>
C. The program gives a syntax error because of the statement
<% String test= "Welcome " + myName; %>
D. The program gives a syntax error because of the statement
<%=test%>
A
Name the default value of the scope attribute of <jsp:useBean>
A. page
B. session
C. application
D. request
A
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp?name="John". The test.jsp contains the following code.
<%! String myName=request.getParameter();%>
<% String test= "welcome" + myName; %>
<%= test%>
What is the output?
A. The program prints "Welcome John"
B. The program gives a syntax error because of the statement <%! String myName=request.getParameter();%>
C. The program gives a syntax error because of the statement <% String test= "welcome" + myName; %>
D. The program gives a syntax error because of the statement <%= test%>
B
Select the correct directive statement insert into the first line of following lines of code (1 insert code here):
A. <%@page import='java.util.*' %>
B. <%@import package='java.util.*' %>
C. <%@ package import ='java.util.*' %>
D. <%! page import='java.util.*' %>
A
For JSP scopes of request and page, what type of object is used to store the attributes?
A. HttpServletRequest and ServletContext respectively.
B. ServletRequest and ServletConfig respectively.
C. ServletRequest and PageContext respectively.
D. HttpServletRequest and PageContext respectively.
E. ServletConfig for both.
A
Which of the following correctly represents the following JSP statement? Select one correct answer.
<%=x%>
A. <jsp:expression=x/>
B. <jsp:expression>x</jsp:expression>
C. <jsp:statement>x</jsp:statement>
D. <jsp:declaration>x</jsp:declaration>
E. <jsp:scriptlet>x</jsp:scriptlet>
B
What gets printed when the following JSP code is invoked in a browser? Select one correct answer.
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>
A. The browser will print either hello or hi based upon the return value of random.
B. The string hello will always get printed.
C. The string hi will always get printed.
D. The JSP file will not compile.
D
Which technique is likely to return an initialization parameter for a JSP page?
A. <%= request.getParameter("myParm") %>
B. <% String s = getInitParameter("myParm"); %>
C. <% = application.getInitParameter("myParm") %>
D. <%= getParameter("myParm") %>
E. <% String s = getAttribute("myParm"); %>
B
A JSP ________________ lets you define methods or fields that get inserted into the main body of the servlet class (outside of the _jspService method that is called by service to process the request).
A. declaration
B. scriptlet
C. expression
A
Which jsp tag can be used to set bean property?
A. jsp:useBean
B. jsp:useBean.property
C. jsp:useBean.setProperty
D. jsp:property
E. jsp:setProperty
E
Which statements are BEST describe param attribute of <jsp:setProperty param=.... /> Action?
A. The ID of the JavaBean for which a property (or properties) will be set.
B. The name of the property to set. Specifying "*" for this attribute causes the JSP to match the request parameters to the properties of the bean.
C. If request parameter names do not match bean property names, this attribute can be used to specify which request parameter should be used to obtain the value for a specific bean property.
D. The value to assign to a bean property. The value typically is the result of a JSP expression.
C
Which statements are BEST describe value attribute of <jsp:setProperty value=... /> action?
A. The ID of the JavaBean for which a property (or properties) will be set.
B. The name of the property to set. Specifying "*" for this attribute causes the JSP to match the request parameters to the properties of the bean.
C. If request parameter names do not match bean property names, this attribute can be used to specify which request parameter should be used to obtain the value for a specific bean property.
D. The value to assign to a bean property. The value typically is the result of a JSP expression.
D
Which statements are BEST describe id attribute of <jsp:useBean id=..... /> Action?
A. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is case sensitive.
B. The scope in which the Java object is accessible—page, request, session or application. The default scope is page.
C. The fully qualified class name of the Java object.
D. The name of a bean that can be used with method instantiate of class java.beans.Beans to load a JavaBean into memory.
E. The type of the JavaBean. This can be the same type as the class attribute, a superclass of that type or an interface implemented by that type. The default value is the same as for attribute class. A ClassCastException occurs if the Java object is not of the type specified with attribute type.
A
Which statements are BEST describe errorPage attribute of <%@ page errorPage=....%> directive?
A. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
B. Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original exception that occurred.
C. Specifies the MIME type of the data in the response to the client. The default type is text/html.
D. Specifies the class from which the translated JSP will be inherited. This attribute must be a fully qualified package and class name.
A
Action _______has the ability to match request parameters to properties of the same name in a bean by specifying "*" for attribute property.
A. <jsp:setProperty>
B. <jsp:getProperty>
C. <jsp:useBean>
D. <jsp:include>
A
Which of the following are potentially legal lines of JSP source?
A. <jsp:useBean id="beanName1" class="a.b.MyBean" type="a.b.MyInterface" />
B. <% String className = "a.b.MyBean"; %>
<jsp:useBean id="beanName2" class="<%=className%>" />
C. <% String beanName = "beanName3"; %>
<jsp:useBean id="<%=beanName3%>" class="a.b.MyBean" />
D. <% String propName = "soleProp"; %>
<jsp:getProperty name="beanName1" property="<%=propName%>" />
/>
B
What sub element of <attribute> tag defines the name of the attribute that might be passed to the tag handler? (Choose one)
A. <attribute-name>
B. <name>
C. <attributename>
D. <param-name>
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?
A. blank
B. empty
C. null
D. false
B
Identify the correct element is required for a valid <taglib> tag in web.xml (Choose one)
A. <uri>
B. <tag-uri>
C. <uri-name>
D. <uri-location>
E. <taglib-uri>
E
Given the following JSP and tag handler code, what is the result of accessing the JSP?
JSP Page Source
<html>
<body>
<%@taglib uri="test_taglib" prefix="myTag"%>
<% session.setAttribute("first", "first"); %>
<myTag:TestTag/>
<br>
<%=session.getAttribute("second")%>
</body>
</html>
Tag Handler Code for <myTag:TestTag />
package examples;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class TestTag extends TagSupport
{
private PageContext pageContext;
public void setPageContext(PageContext page){
this.pageContext=page;
}
public int doStartTag() throws JspException {
try{
String first=pageContext.getSession().getAttribute("first").toString();
pageContext.getOut().write(first);
pageContext.setAttribute("second", "second",PageContext.PAGE_SCOPE);
}
catch(IOException i)
{
throw new JspException(i.getMessage());
}
return SKIP_BODY;
}
public int doEndTag() throws JspException{
return EVAL_PAGE;
}
public void release(){}
}
Assume *.tld and web.xml files are correct.
A. first
null
B. second
null
C. first
second
D. second
first
C
Which of these is legal return types of the doAfterBody method defined in a class that extends TagSupport class?.
A. EVAL_PAGE
B. EVAL_BODY
C. EVAL_PAGE_AGAIN
D. SKIP_BODY
E. SKIP_PAGE
D
Which of the following elements defines the properties of an attribute that a tag needs?
A. attribute
B. tag-attribute
C. tag-attribute-type
D. attribute-type
A
Which element defined within the taglib element of taglib descriptor file is required? Select one correct answer.
A. Tag
B. Description
C. Validator
D. Name
A
Which of the following is a properly formatted taglib element occurring in web.xml?
A. <taglib>
<uri>/graph</uri>
<location>/WEB-INF/Charts.tld</location>
</taglib>
B. <taglib>
<lib-uri>/graph</lib-uri>
<lib-location>/WEB-INF/Charts.tld</lib-location>
</taglib>
C. <taglib>
<taglib-name>/graph</taglib-name>
<taglib-location>/WEB-INF/Charts.tld</taglib-location>
</taglib>
D. <taglib>
<taglib-uri>/graph</taglib-uri>
<taglib-location>/WEB-INF/Charts.tld</taglib-location>
</taglib>
D
Study the statements:
1) URL rewriting may be used when a browser is disabled cookies.
2) In URL encoding the session id is included as part of the URL
Which is the correct option ?
A. Only statement 1 is true
B. Only statement 2 is true
C. Both 1 and 2 are true
D. Both 1 and 2 are not true
c
A JSP page will not have access to session implicit variable if.
A. the user has closed all his/her browser windows.
B. the request is the first request from the user.
C. the user's browser does not support URL rewriting.
D. the session attribute of page directive is set to false.
d
Which statements are BEST describe type attribute of <jsp:useBean type=_.. /> action?
A. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is call..
B. The name of a bean that can be used with method instantiate of class java.beans.Beans to load a JavaBean into memory.
C. The fully qualified class name of the Java object
D. The type ofthe JavaBean. This can be the same type as the class attribute, a superclass ofthattype or an interface implemented bythattype. The default value is the same as for attribute class. ACIassCai
E. The scope in which the Java object is accessible-page. request session or application. The default scope is page.
d
(Choose 1 answer)
HttpServletRequest.getSession() method returns a_____object.
A. HttpServletSession.
B. HttpResponseSession.
C. HttpRequestSession.
D. HttpSession.
d
(Choose 1 answer)
You need to make sure that the response stream of your web application is secure. Which factor will you look at? (Choose one)
A. data integrity
B. authentication
C. authorization
a
Class HttpServlet defines the methods _____ and _______ to response to get and post request from a client.
A. DoGet, DoPost
B. doGet, doPost
C. doGET, doPOST
D. Get, Post
b
(Choose 1 answer)
Which of the elements defined within the taglib element of taglib descriptor file are required? Select one correct answer.
A. taguri
B. info
C. taglib-location
D. display-name
c
(Choose 1 answer)
Which of the following method calls can be used to retrieve an object from the session that was stored using the name "userid"?
A. getValue("userid");
B. get("userid");
C. getAttribute("userid");
D. getParameter("userid");
E. getObject("userid");
c
(Choose 1 answer)
Consider the following doGet method code of a servlet
public void doGet(HttpServletRequest req. HttpServletResponse res)
{
String command = req.getParameter("command"); if("remove".equals(command))
{
HttpSession session = req.getSession();
//insert code here
}
}
If the command equals remove, you want to unbind an attribute named "user" from the session. Which of the following option will you use? (Choose one)
A. session.deleteAttribute("user");
B. session.unbindfuser");
C. session.removeAttribute("user");
D. session.remove("user");
c
(Choose 1 answer)
Which Java technology provides a standard API for publish-subscribe messaging model?
A. JNDI
B. UDDI
C. JMS
D. JSP
c
(Choose 1 answer)
Which of the following statements are correct about HTTP Basic authentication mechanism?
A. HTML FORM is used to capture username and password.
B. Password is transmitted in an encrypted form.
C. Password is transmitted as text
D. Password is transmitted either in encrypted text or in plain text depending on the browser.
c
(Choose 1 answer)
Which is NOT true about stateless session beans?
A. They are used to represent data stored in a RDBMS
B. They are used to implement business logic
C. They are an Enterprises Beans
D. They are CANNOT hold client state
a
(Choose 1 answer)
JSP_let you insert arbitrary code into the servlet's JspService method (which is called by service).
A. scriptlets
B. expressions
C. declarations
a
(Choose 1 answer)
Which component can use a container-managed entity manager with an extended persistent context?
A. Session beans and web components
B. Only stateless session beans
C. Only stateful session beans
D. Any EJB component
c
(Choose 1 answer)
Which statements are BEST describe <jsp:include> Action?
A. Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed.
B. Specifies the relative URI path of the resource to include. The resource must be part of the same Web application.
C. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean.
D. Forwards request processing to another JSP. servlet or static page. This action terminates the current JSP's execution.
a
(Choose 2 answer)
Which of these is legal return types of the doEndTag method defined in a class that extends TagSupport class?
A. EVAL_PAGE
B. EVAL_B0DY
C. EVAL_PAGE_INCLUDE
D. EVAL_BODY_INCLUDE
E. SKIP_B0DY
ae
(Choose 1 answer)
A developer must implement a 'shopping cart" object for a web-based application. The shopping cart must be able to maintain the state of the cart but the state is not stored persistently. Which JEE (J2EE) tech
A. JMS
B. Stateless session beans
C. Stateful session beans
D. Entity beans
c
(Choose 1 answer)
Which is the correct sequence?
A. jsp page is complied-->Jsp page is translated ~>jsplnit is called ->JspService is called ->jspDestroy is called
B. Jsp page is translated -->jsp page is complied-->jsplnit is called ->JspService is called -->jspDestroy is called
C. Jsp page is translated -->jsp page is complied-->jspService is called ->jsplnit is called ->JspDestroy is called
D. jsp page is complied-->Jsp page is translated --> JspService is called -->jsplnit is called -->jspDestroy is called
b
(Choose 1 answer)
Which statement is true about the EJB 3.0 stateful session beans?
A. Its conversational state is lost after passivation unless the bean class saves it to a database
B. Its conversational state is retained across method invocations but NOT across transaction boundaries
C. Its conversational state is retained across method invocations and transactions
c
(Choose 1 answer)
Consider the following tag declaration in a TLD file:
<tag>
<name>simpleInterest</name>
<tag-class>SimpleInterestTag</tag-class>
//1
</tag>
SimpleInteresTag calculates simple interest for any amount and requires two attributes 'amount' and 'rate'.
Which of the following sub elements would you need to add inside the <tag> element in the TLD in place of//1 as shown above? Two separate <attribute> elements.
A. One <attribute> elementwith sub-elements
B. One <attribute-list> elementwith sub-elements
C. One <amount> element and one <rate> element
a
(Choose 1 answer)
Which statement about an entity instance lifecycle is correct?
A. A removed entity instance is NOT associated with a persistence context
B. A new entity instance is an instance with a fully populated state.
C. A managed entity instance is the instance associated with a persistence context
D. A detached entity instance is an instance with no persistent identity.
c
(Choose 1 answer)
Which of the following are potentially legal lines of JSP source?
A. <jsp:useBean id="beanName1" class="a.b.MyBean" type="a.b.MyInterface" />
B. <% String propName = "soleProp": %>
<jsp:getProperty name="beanName1" property="<%=propName%>" />
/>
C. <% String beanName = "beanName3"; %>
<jsp:useBean id="<%=beanName3%>" class="a.b.MyBean" />
D. <% String className = "a.b.MyBean"; %>
<jsp:useBean id="beanName2" class="<%=className%>" />
d
(Choose 1 answer)
You want to use a bean that is stored in com/enthu/GUI.ser file. Which of following statements correctly defines the tag that accesses the bean?
A. <jsp:useBean id="pref'type="com/enthu/GUI.ser"/>
B. <jsp:useBean id="pref' name="com/enthu/GUI.ser"/>
C. <jsp:useBean id="pref' class="com.enthu.GUI.ser"/>
D. <jsp:useBean id="pref' name="com.enthu.GUr"/>
E. <jsp:useBean id="pref' beanName="com.enthu.GUI" type="com.enthu.GUI"/>
e
(Choose 1 answer)
Which is NOT Enterprise Beans?
A. Message-Driven Beans
B. Business Beans
C. Entity Beans
D. Session Beans
b
(Choose 1 answer)
A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify that the JSP page is generating an XML file?
A. <%@page contentType ='text/xml'>
B. <%@page contentType ='xml'>
C. <%@page contentType ='text/html*>
D. <%@page contentType ='html/xml*>
a
(Choose 1 answer)
Review the following scenario: then identify which security mechanisms would be important to fulfill the requirement (Choose one.)
An online magazine company wishes to protect part of its website content to make that part available only to users who pay a monthly subscription. The company wants to keep client network, and server processing overheads down: Theft of content is unlikely to be an issue, as is abuse of user IDs and passwords through network snooping.
A. Client certification
B. Confidentiality
C. Authorization and Authentication
D. Indication
E. Data integrity
c
(Choose 1 answer)
Which Java technology provides a unified interface to multiple naming and directory services?
A. JNI
B. JDBC
C. EJB
D. JavaMail
E. JNDI
e
(Choose 1 answer)
What sub element of <attribute> tag defines the name of the attribute that might be passed to the tag handler? (Choose one)
A. <attribute-name>
B. <attributename>
C. <name>
D. <param-name>
c
(Choose 1 answer)
Which statement is NOT true about JMS?
A. JSM support an event oriented approach to message reception.
B. JMS support both synchronous and asynchronous message passing
C. JMS does NOT depend on MOM (Messaging-Oriented Middleware) products
D. JMS provides common way for Java programs to access an enterprise messaging system's message
c
(Choose 1 answer)
Your servlet may receive a request, which the servlet cannot handle. In such cases, you want to redirect the request to another resource which may or may not be a part of the same web application. Which of the following options can be used to achieve this objective?
A. RequestDispatcher rd = request.getRequestDispatcher("some url");
rd.forward(request, response);
B. response.sendRedirect("some url");
C. request.sendRedirect("some url");
D. RequestDispatcher rd = this.getServletContext().getRequestDispatcher("some url");
rd.forward(request, response);
b
(Choose 1 answer)
Which of the following elements are used for error handling and are child elements of<web-app> of a deployment descriptor?
A. <error_page>
B. <error-page>
C. <error-location>
D. <error>
b
(Choose 1 answer)
A JSP file uses a tag as <myTaglib:myTag>. The myTag element here should be defined in the which element of the taglib element in the tag library descriptor file ?
A. tagname
B. name
C. tag
D. prefix
b
Consider the Servlet definition in a web.xml file below.
(see picture)
What will the following line of code return if present in the init() method of TestServlet?
getlnitParameter(1);
A. It will return "US".
B. Compilation error.
C. It will return null.
D. It will return "eastern".
E. Runtime error.
b
(Choose 1 answer)
Which of the following statement is true for <jsp:useBean> ?
A. The class attribute must be defined for <jsp:useBean>.
B. The id attribute must be defined for <jsp:useBean>.
C. The scope attribute must be defined for <jsp:useBean>.
b
(Choose 1 answer)
Which statement is correct about the Java Persistence API support for the SQL queries?
A. SQL queries are expected to be portable across database
B. SQL queries are NOT allowed to use parameters.
C. The result of a SQL query is not limited to entities
D. Only SELECT SQL queries are required to be supported
c
(Choose 1 answer)
Which of the following is NOT a standard technique for providing a sense of "state" to HTTP?
A. SSL Sessions
B. HTTP is already a stateful protocol.
C. Cookies
D. URL rewriting
b
(Choose 1 answer)
A(n)_enables a web application to obtain a Connection to a database.
A. DataSource
B. Netbean
C. Eclipse
D. Web server
a
(Choose 1 answer)
Which is a valid PostConstruct method in a message-driven bean class?
A. @PostConstruct
public boolean init() {return true;}
B. @PostConstruct
private void init() {};
C. @PostConstruct
private static void init() {}
D. @PostConstruct
public static void init() {}
b
(Choose 1 answer)
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select one correct answer.
A. SC_N0T_F0UND
B. SC_MOVED_TEMPORARILY
C. SCJNTERNAL_SERVER_ERROR
D. ESC_BAD_REQUEST
E. SC_0K
b
(Choose 1 answer)
Which is NOT provided by the EJB tier in a multitier JEE (J2EE) application?
A. XML Parsing
B. Concurrency control
C. Transaction management
D. Security
a
(Choose 1 answer)
Which type of JEE (or J2EE) component is used to store business data persistently?
A. Stateful session beans
B. Java Server Pages
C. Stateles session beans
D. Java Beans
E. Entity Bean
e
(Choose 1 answer)
What is the purpose of JNDI?
A. To access various derictory services using a single interface
B. To register Java Web Start applications with a web server
C. To parse XML documents
D. To access native code from Java application
a
Which of the following is true about Data Integrity?
A. The information/data is not tampered with, in transit from host to client.
B. The information/data is not read by parties other than it's intended recipients.
C. The information/data is never modified.
D. The information/data is accessible only to users who are authenticated.
a
(Choose 1 answer)
Which of the following statement is correct? (choose one)
A. Authentication means determining whether one has access to a particular resource or not.
B. Confidentiality and Authorization are one and the same thing.
C. Authorization means determining whether one has access to a particular resource or not
C
(Choose 1 answer)
Which is true about JDBC?
A. The JDBC API is an extension of the ODBC API
B. All JDBC drivers are pure Java.
C. JDBC is used to connect to MOM (Message-Oriented Middleware Product)
D. The JDBC API is included in J2SE
d
(Choose 1 answer)
In which of the following cases will the method doEndTagO of a tag handler be invoked?
A. It will be invoked in all case even if doStartTagO or doAfterBodyO throw an exception.
B. This method is invoked if doStartTagO method returns true.
C. It will be invoked only if doStartTagO and doAfterBodyO complete successfully.
D. It will be invoked only if doStartTagO or doAfterBodyO return Tag.DO_END_TAG.
A
(Choose 1 answer)
Data Integrity is the biggest issue for your web application. What will you do? (Choose one)
A. Use HTTPS instead of HTTP.
B. Use LDAP to store user credentials.
C. Use HTTP digest authentication.
D. Use form-based authentication.
d
(Choose 1 answer)
Which jsp tag is needed to ensure that implicit variable 'exception' is available in the page that is meant to be an error page? (Choose one)
A. <%@isErrorPage="true"%>
B. <%@ page errorPage="this"%>
C. <%@ page isErrorPage="true"%>
D. <%@errorPage="true"%>
c
(Choose 1 answer)
Where the bean is declared using the following useBean tag accessible? <jsp:useBean id="jbean" class="com.jclass.JBean" />
A. within other servlets and JSP pages of the same web applications.
B. throughout all future invocations of the JSP as long as the servlet engine is running.
C. Throughout the remainder of the page.
D. throughout all future invocations of the JSP as long as the session is not expired
c
(Choose 1 answer)
Which of the following statement correctly set a cookie from a servlet code? (Choose one)
Assume that response and request refer to HttpServletResponse and HttpServletRequest respectively.
A. requestsetCookie("mycookie". "value");
B. response.addCookiefmycookie". "value");
C. response.setCookie("mycookie". "value");
D. response.addCookie(newCookie("mycookie". "value"));
d
(Choose 1 answer)
Which statements are BEST describe contentType attribute of<%@ page contentType=_.%> directive?
A. Specifies the MIME type of the data in the response to the client The default type is text/html.
B. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
C. Specifies the class from which the translated JSP will be inherited. This attribute must be a fully qualified package and class name.
D. Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original excep
a
(Choose 1 answer)
The following line of code exists in the doGet method of Servlet String sid = request.getParameter("jsessionid");
Which of the option is NOT a standard technique for retrieving the HttpSession associated with the request? (Assume that the session has already been created.)
A. HttpSession session = requestgetSession(sid):
B. HttpSession session = requestgetSession():
C. HttpSession session = requestgetSession(false):
D. HttpSession session = request.getSession(true);
a
(Choose 1 answer)
Which is NOT the main type of JSP constructs that you embed in a page?
A. directives
B. scripting elements
C. HTML code
D. actions
C
(Choose 1 answer)
A web application named webmail has a file named folderview.jsp which the user should be able access directly. Which ofthe following directory may contain this file? (Choose one)
A. /webmail/jsp
B. /webmail/web-inf/jsp
C. /webmail/WEB-INF/lib/jsp
D. /webmail/WEB-INF/jsp
a
(Choose 1 answer)
Servlet Container calls the init method on a servlet instance_
A. For each request to the servlet
B. For each request to the servlet that causes a new thread to be created.
C. Only once in the life time of the servlet instance.
D. If the request is from the user whose session has expired.
c
Choose 1 answer)
Which of the following XML fragments correctly defines a role named "manager" in webxml?
A. <security-role>manager</security-role>
B. <security-role rolename=manager></security-role>
C. <security>
<role-name>manager</role-name>
</security>
D. <security-role>
<role-name>manager</role-name>
</security-role>
d
(Choose 1 answer)
Which of the following lines of code are correct?
A. @EntityBean
public class Employees{
...
}
B. class Employees{
@Entity
private class Address{
...
}
...
}
C. @Entity
public class Employees{
}
c
The requirementfor an online shopping application are:
It must support millions of customers. The invocations must be transactional. The shopping cart must be persistent Which technology is required to support these requirements?
A. JMX
B. JNI
C. JMS
D. EJB
d
(Choose 1 answer)
Which method would you use to put the session id into the URL to support sessions using URL rewriting?
A. encodeURL() of HttpServlet
B. rewriteURL() of HttpServletResponse
C. encodeURL() of HttpServletResponse
D. encodeURL() of HttpServletRequest
c
(Choose 1 answer)
Which syntax is correct for JSP Declarations?
A. <%=code%>
B. <%! code %>
C. <%code%>
b
(Choose 1 answer)
Which of the following is NOT a valid attribute for a useBean tag?
A. className
B. beanName
C. scope
a
(Choose 1 answer)
What is the implementation specification of E JB 3 session bean classes?
A. a session bean class must be final or abstract
B. a session bean class must be marked with @Stateless or @Stateful
C. a session bean class can't extend other classes
b
(Choose 1 answer)
Given a stateless session bean with container-managed transaction demarcation, from which method can a developer access another enterprise bean?
A. bean constructor
B. PreDestroy lifecycle callback method
C. business method from the business interface
c
(Choose 1 answer)
Which statements are BEST describe name attribute of <jsp:setProperty name=_. /> action?
A. If request parameter names do not match bean property names, this attribute can be used to specify which request parameter should be used to obtain the value for a specific bean property.
B. The value to assign to a bean property. The value typically is the result of a JSP expression.
C. The ID of the JavaBean for which a property (or properties) will be set.
D. The name of the property to set. Specifying for this attribute causes the JSP to match the request parameters to the properties of the bean.
c
(Choose 1 answer)
Which is NOT responsibility of the business tier in a multitier web-based application with web. business, and EIS tiers?
A. To participate in transactions
B. To integrate with the legacy applications
C. To provided business logic
D. To generate dynamic content
d
(Choose 1 answer)
Name the implicit variable is available to JSP pages that may be used to access all the other implicit objects.
A. request
B. response
C. pageContext
D. out
E. page
c
(Choose 1 answer)
Which statements are BEST describe scope attribute of <jsp:useBean scope=_.. /> Action?
A. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is ca
B. The scope in which the Java object is accessible-page. request session or application. The default scope is page.
C. The name of a bean that can be used with method instantiate of class java.beans.Beans to load a JavaBean into memory.
D. The type of the JavaBean. This can be the same type as the class attribute, a superclass of that type or an interface implemented by that type. The default value is the same as for attribute class. ACIassCai
E. The fully qualified class name of the Java object
b
(Choose 1 answer)
Which statement(s) about Servlet Life Cycle is(are) correct? (Choose one)
A. When the servlet is first created, its init method is invoked, so that is where you put one-time setup code.
B. All the others
C. Servlet can implement a special interface that stipulates that only a single thread is permitted to run at any one time.
D. When the server decides to unload a servlet it first calls the servlet's destroy method.
E. Each user request results in a thread that calls the service method of the previously created instance.
F. Multiple concurrent requests normally result in multiple threads calling service simultaneously.
b
(Choose 1 answer)
Which is true about RMI?
A. RMI is used to create thin web client
B. RMI is the Java API used for executing queries on a database
C. RMI allows objects to be send from one computer to another
D. RMI is the transport protocol used by web servers and browsers
c
(Choose 1 answer)
Which statement is true about management of an E JB's resources?
A. The reference to home object is obtained through JNDI to improve maintainability and flexibility.
B. The reference to the remote object is obtained through JNDI to improve maintainability and flexibility.
a
(Choose 1 answer)
A web application is located in "helloapp" directory. Which directory should it's deployment descriptor be in?
A. helloapp
B. helloapp/WEB-INF
C. helloapp/WEBJNF
D. helloapp/WEBINF
b
(Choose 1 answer)
A developer is working on a project that includes both EJB 2.1 and EJB 3.0session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB 3.0 session beans need to access this business logic.
Which design approach can achieve this requirement?
A. Add adapted home interfaces to EJB 3.0 session beans to make EJB 3.0 and EJB 2.1 session beans interoperable.
B. Add EJB 3.0 business interfaces to existing EJB 2.1 session beans and inject references to these business interfaces into EJB 3.0 session beans.
C. No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.
c
(Choose 1 answer)
Which statement is true about EJB 3.0 containers?
A. The Java 2D API is guaranteed to be available for session beans
B. Java Telephony API is guaranteed to be available for session and message beans
C. javax.naming.initialContextis guaranteed to provide a JNDI name space
c
(Choose 1 answer)
The Java Persistent API defines the Query interface. Which statement is true about the Query.executeUpdate method ?
A. It must always be executed within a transaction
B. All managed entity objects corresponding to database rows affected by the update will have their state changed to correspond with the update
C. It throws a PersistenceException if no entities were updated.
a
(Choose 1 answer)
If you want to send an entity object as the pass by value through a remote interface, which of the following statements are valid? (Choose one)
A. public class Employees implements Serializable{
...
}
B. @Entity
public class Employees implements Serializable{
...
}
C. @entity
public class Employees implements Serializable{
...
}
D. @Entity
public class Employees implements SessionSynchronization{
...
}
b
(Choose 1 answer)
Which of the following lines of code, in the doPost() method of a servlet, uses the RL rewriting approach to maintaining sessions? (Choose one)
A. request.useURLRewriting();
B. out.println(response.rewrite("<a href='/servlet/XServlet'>Click here</a>"));
C. out.println("<a href='"+response.encodeURL("/servlet/XServlet")+"'>Click here</a>"));
D. out.println(""<a href='"+request.rewrite("/servlet/XServlet")+"'>Click here</a>"));
c
(Choose 1 answer)
Which syntax is correct for JSP Scriptlets?
A. <% code%>
B. <%= code%>
C. <%! code %>
a
(Choose 1 answer)
Which is correct JDBC-ODBC driver name?
a) jdbc.odbc.sun.JdbcOdbcDriver
b) sun.driver.jdbc.odbc
c) jdbc.odbc.sun.driver
d) sun.jdbc.odbc.JdbcOdbcDriver
d
Select at ( least one ) answer
Choose three correct statements in JDBC
a) getObject
b) getLine
c) getText
d) getInt
e) getString
ade
Which is correct sequence for a JDBC execution?
(Choose 1 answer)
a) Connection -> Load Driver -> Statement -> ResultSet
b) Load Driver -> Statement -> ResultSet -> Connection
c) Load Driver -> Connection -> Statement -> ResultSet
d) Statement -> Connection -> ResultSet -> Load Driver
c
Which are the correct statements of Connection object? (Choose two)
a) createStatement(int, int);
b) createStatement(int, String);
c) createStatement(String, int);
d) createStatement();
ad
Which are the correct statements of ResultSet object? (Choose three)
a) executeQueries()
b) executeBatch()
c) execute()
d) executeUpdate()
ac
To send text outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer.
a) getOutputStream
b) getBinaryStream
c) getWriter
d) getStream
c
Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer
a) \doc-root\dd.xml
b) \doc-root\WEB-INF\dd.xml
c) \doc-root\WEB-INF\web.xml
d) \doc-root\web.xml
e) \doc-root\WEB_INF\dd.xml
c
Which of these is true about deployment descriptors.
Select the one correct answer
a) The servlet-mapping element, if defined, must be included within the servlet element.
b) The web-app element must include the servlet element
c) The order of elements in deployment descriptor is important. The elements must follow a specific order
d) The elements of deployment descriptor are case insensitive
c
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Do not include the element in enclosing parenthesis
a) error
b) exception
c) exception-page
d) error-page
d
______ is a set of java API for executing SQL statements.
a) JDBC
b) JAVADB
c) ODBC
d) None of the other choices
a
JDBC supports ______ and ______ models.
choose one answer
a) Three-tier and four-tier
b) Two-tier and three-tier
c) None of the other choices
d) Single-tier and two-tier
b
URL referring to databases use the form:
(Choose one answer)
a) protocol:subprotocol:datasoursename
b) jdbc:odbc:datasoursename
c) protocol:datasoursename
d) jdbc:datasoursename
b
Study the statements:
1)When a JDBC connection is created, it is in auto-commit mode
2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly
(Choose one answer)
a) Only statement 2 is true
b) Both 1 and 2 are not true
c) Both 1 and 2 are true
d) Only statement 1 is true
c
The ______ class is the primary class that has the driver information.
Select the one correct answer.
a) None of the other choices
b) Driver
c) DriverManager
d) ODBCDriver
c
1. The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the one correct answer.
A. HttpServletRequest
B. HttpServletResponse
C. ServletConfig
D. ServletContext
b
2. Name the method defined in the HttpServletResponse class that may be used to set the content type. Select the one correct answer.
A. setType
B. setContent
C. setContentType
D. setResponseContentType
c
3. Which of the following statement is correct. Select the one correct answer.
A. The response from the dedicated server to a HEAD request consists of status line, content type and the document.
B. The response from the server to a GET request does not contain a document.
C. The setStatus method defined in the HttpServletRequest class takes an int as an argument and sets the status of Http response
D. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method.
d
4. The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter. Select the one correct answer.
A. SC_OK
B. SC_MOVED_TEMPORARILY
C. SC_NOT_FOUND
D. SC_INTERNAL_SERVER_ERROR
E. ESC_BAD_REQUEST
c
To send binary output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer.
A. getStream
B. getOutputStream
C. getBinaryStream
D. getWriter
b
To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer.
A. getStream
B. getOutputStream
C. getBinaryStream
D. getWriter
d
Is the following statement true or false. URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL.
a. True
b. False
a
Which of the following are correct statements? Select the two correct answers.
A. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext.
B. The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server.
C. The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method
D. The getNamedDispatcher(String) defined in HttpServletRequest class takes the name of the servlet and returns an object of RequestDispatcher class.
ac
A user types the URL http://www.javaprepare.com/scwd/index.html . Which HTTP request gets generated. Select the one correct answer.
A. GET method
B. POST method
C. HEAD method
D. PUT method
a
When using HTML forms which of the folowing is true for POST method? Select the one correct answer.
A. POST allows users to bookmark URLs with parameters.
B. The POST method should not be used when large amount of data needs to be transferred.
C. POST allows secure data transmission over the http method.
D. POST method sends data in the body of the request.
d
. Which HTTP method gets invoked when a user clicks on a link? Select the one correct answer.
A. GET method
B. POST method
C. HEAD method
D. PUT method
a
Which of the following is not a valid HTTP/1.1 method. Select the one correct answer.
A. CONNECT method
B. COMPARE method
C. OPTIONS method
D. TRACE method
b
Name the http method used to send resources to the server. Select the one correct answer.
A. FTP methodd
B. PUT method
C. WRITE method
D. COPY method
b
. Name the http method that sends the same response as the request. Select the one correct answer.
A. DEBUG method
B. TRACE method
C. OPTIONS method
D. HEAD method
B
Which three digit error codes represent an error in request from client? Select the one correct answer.
A. Codes starting from 200
B. Codes starting from 300
C. Codes starting from 400
D. Codes starting from 500
c
Name the location of compiled class files within a war file? Select the one correct answer.
A. /META-INF/classes
B. /classes
C. /WEB-INF/classes
D. /root/classes
c
Which of the following is legal JSP syntax to print the value of i. Select the one correct answer
A. <%int i = 1;%>
<%= i; %>
B. <%int i = 1;
i; %>
C. <%int i = 1%>
<%= i %>
D. <%int i = 1;%>
<%= i %>
E. <%int i = 1%>
<%= i; %>
d
Which of the following correctly represents the following JSP statement. Select the one correct answer.
<%x=1;%>
A. <jsp:expression x=1;/>
B. <jsp:expression>x=1;</jsp:expression>
C. <jsp:statement>x=1;</jsp:statement>
D. <jsp:declaration>x=1;</jsp:declaration>
E. <jsp:scriptlet>x=1;</jsp:scriptlet>
e
Which of the following are correct. Select the one correct answer.
A. JSP scriptlets and declarations result in code that is inserted inside the _jspService method.
B. The JSP statement <%! int x; %> is equivalent to the statement <jsp:scriptlet>int x;</jsp:scriptlet%>.
C. The following are some of the predefined variables that maybe used in JSP expression - httpSession, context.
D. To use the character %> inside a scriptlet, you may use %\> instead.
d
What gets printed when the following is compiled. Select the one correct answer.
<% int y = 0; %>
<% int z = 0; %>
<% for(int x=0;x<3;x++) { %>
<% z++;++y;%>
<% }%>
<% if(z<y) {%>
<%= z%>
<% } else {%>
<%= z - 1%>
<% }%>
A. 0
B. 1
C. 2
D. 3
E. The program generates compilation error.
c
Which of the following JSP variables are not available within a JSP expression. Select the one correct answer.
A. out
B. session
C. request
D. response
E. httpsession
F. page
e
A bean with a property color is loaded using the following statement
<jsp:usebean id="fruit" class="Fruit"/>
Which of the following statements may be used to print the value of color property of the bean. Select the one correct answer.
A. <jsp:getColor bean="fruit"/>
B. <jsp:getProperty id="fruit" property="color"/>
C. <jsp:getProperty bean="fruit" property="color"/>
D. <jsp:getProperty name="fruit" property="color"/>
E. <jsp:getProperty class="Fruit" property="color"/>
d
A bean with a property color is loaded using the following statement
<jsp:usebean id="fruit" class="Fruit"/>
What happens when the following statement is executed. Select the one correct answer.
<jsp:setProperty name="fruit" property="*"/>
A. This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value or param must be defined.
B. All the properties of the fruit bean are initialized to a value of null.
C. All the properties of the fruit bean are assigned the values of input parameters of the JSP page that have the same name.
D. All the properties of the fruit bean are initialized to a value of *.
c
Which of the following represents a correct syntax for usebean. Select the two correct answers.
A. <jsp:usebean id="fruit scope ="page"/>
B. <jsp:usebean id="fruit type ="String"/>
C. <jsp:usebean id="fruit type ="String" beanName="Fruit"/>
D. <jsp:usebean id="fruit class="Fruit" beanName="Fruit"/>
bc
Which of the following statements are true for <jsp:usebean>. Select the two correct answers.
A. The id attribute must be defined for <jsp:usebean>.
B. The scope attribute must be defined for <jsp:usebean>.
C. The class attribute must be defined for <jsp:usebean>.
D. The <jsp:usebean> must include either type or class attribute or both.
ad
Which of these are legal attributes of page directive. Select the two correct answers.
A. include
B. scope
C. errorPage
D. session
E. debug
cd
Which of the following represents the XML equivalent of this statement <%@ include file="a.jsp"%> . Select the one correct statement
A. <jsp:include file="a.jsp"/>
B. <jsp:include page="a.jsp"/>
C. <jsp:directive.include file="a.jsp"/>
D. There is no XML equivalent of include directive.
c
Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.
<% int sum = 0;
for(j = 0; j < 10; j++) { %>
// XXX --- Add j to sum
<% } %>
// YYY --- Display ths sum
Which statement when placed at the location XXX can be used to compute the sum. Select the one correct statement
A. <% sum = sum + j %>
B. <% sum = sum + j; %>
C. <%= sum = sum + j %>
D. <%= sum = sum + j; %>
b
Now consider the same JSP example as last question. What must be added at the location YYY to print the sum of ten numbers. Select the one correct statement
A. <% sum %>
B. <% sum; %>
C. <%= sum %>
D. <%= sum; %>
c
JSP pages have access to implicit objects that are exposed automatically. One such object that is available is request. The request object is an instance of which class?
A. HttpRequest
B. ServletRequest
C. Request
D. HttpServletRequest
d
JSP pages have access to implicit objects that are exposed automatically. Name the implicit object that is of type HttpSession.
A. session
B. application
C. httpSession
D. httpsession
a
A Java bean with a property color is loaded using the following statement
<jsp:usebean id="fruit" class="Fruit"/>
What is the effect of the following statement.
<jsp:setproperty name="fruit" property="color"/>
Select the one correct answer.
A. An error gets generated because the value attribute of setAttribute is not defined.
B. The color attribute is assigned a value null.
C. The color attribute is assigned a value "".
D. If there is a non-null request parameter with name color, then its value gets assigned to color property of Java Bean fruit
d
The page directive is used to convey information about the page to JSP container. Which of these are legal syntax of page directive. Select the two correct statement
A. <% page info="test page" %>
B. <%@ page info="test page" session="false"%>
C. <%@ page session="true" %>
D. <%@ page isErrorPage="errorPage.jsp" %>
E. <%@ page isThreadSafe=true %>
bc
Is the following JSP code legal? Select the one correct statement.
<%@page info="test page" session="false"%>
<%@page session="false"%>
A. Yes. This is legal JSP syntax.
B. No. This code will generate syntax errors
b
A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify that the JSP page is generating an XML file.
A. contentType
B. generateXML
C. type
D. outputXML
a
A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its complete package name each time, we want to just use ArrayList. Which attribute of page directive must be specified to achieve this. Select the one correct answer.
A. extends
B. import
C. include
D. package
E. classpath
b
Which of these are true. Select the two correct answers.
A. The default value of isThreadSafe attribute of page directive is true.
B. If isThreadSafe attribute of page directive is set to true, then JSP container dispatches request for the page sequentially.
C. When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page.
D. Setting isThreadSage attribute to true for JSP pages, can lead to poor performance.
ac
Which of the following are examples of JSP directive. Select the two correct answers.
A. include
B. exclude
C. import
D. taglibrary
E. servlet
F. page
af
Which of these is true about include directive. Select the one correct answer.
A. The included file must have jspf extension.
B. The XML syntax of include directive in <jsp:include file="fileName"/> .
C. The content of file included using include directive, cannot refer to variables local to the original page.
D. When using the include directive, the JSP container treats the file to be included as if it was part of the original file.
d
Message-driven beans are classes that implement 2 interfaces :
Choose two answer
[A]
javax.ejb.MessageDrivenBean
[B]
javax.jms.Message
[C]
javax.jms.MessageBean
[D]
javax.jms.MessageListener
ad
Which are the types of messaging domains ? (choose 2)
[A]
Publish/Subcribe
[B]
Point-to-Point
[C]
Peer-to-Peer
[D]
Broadscast/Receiver
ab
Select the correct JMS programming model
[A]
Locate the JMS Driver -> Create a JMS connection -> Create a JMS session -> Locate the JMS destination -> Create a JMS producer or a JMS consumer -> Send or receive message
[B]
Locate the JMS Driver ->Create a JMS session ->Create a JMS connection ->Locate the JMS destination ->Create a JMS producer or a JMS consumer -> Send or receive message
[C]
Locate the JMS Driver ->Create a JMS connection -> Locate the JMS destination ->Create a JMS producer or a JMS consumer -> Send or receive message
[D]
Locate the JMS Driver ->Create a JMS connection ->Create a JMS session ->Create a JMS producer or a JMS consumer -> Send or receive message
d
Select the word to replace ??? to make the diagram about messaging domain correct
[A]
Topic
[B]
Queue
[C]
PTP
[D]
Pub/Sub//
a
A ____ subscription to a topic means that a JMS subscriber receives all message even if the subscriber is inactive
[A]
temporary
[B]
nondurable
[C]
persistent
[D]
Durable
d
In ejb-jar.xml file, <persistence-type> element value is __________
[A]
Bean or Container
[B]
Container-Managed-Persistent
[C]
Bean-Managed-Persistent
[D]
BMP or CMP
a
Entity bean is ______
[A]
a persistent data component
[B]
a database object
[C]
an application logic component
[D]
an object-relational mapping
a
ejbCreate() method of entity bean class returns ______
[A]
remote object
[B]
null
[C]
home object
[D]
primary key
d
create() method of entity home interface returns _________
[A]
null
[B]
remote object
[C]
primary key
[D]
home object
a
select CORRECT statement (choose 2)
[A]
Entity beans represent persistent state objects (things that don't go away when user goes away)
[B]
Session beans represent persistent state objects (things that don't go away when user goes away)
[C]
Session beans model a process or workflow (actions that are started by the user and that do away when user goes away)
[D]
Entity beans model a process or workflow (action that are started by the user and that go way when user goes away)
ac
The _______ class makes every entity bean different
[A]
bean key
[B]
bean ID
[C]
primary key
[D]
key
c
The top three values of EJB are (choose 3):
[A]
Portability is easier
[B]
Distributed application
[C]
Rapid Application Development
[D]
It is agreed upon by the industry
[E]
Easy to upgrade
acd
Which is not the players in the EJB Ecosystem? (choose 1):
[A]
End User
[B]
EJB Deployer
[C]
System Administrator
[D]
Application Assembler
[E]
Bean provider
a
The ______ is the overall application architect .This party is responsible for understanding how various components fit together and writes the application that combine components.
[A]
Application Assembler
[B]
Application Builder
[C]
Deployer
[D]
Developer
a
which is not the role of EJB Deployer?
[A]
Securing the deployment with a firewall
[B]
Performance-turning the system
[C]
Write the code that calls on components supplied by bean providers
[D]
Choosing hardware that provides the required level of performance
c
Which are EJB containers ? (choose three)
[A]
JBoss
[B]
BEA's WebLogic
[C]
Microsoft Application Server
[D]
Apache Tomcat 5.5
[E]
IBM WebSphere
abe
The ________ supplies business components,or enterprise beans
[A]
Tool vendor
[B]
Application assembler
[C]
Deployer
[D]
Bean provider
d
Given the following JSP and Tag handler code,what is the result of accessing the JSP ?
JSP Page Source
<html>
<body>
<%@taglib uri = "test_taglib" prefix = "myTag"%>
<% session.setAttribute("first", "first");%>
<myTag:TestTag/>
<br>
<%=session.getAttribute("second")%>
</body>
</html>
Tag Handler Code for <myTag:TestTag/>
pakage examples;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class TestTag extends TagSupport
{
private PageContext pageContext;
public void setPage(PageContextpage){
this.pageContext=page;
}
public int doStartTag() throws JspException {
try{
String first = pageContext.getSession().getAttribute("first").toString();
pageContext.getOut().write(first);
pageContext.setAttribute("second", "second", PageContext.PAGE_SCOPE);
}
catch(IOException)
{
throw new JspException(i.getMessage());
}
return SKIP_BODY;
}
public int doEndTag() throws JspException{
return EVAL_PAGE;
}
public void release(){}
}
Assume *.tld and web.xml files are correct.
[A]
second
first
[B]
first
second
[C]
first
null
[D]
second
null
b
Which of these are legal return types of the doEndTag method defined in a class that extends TagSupport class. SELECT the two correct answers.
[A]
EVAL_PAGE
[B]
EVAL_BODY
[C]
EVAL_PAGE_INCLUDE
[D]
EVAL_BODY_INCLUDE
[E]
SKIP_PAGE
[F]
SKIP_BODY
ae
A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive <%@taglib uri = "..." prefix="..."%>
Which of the following specifies the correct purpose of prefix attribute.SELECT the one correct answer.
[A]
The prefix defines the name of the tag that may be used for a tag library.
[B]
The prefix attribute defines the location of the tag library descriptor file
[C]
The prefix attribute should refer to the short name attribute of the tag library file that is defined by the uri attribute of taglib directive
[D]
The prefix attribute is used in front of a tagname of a tag defined within the tag library
d
_____ sends a request to an object and includes the result in a JSP file.
[A]
include directive
[B]
import directive
[C]
<jsp:forward>
[D]
<jsp:include>
d
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is need to do this. The InventoryItem has private instance variables to store the item information:
10.private int itemld;
11.private String name;
12.private String description;
Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable? (choose one)
[A]
setItemld(int itemld)
[B]
updateItemID(int itemld)
[C]
itemID(int itemld)
[D]
update(int itemld)
[E]
mutateItemId(int itemld)
a
Name the class that includes the SetSession method that is used to get the httpSession object
[A]
HttpSevletRequest
[B]
HttpSevletResponse
[C]
SessionContext
[D]
SessionConfig
a
Which of the following are potential legal of JSP source ? (choose 2)
[A]
<jsp:useBean id = "beanName1" class="a.b.MyBean"type="a.b.Myinterface"/>
[B]
<% String myValue = "myValue";%>
<jsp:setProperty name ="beanName1" property="soleProp" value = "<%=myValue%>"/>
[C]
<%String className = "a.b.MyBean";%>
<jsp:useBean id = "beanName2" class="<%=className>"/>
[D]
<%String propName = "soleProp"; %>
<jsp:getProperty name = "beanName1" property="<%=propName>" />
[E]
<%String beanName = "beanName3"; %>
<jsp:useBean id = "<%=beanName3%>" class="a.b.MyBean" />
bc
Given that a servlet has been mapped to /account/*.
Identity the HttpServletRequest methods that will return the/myapp segementforthe URI: /myapp/account/*.
A. getPathlnfo
B. getServletPath
C. getContextPath
a
Identify the method used to get an object available in a session. (Choose one)
A. get of Session
B. getValue of HttpSession
C. getAttribute of Session
D. getAttribute of HttpSession
d
Which jsp tag can be used to set bean property?
A. jsp:property
B. jsp:useBean.setProperty
C. jsp:useBean
D. jsp:useBean.property
E. jsp:setProperty
e
What is the consequence of attempting to access the following JSP page?
<html>
<body>
<%!
public void JspService(HttpServletRequest request HttpServletResponse response) { outwrite("A"):
}
%>
<% outwritef("B"): %>
</body>
</html>
A. Duplicate method compilation error.
B. "A" is output to the response before "B".
C. "A" is output to the response.
D. "B" is output to the response.
a
Which of the following statement is correct?
A. Data Integrity means that the data cannot be viewed by anybody other than it's intended recepient
B. Authentication means determining whether one has access to a particular resource or not
C. Data Integrity means that the data is not modified in transit between the sender and the receiver.
C
______includes a static file in a JSP file, parsing the file's JSP elements
A. <jsp:forward>
B. <jsp:useBean>
C. import directive
D. include directive
E. <jsp:include>
d
Study the statements:
1) The special directory/WEB-INF/lib contains Java class files—servlets and supporting code.
2) The special directory /WEB-INF/classes contains JAR files with supporting libraries of code.
A. Only statement 1 is true
B. Only statement 2 is true
C. Both 1 and 2 are true
D. Both 1 and 2 are not true
d
Which statements are BEST describe class attribute of <jsp:useBean class=_.. /> Action?
A. The name of a bean that can be used with method instantiate of class java.beans.Beans to load a JavaBean into memory.
B. The fully qualified class name of the Java object
C. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is ca
D. The type of the JavaBean. This can be the same type as the class attribute, a superclass of that type or an interface implemented by that type. The default value is the same as for attribute class.
b
Which are the correct lines of code to get information in the following<context-param> tag in the web.xml fi
Assume that response and request refer to HttpServletResponse and HttpServletRequest respectively.
A. response.getParameter('machineName');
B. requestgetParameter( machineName');
C. ServletContext sc = getServletContextO;
String serverName = sc.getlnitParameter("machineName");
D. ServletConfigsc = getServletConfigO;
String serverName = sc.getlnitParameterfmachineName");
--------------------------
<web-app>
<concexc-param>
<parair - narr.e >mach i neN ame < / p a r air - name >
<parair.-value>cms-server</parair.-value>
</context-parair.>
</web-app>|
c
Consider the following java code:
//in file Book.java package com.bookstore; public class Book {
private long isbn;
public BookO{ isbn = 0;}
public long getlsbn(){ return isbn;}
public void setlsbn(long value){ this.isbn = value;}
}
Code for browse.jsp:
<jsp:useBean class="com.bookstore.Book" id="newbook"/>
LINE 1: <jsp:setProperty name="newbook" property="isbn" value="1000"/>
Which of the following statements are correct?
A. The isbn property of new book will be set to 1000 if nbsp;nbsp;'value' attribute of 'setProperty' tag is given as: value=1000
B. The isbn property of newbook will be set to 1000.
C. It will not compile.
b
Identify the technique that can be used to implement 'sessions' if the client browser does not support cookies.(Choose one)
A. It cannot be done without cookie support
B. Using Http headers.
C. URL Writing
D. Hidden form fields.
D
You have to send a pdf file to the client as a response to a request Which of the following calls will you have to make? (Choose one)
A. response.setType("application/pdf");
B. response.setContentType("image/pdf");
C. response.setContentType("application/pdf");
D. response.setType("image/pdf);
C
A JSP_____lets you define methods or fields that get inserted into the main body of the servlet class (outside of the JspService method that is called by service to process the request).
A. expression
B. scriptlet
c. declaration
c
Which is NOT a correct statement about entity beans?
A. They are used to share data among clients
B. They are used to store persistent data
C. They are used to represent data stored in a RDBMS
D. They are used to implement business processes
d
A Java developer needs to be able to send email, containing XML attachments, using SMTP. Which JEE (J2EE) technology provides this capability?
A. Servlet
B. JSP
C. EJB
D. JavaMail
d
Consider the HTML code below. Which of the following method calls can retrieve the "email" value sent from the browser? (Choose one)
A. getFormValue("email") of HttpServletRequest
B. getField(email") of HttpServletRequest
C. getParameter("email") ofServletRequest
D. getParameters("email") of HttpServlet
c
Which of the following methods can be used to add cookies to a servlet response?
A. HttpServletResponse.addCookie(Cookie cookie)
B. ServletResponse.addCookie(Cookie cookie)
C. ServletResponse.addCookie(String contents)
D. HttpServletResponse.addCookie(String contents)
E. ServletResponse.addHeader(String name. String value)
a
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?
A. FWorks/classes
B. FWorks/WEB-INF/lib/classes
C. FWorks/WEB-INF
D. FWorks/WEB-INF/classes
d
Which is NOT a core component of JSP?
A. actions
B. name of a jsp file
C. tag libraries
D. scriptlets
E. directives
d
A parameter is defined in a <context-param> element of the deployment descriptor for a web application. Which of the following statements is correct?
A. It is accessible only to the servlet it is defined for.
B. It is accessible to all the servlets of all the webapps of the container.
C. It is accessible to all the servlets of the webapp.
c
Identify the parent element of <session-timeout> element in web.xml
A. <session-configuration>
B. <webapp>
C. <session_config>
D. <session-config>
d
Which of the following are correct JSP expressions?
A. <%= outprintln("hello"); %>
B. <% "Hello World"; %>
C. <%= "Hello World"; %>
D. <%= new Date() %>
d
What would be the best directory in which to store a supporting JAR file for a web application? Note that in the list below, all directories begin from the context root
A. \WEB-INF\lib
B. \jars
C. \WEB-INF
D. \WEB-INF\classes
a
Which security mechanism proves that data has not been tampered with during its transit through the network?
A. Packet sniffing
B. Data integrity
C. Data validation
D. Authentication
E. Data privacy
F. Authorization
b
A JSP page has the following page directives:
<%@page isErrorPage='false' %>
<%@page errorPage='/jsp/myerror.jsp' %>
Which of the following implicit object is NOT available to the jsp page?
A. session
B. response
C. application
D. exception
d
Which statements are BEST describe uri attribute of <%@ taglib uri=_%>directive of JSP file?
A. The scripting language used in the JSP. Currently, the only valid value for this attribute is java.
B. Allows programmers to include their own new tags in the form of tag libraries. These libraries can be used to encapsulate functionality and simplify the coding of a JSP.
C. Specifies the relative or absolute URI of the tag library descriptor.
D. Specifies the required prefix that distinguishes custom tags from built-in tags. The prefix names jsp. jspx. java, javax. servlet sun and sunw are reserved.
c
Which is NOT a standard technique for a session be definitely invalidated?
A. If the session time out is set to 0 using setMaxInactivelntervalO method.
B. No request comes from the client for more than "session timeout" period.
C. A servlet explicitly calls invalidateO on a session object
D. The container is shutdown and brought up again.
a
Which of the following task may happen in the translation phase of JSP page? (Choose one)
A. Instantiation of the servlet class.
B. Creation of the servlet class corresponding to the JSP file.
C. None of the others
D. Execution of JspServiceQ method.
b
How can you ensure the continuity of the session while using HttpServletResponse.sendRedirect() method when cookies are not supported by the client?
A. By using HttpServletRequestencodeURLO method.
B. By enconding the redirect path with HttpServletResponse.encodeRedirectURLO method.
C. By using hidden parameters.
b
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.lang.Exception? (Choose one)
A. Don't do anything, the servlet container will automatically send a default error page.
B. Don't catch the exception and define the 'exception to error-page' mapping in web.xml
C. Catch the exception, wrap it into ServletException and define the 'business exception to error-page' mapping in web.xml
c
What is the output of the following code snippet of a JSP page?
${empty""}<br>
${empty"sometext"}
A. false
B. false true
C. true false
D. true
c
Which option can be used to predefine Java Persistence queries for easy use?
A. @NamedNativeQuery annotation
B. @NamedQuery annotation
C. using the named-native-query element in the XML descriptor
b
Which is NOT associated with the business tier in a JEE (J2EE) web-based application?
A. Entity Beans
B. JSP
C. Stateless Session Beans
b
Which of the following statements is correct? Select the one correct answer.
A. The response from the server to a GET request does not contain a document
B. The setStatus method defined in the HttpServletRequest class takes an int as an argument and sets the status of Http response
C. The response from the server to a HEAD request consists of status line, content type and the document
D. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method.
d
Which of the following classes define the methods setStatus(...) and sendError(...) used to send an HTTP error back to the browser? (Choose one)
A. Both are defined in HttpServletResponse.
B. Both are defined in ServletResponse
C. HttpServletResponse and ServletResponse respectively.
D. ServletResponse and HttpServletResponse respectively.
a
Identify the correct element is required for a valid <taglib> tag in web.xml (Choose one)
A. <taglib-uri>
B. <uri>
C. <uri-name>
D. <uri-location>
E. <tag-uri>
a
(Choose 1 answer)
Which of the statements regarding the following code are correct?
public void doPost(HttpServletRequest req. HttpServletResponse res) throws lOException. ServletException {
res.getWriterOprint("Hello");
RequestDispatcher rd = getServletContext().getRequestDispatcher(7testjsp");
rd.include(req. res);
res.getWriter().print("World"):
}
A. Only "World" will be a part of the output
B. Neither will be a part of the output
C. Only "Hello" will be a part of the output
D. "Hello" and "World" both will be a part of the output
d
Which technology is used for processing HTTP requests and mapping those requests to business objects
A. EJB
B. JMS
C. Servlets
D. MOM (Message-Oriented Middleware Product)
c
10. Which of the given jsp statement is equivalent to
<% = userbean.getAge() %>
Assume that userbean.getAge() returns an integer. (Choose one)
A . <jsp:getProperty name = "userbean" property = "Age" />
B. <jsp:getProperty name = "userbean" method= "getAge" />
C. <jsp:getProperty name = "userbean" property = "age" />
D . <jsp:getProperty name = "userbean" property = "getAge" />
C
1. Which statements are BEST describe errorPage attribute of <%@ page errorPage=. %> directive?
A. Specifies the MIME type of the data in the response to the client. The default type is text/html
B. Specifies the class from which the translated JSP will be inherited . This attribute must be a fully qualified package and class name.
C. Any exception in the current page that are not caught are sent to the error page for processing . The error page implicit object exception references the original exception.
D. Specifies if the current page is an error page that will be inoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references th...
C
2. What gets printed when the following code snippet is compiled? Select the one correct answer .
<% int y =0 ; %>
<% int z =0; %>
<%for(int x =0; x<3; x++) { %>
<% z++ ; ++y; %>
<% } %>
<% if(z<y) {%>
<%=z%>
<%} else { %>
<%= z-1 %>
<%} %>
A. 0
B. 1
C. 2
D. 3
E. The program generates compilation error.
C
3. Which of these is a correct fragment within the web-app element of deployment descriptor
A. <error-page> <error-code>404 </error-code> <location></error-page>
B. <error-page> <exception-type> mypackage.MyException</exception-type> <error-code>404 </error-code> <location>/error.jsp</location></error-page>
C. <error-page> <exception-type> mypackage.MyException</exception-type> <error-code>404 </error-code> <location></error-page>
A
5. The HttpServletRequest has methods by which you can find out about incoming information such as:
A. the client's hostname
B. All of the others
C. cookies
D. HTTP request headers
E. form date
B
6. Which of the following classes define the methods setStatus(___) and sendError(___) used to send an HTTP error back to the browser?
A . Both are defined in ServletRequest
B . Both are defined in ServletResponse
C . Both are defined in HttpServletRequest
D .Both are defined in HttpServletResponse_
D
7. Host names are translated into IP addresses by web servers.
A False
B_ True
A
8. Which of the following defines the type of the content that a tag can accept?
A. content-type
B body-content
C content
D. tag-content-type
B
12.
Identify the parent element of <session-timeout> element in web_xml
A <session-configuration>
B . <session config>
C. <session-config>
D . <webapp >
C
14. In which of the following case will the method doStartTag() of a tag handler be invoked?
A, If doEndTag() returns EVAL TAG AGAIN
B . This method is invoked if doTag() method returns true.
C .It will be invoked only If the use of that tag is not enclosed in another custom tag.
D. This method is invoked if doTag() method returns DO START
E. This method is always invoked whenever the tag's use is encountered in the jsp page.
E
16. Which statements are BEST describe name attribute of < jsp:setProperty name:__ /> action?
A The name of the property to set. Specifying " *"for this attribute causes the JSP to match the request parameters to the properties of the bean.
B . The ID of the JavaBean for which a property (or properties) will be set.
C, If request parameter names do not match bean property names, this attribute can be used to specify which request parameter should be used to obtain the value for a specific bean property
D. The value to assign to a bean property The value typically is the result of a JSP expression
B
17. How can you ensure the continuity of the session while using HttpServletResponse.sendRedirect() method when cookies are not supported by the client?
A By using hidden parameters.
B By using HttpServletRequest_encodeURL() method.
C By enconding the redirect path with HttpServletResponse.encodeRedirectURL() method
D HttpServletResponse.encodeRedirectURL() method
C
18. Which of the following implicit variables should be used by a jsp page to access a resource and to foward a request to another jsp page?(Choose one)
A pageContext and config
B config and pageContext
C application for both
D config for both.
A
19. Which of the following is a properly formatted taglib element occurring in web_xml?
A. <taglib>
<uri>/graph</tablib-uri>
<location>/WEB-INF/Charts.tld</location>
</tablib>
B. <taglib>
<taglib-uri>/graph</tablib-uri>
<tablib-location>/WEB-INF/Charts.tld</tablib-location>
</tablib>
C. <taglib>
<taglib-name>/graph</taglib-name>
<taglib-location>/WEB-INF/Charts.tld</taglib-location>
</tablib>
B
21. Your web application logs a user in when she supplies username/password_ At that time a session is created for the user. Your want to let the user to be logged in only for 20 r
A getLastAccessTime()
B getLastAccessedTime()
C getMaxlnactivelnterval()
D getCreationTime()
B
22. A bean with a property color is loaded using the following statement
<jsp:useBean id="fruit"
Which statement may be used to set the color property of the bean.
A <jsp:setColor id="fruit" property= "color" value="white"/>
B <jsp:setColor name="fruit" property= "color" value="white"/>
C <jsp:setValue name="fruit" property= "color" value="white"/>
D <jsp:setProperty name="fruit" property= "color" value="white">
E <jsp:setProperty name="fruit" property= "color" value="white"/>
F <jsp:setProperty id="fruit" property= "color" value="white">
E
23. Consider the HTML code below. Which of the following method calls can retrieve the "email" value sent from the browser? (Choose one)
A getFormValue("email") of HttpServletRequest
B getParameters("email") of HttpServlet
C getParameter("email") of ServletRequest
D getField("email") of HttpServletRequest
C
26. Identify the method used to get an object available in a session. (Choose one)
A getAttribute of HttpSession
B getValue of HttpSession
C get of Session
D getAttribute of Session
A
27. _________ includes a static file in a JSP file, parsing the file's JSP elements
A <jsp:forward>
B. <jsp:useBean>
C import directive
D <jsp:include>
E . include directive
E
28. Which of these is legal attribute of page directive?
A include
B scope
C errorPage
D debug
C
30. Complete the statement:
<taglib> element in the Web application deployment descriptor is used to ______
A specify the mapping of the name and the TLD file for a tag library
B specify the parameters needed by a tag library
C specify a URI identifying a tag library
A
29. Which of the following XML fragments correctly specify the class name for a sennet in a deployment descriptor of a webapp?
A <servlet-class> com.abcinc.OrderServlet</servlet-class>
B <servlet> com.abcinc.OrderServlet</servlet>
C <class> com.abcinc.OrderServlet</class>
D <servlet-class> com.abcinc.OrderServlet.class</servlet-class>
A
31. When implementing a tag, if the tag does not include the body, then the tag handler class must extend the BodyTagSupport class.
Is this statement true of false?
A True
B_ False
B
33. Browsers typically cache the server's response to a POST request.
A False
B_ True
A
34. You can set a page to be an error page either through web_xml or by adding a page directive
A <%@page errorPage="errorPage.jsp" %>
B <%@page isErrorPage="true" %>
B <%@page íisErrorPage="false" %>
B
36. (Choose 1 answer)
Study the statements:
1) The context path contains a special directopy called WEB-INF which contains the deployment descriptor file, web_xml
2) A client application may directly access resources in WEB-INF or Its subdirectones through HTTP_
A Both 1 and 2 are true
B Only statement 1 is true
C Only statement 2 is true
D Both 1 and 2 are not true
B
37. (Choose 1 answer)
The web_xml file for a webapp contains the following XML fragment for configuring session timeout.
<session-config>
<session-timeout>300</session-timeout>
<session-config>
What would be the sesson timeout intewal for the sessions created in this web application?
A. 300 minutes
B_ 300 hours
C. 300 milli seconds
D. 300 seconds
A
39. JSP ____ let you inserts arbitrary code into servlet's _jspService method (which is called by service)
A declarations
B scriptlets
C expressions
B
47. Which is NOT a scope of implicit objects of JSP file?
A. application
B session
C page
D request
E response
E
48. A JavaBeans component has the following field.
private boolean enabled
Which pairs of method declarations follow the JavaBeans standard for accessing this field?
A. public boolean setEnabled( boolean enabled)
public boolean getEnabled()
B. public void setEnabled( boolean enabled)
public boolean getEnabled()
C. public Boolean setEnabled( boolean enabled)
public boolean isEnabled()
D. public void setEnabled( boolean enabled)
public void isEnabled()
B
49. statement true or false?
The deployment descriptor of a web application must have the name web_xml_ In the same way the tag librapy descriptor file must be called taglib_xml
A. True
B. False
B
40. Which are the correct lines of code to get information in the following <context-param> tag,
Assume that response and request refer to HttpSeMetResponse and HttpServletRequest
<web—app>
<context—param>
<param—name>machineName</param—name >
<param—value>cms-server</param-value>
</context—param>
</web—app>
A. request.getParameter("machineName");
B. ServletConfig sc = getServletConfig();
String serverName = sc.getInitParameter("machineName");
C. ServletConfig sc = getServletContext();
String serverName = sc.getlnitParameter("machineName");
D. response.getParameter("machineName");
C
41. <html>
<body>
<form action="loginPage.jsp">
Login ID:<input type "text" name="loginlD"><br>
Password:<input type "password" name="password"><br>
<input type "submit" value="Login">
<input type "reset" value="Reset">
</form>
</body>
<html>
Study the above html code. Assume that user clicks button Reset.
What is the correct statement?
A. All inputs are cleared.
B. Nothing changes.
A
43. You need to modify the deployment descriptor for a web application installed in MyWebApp directory. Which file would you look for?
A. MyWebApp.xml MyWebApp
B. web.xml in MyWebApp
C. MyWebApp.xml in MyWebApp/WEB-INF
D. web.xml in MyWebApp/WEB-INF
D
45. 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?
A. FWorks/WEB-INF/classes
B. FWorks/classes
C. FWorks/WEB-INF
D. FWorks/WEB-INF/lib/classes
A
46.
Which of the following are correct JSP expressions?
A. <%=out.println("hello");%>
B. <%="Hello World";%>
C. <%= new Date()%>
D. <%"Hello World";%>
C
Which jsp tag can be used to set bean property?
A. jsp:useBean.setProperty
B. jsp:useBean.property
C. jsp:setProperty
D. jsp:property
E. jsp:useBean
C
Which are the correct lines of code to get information in the following <context-param> tag in the web.xml file?
<web-app>
<context-param>
<param-name>machineName</param-name>
<param-value>cms-server</param-value>
</context-param>
</web-app>
A. request.getParameter("machineName");
B. ServletContext sc = getServletContext();
String serverName = sc.getInitParameter("machineName");
C. ServletConfig sc = getServletConfig().
String serverName = sc.getInitParameter("machineName");
D. response.getParameter("machineName");
B
Servlets usually are used on the client side of a networking application.
A. False
B. True
A
Study the statements:
1) Every web application within a web container has a unique context path
2) The context path and any directories you choose to create within it contain resources that are accessible through HTTP
A. Only statement 1 is true
B. Only statement 2 is true
C. Both 1 and 2 are true
D. Both 1 and 2 are false
C
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?
A. null
B. false
C. empty
D. blank
C
Session death is more likely to come about through a time-out mechanism. If there is no activity on a session for a predefined length of time, the web container invalidates the session.
A. False
B. True
B
What is the output of the following code snippet of a JSP page?
${empty "")<br>
${empty "sometext"}
A. true
false
B. false
true
C. false
D. true
A
The <servlet-mapping> element provides a means of defining URLs to use the servlet resources.
A. True
B. False
A
Which of the following is a properly formatted taglib element occurring in web.xml?
A. <taglib>
<taglib-name>/graph</taglib-name>
<taglib-location>/WEB-INF/Charts.tld</taglib-location>
</taglib>
B. <taglib>
<taglib-uri>/graph</taglib-uri>
<taglib-location>/WEB-INF/Charts.tld</taglib-location>
</taglib>
C. <taglib>
<lib-uri>/graph</lib-uri>
<lib-location>/WEB-INF/Charts.tld</lib-location>
</taglib>
D. <taglib>
<uri>/graph</uri>
<location>/WEB-INF/Charts.tld</location>
</taglib>
B
What gets printed when the following JSP code is invoked in a browser?
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>
A. The browser will print either hello or hi based upon the return value of random.
B. The string hello will always get printed.
C. The string hi will always get printed.
D. The JSP file will not compile.
D
A JSP file uses a tag as <myTaglib:myTag>. The myTag element here should be defined in the which element of the taglib element in the tag library descriptor file?
A. tagname
B. name
C. tag
D. prefix
B
Identify the method used to get an object available in a session.
A. getValue of Session
B. getValue of HttpSession
C. getAttribute of Session
D. getAttribute of HttpSession
D
Which of these is true about include directive?
A. The included file must have jsp extension.
B. The XML syntax of include directive in <jsp:include file="fileName"/>
C. The content of file included using include directive, cannot refer to variables local to the original page.
D. When using the include directive, the JSP container treats the file to be included as if it was part of the original file.
D
A bean present in the page and identified as 'mybean' has a property named 'name'. Which of the following is a correct way to print the value of this property?
A. <%=jsp:getProperty name="mybean" property="name"%>
B. <%out.println(mybean.getName())%>
C. <jsp:getProperty name="mybean" property="name"/>
D. <%=out.println(mybean.getName())%>
C
Your jsp page uses java.util.TreeMap. Adding which of the following statement will ensure that this class is available to the page?
A. <%@ page import="java.util.TreeMap"%>
B. <%! import="java.util.TreeMap"%>
C. <%@ import="java.util.TreeMap"%>
D. <%! page import="java.util.TreeMap"%>
A
Which directory is legal location for the deployment descriptor file? Note that all paths are shown as from the root of the web application directory
A. \WEB-INF
B. \WEB-INF\xml
C. \WEB-INF\classes
A
Given the following JSP and tag handler code, what is the result of accessing the JSP?
<html>
<body>
START
<br>
<%@taglib uri="test_taglib" prefix="myTag"%>
<myTag:TestTag/>
<br>
END
</body>
</html>
Tag Handler Code for <myTag:TestTag />
package examples;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class TestTag extends TagSupport {
@Override
public int doStartTag() throws JspException {
return EVAL_PAGE;
}
@Override
public int doEndTag() throws JspException {
return SKIP_PAGE;
}
}
Assume *.tld and web.xml files are correct
A. START
B. START
END
C. END
START
D. END
A
Which of the following file is the correct name and location of deployment descriptor of a web application? Assume that the web application is rooted at \doc-root.
A. \doc-root\dd.xml
B. \doc-root\web.xml
C. \doc-root\WEB-INF\web.xml
D. \doc-root\WEB_INF\dd.xml
E. \doc-root\WEB-INF\dd.xml
F. \doc-root\WEB_INF\web.xml
C
A Java bean with a property color is loaded using the following statement
<jsp:useBean id="fruit" class="Fruit"/>
What is the effect of the following statement.
<jsp:setProperty name="fruit" property="color"/>
Select one correct answer.
A. An error gets generated because the value attribute of setAttribute is not defined
B. The color attribute is assigned a value null
C. The color attribute is assigned a value ""
D. If there is a non-null request parameter with name color, then its value gets assigned to color property of Java Bean fruit
D
Which of the following classes define the methods setStatus(...) and sendError(...) used to send an HTTP error back to the browser?
A. Both are defined in HttpServletResponse
B. Both are defined in ServletRequest
C. Both are defined in ServletResponse
D. Both are defined in HttpServletRequest
A
The path in a URL typically specifies a resource's exact location on the server
A. False
B. True
B
In which of the following cases will the method doEndTag() of a tag handler be invoked?
A. It will be invoked only if doStartTag() or doAfterBody() return Tag.DO_END_TAG
B. It will be invoked only if doStartTag() and doAfterBody() complete successfully
C. This method is invoked if doStartTag() method returns true
D. It will be invoked in all case even if doStartTag() or doAfterBody() throw an exception
D
Which statements are BEST describe errorPage attribute of <%@ page errorPage=...%> directive?
A. Specifies the MIME type of the data in the response to the client. The default type is text/html.
B. Specifies the class from which the translated SP will be inherited. This attribute must be a fully qualified package and class name.
C. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
D. Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original exception that occurred.
C
Which of the following statement is correct?
A. Authentication means determining whether one has access to a particular resource or not
B. Confidentiality and Authorization are one and the same thing
C. Authentication means proving whether one is what one claims to be
C
Which of the following statements are correct about HTTP Basic authentication mechanism?
A. HTML FORM is used to capture username and password
B. Password is transmitted either in encrypted text or in plain text depending on the browser
C. Password is transmitted in an encrypted form
D. Password is transmitted as text
D
Select the correct directive statement insert into the first line of following lines of code:
1 Insert code here
<html>
<head>
<title>Test Page</title>
</head>
<body>
Today's Date is <%=new Date()%>
</body>
</html>
A. <%@ package import ='java.util.*' %>
B. <%@ page import='java.util.*' %>
C. <%! page import='java.util.*' %>
D. <%@ import package='java.util.*' %>
B
Which statements are BEST describe page attribute of <jsp:include page =...> Action?
A. Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed
B. Forwards request processing to another JSP, servlet or static page. This action terminates the current JSP's execution
C. Specifies the relative URI path of the resource to include. The resource must be part of the same Web application
D. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean
C
Your web application logs a user in when she supplies username/password. At that time a session is created for the user. Your want to let the user to be logged in only for 20 minutes. The application should redirect the user to the login page upon any request after 20 minutes of activity. Which of the following HttpSession methods would be helpful to you for implementing this functionality?
A. getCreationTime()
B. getLastAccessedTime()
C. getMaxInactiveInterval()
D. getLastAccessTime()
B
Identify correct statement about a WAR file:
A. It is used by web application developer to deliver the web application in a single unit
B. It cannot be unpackaged by the container
C. It is an XML document
D. It contains web components such as servlets as well as EJBs
E. It cannot contain third party jar and class files.
D
The two most common HTTP requests are get and put.
A. False
B. True
A
Which security mechanism limits access to the availability of resources to permitted groups of users or programs?
A. MD5 encryption
B. Authentication
C. Data integrity
D. Authorization
E. Confidentiality
F. Checksum validation
D
Browsers typically cache the server's response to a POST request.
A. True
B. False
B
A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its complete package name each time, we want to just use ArrayList. Which attribute of page directive must be specified to achieve this.
A. extends
B. import
C. include
D. package
E. classpath
B
Which statements are BEST describe include directive of JSP file?
A. Allows programmers to include their own new tags in the form of tag libraries. These libraries can be used to encapsulate functionality and simplify the coding of a JSP.
B. The scripting language used in the JSP. Currently, the only valid for this attribute is java.
C. Causes the JSP container to perform a translation-time insertion of another resource's content. As the JSP is translated into a servlet and compiled, the referenced file replaces the include directive and is translated as if it were original part of the JSP.
D. Defines page setting for the JSP container to process.
C
Which is NOT a standard technique for a session be definitely invalidated?
A. The container is shutdown and brought up again.
B. No request comes from the client for more than "session timeout" period.
C. If the session time out is set to 0 using setMaxInactiveInterval() method.
D. A servlet explicitly calls invalidate() on a session object.
C
You need to make sure that the response stream of your web application is secure. Which factor will you look at?
A. authorization
B. authentication
C. data integrity
C
Which of the following is NOT a valid attribute for a useBean tag?
A. className
B. beanName
C. scope
A
Which of the given jsp statement is equivalent to: <%=userbean.getAge()%>. Assume that userbean.getAge() returns an integer.
A. <jsp:getProperty name="userbean" method="getAge"/>
B. <jsp:getProperty name="userbean" property="Age"/>
C. <jsp getProperty name="userbean" property="getAge"/>
D. <jsp:getProperty name="userbean" property="age"/>
D
Which interface and method should be used to retrieve a servlet initialization parameter value?
A. ServletConfig: getInitParameter(String name)
B. ServletConfig: getParameter(String name)
C. ServletConfig: getInitParameterNames(String name)
D. SevletContext: getInitParameter(String name)
A
Which of the following elements defines the properties of an attribute that a tag needs?
A. attribute
B. tag-attribute-type
C. attribute-type
D. tag-attribute
A
... is the well-known host name that refers to your own computer.
A. localhost
B. ip
C. DNS
D. computer name
A
Which statements are BEST describe <jsp:include> Action?
A. Specifies the relative URI path of the resource to include. The resource must be part of the same Web application.
B. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean.
C. Forwards request processing to another JSP servlet or static page. This action terminates the current JSP's execution.
D. Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed.
D
Which method of LoginServlet will be called when the user clicks on "Submit" button for the following form.
<html>
<body>
<form action="/myapp/Loginservlet" method="POST">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit" value="POST">
</form>
</body>
</html>
A. servicePost(HttpServletRequest, HttpServletResponse);
B. doPost(HttpSevletRequest, HttpServletResponse);
C. doPOST(HttpServletRequest, HttpServletResponse);
D. post(HttpServletRequest, HttpServletResponse);
E. doPUT(HttpServletRequest, HttpServletResponse);
B
Which of the following statement is correct?
A. Authentication means determining whether one has access to a particular resource or not.
B. Data Integrity means that the data cannot be viewed by anybody other than it's intended recepient.
C. Data Integrity means that the data is not modified in transit between the sender and the receiver.
C
The HttpServletRequest has methods by which you can find out about incoming information such as:
A. form data
B. the client's hostname
C. cookies
D. HTTP request headers
E. All of the others
E
Consider the following taglibrary descriptor element:
<tag>
<name>Hello</name>
<tag-class>com.abc.HelloTag<tag-class>
<body-content>...</body content>
</tag>
Which of the following is NOT a valid value for <body-content> element?
A. generic
B. empty
C. JSP
A
The following line of code exists in the doGet method of Servlet:
String sid = request.getParameter("jsessionid");
Which of the option is NOT a standard technique for retrieving the HttpSession associated with the request?
A. HttpSession session = request.getSession(true);
B. HttpSession session = request.getSession(false);
C. HttpSession session = request.getSession();
D. HttpSession session = request. getSession(sid);
D
The web.xml file for a webapp contains the following XML fragment for configuring session timeout.
<session-config>
<session-timeout>300</session-timeout>
</session-config>
What would be the session timeout interval for the sessions created in this web application?
A. 300 seconds
B. 300 hours
C. 300 minutes
D. 300 milliseconds
C
Name the default value of the scope attribute of <jsp:useBean>
A. request
B. page
C. application
D. session
B
What will be the result of pressing the submit button in the following HTML form? (Choose two.)
<form action="/servlet/Register">
<input type="text" name="fullName" value="Type name here" />
<input type="submit" name="sbmButton" value="OK" />
</form>
A. A request is sent with the HTTP method HEAD.
B. A request is sent with the HTTP method POST.
C. A request is sent with the HTTP method GET.
D. The parameter fullName is the only parameter passed to the web server in the request URL.
E. The parameter fullName is the only parameter passed to the web server as part of the request body.
F. The parameters fullName and sbmButton are passed to the web server in the request URL.
G. The parameters fullName and sbmButton are passed to the web server as part of the request body.
H. No parameters are passed to the web server.
C F
Students also viewed
SWE201c
345 terms
SWT301
340 terms
SE_Kỳ 4_SWE201c
342 terms
SWE201c
342 terms
Other sets by this creator
PRJ321 (Java Web)
320 terms
PRJ321 (Java Web)
320 terms
PRJ321 (Java Web)
320 terms
SWT301-Test1
16 terms
Recommended textbook solutions
Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition
•
ISBN: 9780124077263
(5 more)
David A. Patterson, John L. Hennessy
220 solutions
Service Management: Operations, Strategy, and Information Technology
7th Edition
•
ISBN: 9780077475864
James Fitzsimmons, Mona Fitzsimmons
103 solutions
Operating System Concepts
9th Edition
•
ISBN: 9781118063330
(2 more)
Abraham Silberschatz, Greg Gagne, Peter B. Galvin
489 solutions
Starting Out with C++ from Control Structures to Objects
8th Edition
•
ISBN: 9780133769395
(10 more)
Godfrey Muganda, Judy Walters, Tony Gaddis
1,294 solutions
Other Quizlet sets
Rebecuh y el Cristal Mágico
16 terms
Principles of Investigation (AJ019) - Chapters 7,…
40 terms
CISCO 1 Chapters 9-17 study guide
246 terms
chap 13 quiz
20 terms