Font size
WorksheetsPRJ103_PART2
Total questions: 130
Worksheet time: 1hrs 8mins
Which sub-element is used to define a logical name of servlet in web deployment descriptor?
Select one:
a. All of the other choices
b. url-pattern
c. servlet-name
d. servlet-class
Which of these statements is true about the Filter implementation?
Select one:
a. The doFilter(request, response) method examines the request or response headers and also customises them as per requirement
b. All of the others
c. The Filter Interface must be implemented to create a filter class
d. The init() method is called by the servlet container many times to initialise the filter
Given a scoped attribute cart exists only in a user's session.Choose the option taken the cart from session and assign it to the attribute.
Select one:
a. <c:set var="cart" value="${sessionScope[].cart}"/>
b. <c:set var="cart" value="${sessionContext.cart}"/>
c. <c:set var="cart" value="${session.cart}"/>
d. None of the others.
e. <c:set var="cart" value="${sessionScope.cart}"/>
Given a web application in which the request parameter productID contains a product identifier. Which EL expression evaluates the value of the productID?
Select one:
a. ${productID}
b. None of the others
c. ${pageContext.request.productID}
d. ${param.productID}
Which JSTL code snippet can be used to import content from another web resource?
Select one:
a. <c:import url="foo.jsp"/>
b. <c:import page="foo.jsp"/>
c. All of the others
d. <c:include url="foo.jsp"/>
Which of the following statement is true about the Session Listeners?
Select one:
a. HttpSessionBindingListener must not register in web deployment descriptor
b. HttpSessionBindingListener must register in web deployment descriptor
c. None of the others
d. ServletContextListener must not register in web deployment descriptor
e. ServletContextAttributeListener must not register in web deployment descriptor
Which of the following statement relating to Hidden form fields is incorrect?
Select one:
a. The session information can be extracted by the application by searching for Hidden form fields
b. Hidden form fields send information from one HTML page to another thereby maintaining the connection between the two pages
c. All of the others
d. The servlets or JSP page read the Hidden form fields using response.sendParameter
Which of the following attributes of the Page directive is used to specify the page to display errors which may occur in the JSP page?
Select one:
a. None of the others
b. Error
c. excption
d. errorPage
e. isErrorPage
Which of the following is a incorrect syntax of the getAttribute() method?
Select one or more:
a. public Object getAttribute(String name)
b. public Name getAttribute(String name)
c. public Object getAttribute(String name, Object obj)
d. public Object getAttribute(Object obj)
Given:
<filter>
<filter-name>FilterF</filter-name>
</filter-class>sample.servlet.Filter1</filter-class>
</filter>
<filter>
<filter-name>FilterE</filter-name>
</filter-class>sample.servlet.Filter2</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterF</filter-name>
</url-pattern>FilterServlet</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>FilterE</filter-name>
</url-pattern>FilterServlet</url-pattern>
</filter-mapping>
Choose the correct statement
Select one:
a. The request is applied the FilterF, FilterE in sequence
b. None of the others
c. The response is applied the FilterF, FilterE in sequence
d. The request is applied the FilterE, FilterF in sequence
What time is recorded as the last accessed time for an HttpSession object?
Select one:
a. The last time an attribute was bound to or unbound from the HttpSession object.
b. None of the others.
c. The last time a method was executed against an HttpSession object.
d. The last time the client sent a request associated with the session.
Given:
6. <%int[] nums = {42, 420, 4200};
7. request.setAttribute("foo", nums); %>
Which successfully translate and result in a value of true? Select one:
a. ${true or false}
b. ${requestScope[foo][0] > 500}
c. All of the others
d. ${requestScope['foo'][1] = 420}
Which element is the parent of the <filter> tag in the web application deployment descriptor?
Select one:
a. <filter-list>
b. None of the others.
c. <filters>
d. <web-app>
e. <servlet>
Which of the following is a correct syntax of the getAttribute() method of web development context?
Select one:
a. public Object getAttribute(String name, Object obj)
b. public Object getAttribute(String name)
c. public Name getAttribute(String name)
d. public Object getAttribute(Object obj)
Which of the following constitute valid ways of importing Java classes into JSP page source?
Select one:
a. <%! import java.util.*; %>
b. <%@ import java.util.* %>
c. <%@ page import="java.util.*" %>
d. None of the others.
Which of the following are false statements about standard action attributes?
Select one or more:
a. If both are used, class and type attributes must have different values.
b. The reference variable used for a bean doesn't always have the same type as the bean object it refers to.
c. If the type attribute is used, the class attribute must be presented.
d. If both are used, class and type attributes must have the same value.
e. If class and type attributes are presented, the class attribute must match the object type of your bean.
What will be the output of the code snippet ${"2" + "2"}?
Select one:
a. 22
b. None of the others.
c. 4
d. 2+2
The JSP element <%!.....%> will be replaced by the tag .... in the JSP document.
Select one:
The JSP element <%!.....%> will be replaced by the tag .... in the JSP document.
Select one:
b. <jsp:method>></jsp:method>
c. All of the others.
d. <jsp:declaration> ... </jsp:declaration>
A Java bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="abc.Fruit" /> What is the effect of the following statement? <jsp:setproperty name="fruit" property="color"/>
Select the correct answer.
Select one:
a. An error is generated because the value attribute of setAttribute is not defined
b. None of the others
c. The color attribute is assigned a value null
d. The color attribute is assigned a value ""
e. If there is a non-null request parameter with name color, then its value is assigned to color property of Java Bean fruit
Given a JSP code fragment
<jsp:useBean id="book1" scope="session"/>
Choose the correct statement .
Assume that the book class has the title attribute that is declared both get and set method
Select one:
a. The title attribute of book1 can be accessed using EL as ${sessionScope.book1.title}
b. None of the others
c. The title attribute of book1 can be accessed using EL as ${sessionScope.book1.getTitle}
d. The title attribute of book1 can be accessed using EL as ${session.book1.title}
e. The title attribute of book1 can be accessed using EL as ${requestScope.book1.title}
Which of the following listeners will respond to events that a request comes to server or gets out of its scope?
Select one:
a. ServletResponseListener
b. ServletRequestListener
c. None of the others
d. ServletContextListener
d. ServletContextList
Which of the following statements about the standard actions is false?
Select one:
a. JSP standard actions are performed when a browser requests for a JSP page
b. Standard actions take the form of an XML tag with a name suffixed jsp
c. None of the others.
d. In standard action, the values in the attributes must be enclosed in double quotes
Which of the following statements about the standard actions are true?
Select one:
a. The Attributes in standard action can not distinguish between uppercase and lowercase
b. None of the others
c. JSP uses standard actions for calling the JavaBean methods
d. Standard actions take the form of an XML tag with a name suffixed jsp
Which classes or interfaces provide a getSession method?
Select one:
a. javax.servlet.http.HttpServletRequest
b. None of the others
c. javax.servlet.http.HttpServletResponse
d. javax.servlet.http.HttpSessionContext
e. javax.servlet.http.HttpSessionAttributeEvent
Given that session is a valid HttpSession object:
int max = session.getAttribute("MyReallyLongName");
Which is true?
Select one:
a. The HttpSession attribute name must NOT exceed eight characters.
b. Primitives CANNOT be stored in the HttpSession.
c. All of the others
d. The getAttribute method takes two arguments.
What is the scope of variables in EL?
Select one:
a. The scope of variables in EL has request Scope
b. All of the others
c. The scope of variables in EL has response Scope
d. The scope of variables in EL has page Scope
The following code comes from the only servlet in a web application, what is the outcome of accessing the doGet() method?
protected void doGet(HttpServleRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
try {
Thread.sleep(1500);
long now = (new Date()).getTime();
long interval = now -session.getLastAccessedTime();
if(interval <=1000) {
System.out.println("The time is smaller than 1000");
} else {
System.out.println("The time is larger than 1000");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Select one:
a. The time is larger than 1000
b. None of the others
c. The code is not correct
d. The time is smaller than 1000
When a specific request is processed, some servlets must be called and they need to access some common data. These common data should be put to dynamic variables in the ..... scope( select the most correct option). Select one:
a. None of the others.
b. session
c. application
d. request
Which of the following commands will successfully build a WAR file?
Select one:
a. jar -cvf myfile.war
b. jar -cfv myfile.war *.class
c. jar -war myfile.war .
d. jar -tvf myfile.war .
e. None of the others.
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:
10. private int itemId;
11. private String name;
12. private String description;
Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?
Select one:
a. updateItemID(int itemId)
b. mutateItemId(int itemId)
c. update(int itemId)
d. itemID(int itemId)
e. None of the others
A JSP page needs to perform some operations before servicing the first request. Where can this be done?
Select one:
a. within a method called jspInit
b. within the XML element
c. within the page directive of the JSP page
d. within a scriptlet at the top of the JSP page
Which object is passed as parameter in attributedAdded, attributedReplaced, and attributedRemoved method of the HttpSessionAttributeListener?
Select one:
a. HttpSessionEvent
b. HttpSession
c. None of the others
d. HttpSessionListenerEvent
e. HttpSessionBindingEvent
A JavaBeans component has the following field: private boolean enabled; Which of method declarations (following of JavaBeans standard) do access this field?
Select one or more:
a. public void setEnabled( boolean enabled) or public void isEnabled()
b. public void setEnabled( boolean enabled) or public boolean isEnabled()
c. public void setEnabled( boolean enabled) or public boolean getEnabled()
d. public boolean setEnabled( boolean enabled) or public boolean getEnabled()
Name the class that includes the getSession method that is used to get the HttpSession object
Select one:
a. None of the others
b. SessionConfig
c. SessionContext
d. HttpServletRequest
e. HttpServletResponse
Given a web application in which the request parameter productID contains a product identifier. Which EL expression evaluates the value of the productID?
Select one:
a. ${productID}
b. ${param.productID}
c. ${pageContext.request.productID}
d. None of the others
Which of the following statement relating to create static methods in EL is false?
Select one:
a. To access the function using EL, the function must be implemented as a static function in a java class
b. None of the others
c. The function need to be mapped with EL using a Tag Library Descriptor file
d. Only a single function should be defined in a single class
e. The static java methods can be called within the EL expression
Given a JSP code fragment
<% int a = Integer.parseInt("a"); %>
Choose the correct statement
Select one:
a. None of the others
b. The code is generated besides of _jspService method by JSP engine
c. The code is generated in jspInit method by JSP enginer
d. The code is generated in _jspService method by JSP engine
Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in the page being invoked?
Select one:
a. exception
b. request.exception
c. error
d. None of the others
e. throwable
With respect to JSP elements/actions. Which of the followings will insert text of source page to destination page before executing compilation?
Select one:
a. <jsp:insert>
b. <jsp:include>
c. <jsp:import>
d. <%@include>
e. None of the others
Which of the following represents the XML equivalent of this statement
<%@ include file="a.jsp"%> .
Select one correct statement.
Select one:
a. There is no XML equivalent of include directive.
b. None of the others
c. <jsp:include page="a.jsp"/>
d. <jsp:include file="a.jsp"/>
e. <jsp:directive.include file="a.jsp"/>
Which of the following methods can be used to add cookies to a servlet response?
Select one or more
a. HttpServletResponse.addCookie(Cookie cookie)
b. ServletResponse.addCookie(Cookie cookie)
c. ServletResponse.addHeader(String name, String value)
d. ServletResponse.addCookie(String contents)
f. HttpServletResponse.addCookie(String contents)
e. HttpServletResponse.addHeader(String name, String value)
What http method send by browser that gives the server what user data typed in the form?
a. delete
b. post
c. put
d. head
Which among the following components acts as a Controller in Struts 2 framework? Choose TWO answer.
a. Interceptors
b. FilterDispatcher
c. Configuration Manager
d. Action Mapper
Choose the option to make jsp page as an error page?
a. isErrorPage= "false"
b. Session= "false"
c. Session="true"
d. isError Page= "true"
Which following methods of HttpServlet class stores a resource under the request URL?
a, doput
b. doGet
c. doHead
d. do Delete
e. doTrace
f. do Post
What is NOT true about MVC Model 2 Architecture?
a. It is applied for little applications only, not for substantial applications
b. The model represents the application object or data.
c. The view represents the user interface component of the data model
d. The controller transmits the request, and selects a view for presenting data to the user.
Choose option is NOT types of filters in JSP
a. Authentication Filters
b. Data Compression Filters
c. Logging Filters
d. Time Controlling Filters
Which of the following is not a directive in JSP?
a. taglib
b. page
c. include
d. export
Which is the methods of generated Servlet??
a._jsplnit()
b._jspBuild()
c. _jspDestroy()
d. jspService()
Which statement is CORRECT about Struts 2?
a. Provides multiple tag libraries.
b. Uses JSTL.
c. Implements the Action interface.
d. Provide a single tag library.
How can you open a link in a new browser window?
a. <a href = "url" target="_blank">
b. <a href = "url" target ="open">
c. <a href = "url".new>
d. <a href = "url" target = "new">
_______interface with all methods for contacting a database?
a. Driver
b. Connection
c. ResultSet
d. Statement
Which implicit object is supported in jsp page to access pageScope, requestScope, sessionscope, applicationScope?
a. scope object
b. pageContext object
c. application object
d. context object
The class java.sql.Timestamp has its super class as
What does the FilterChain do?
a. It invokes the next filter in the chain, or if the calling filter is the last filter in the chain, it invokes the resource at the end of the
chain.
b. It invokes the first filter in the chain.
c. FilterChain is a function of the web.xml file
d. It does nothing.
To connect to the database, which JSTL tag do we use?
a. <sql:setConnection>
b. <sql:setDataSource>
c. <sql:setDatabase>
d. <sql.setDataBase>
Choose the default scope value of this declared bean:
<jsp:useBean id="userlist" class="model.UserList"> </jsp:useBean>
a. page
b. session
c. application
d. request
Suppose we write the Servlet "EditServlet" to delete the student based on "id" using delete(id) method and then display the list in "display.jsp". Please try to fill the Position 1, Position2 and Position3 to make the code complete.
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException ! response.setContentType("text'html;charset-UTF-8"} String action request.getParameter"action"): int id = Integer.parse un request.getParameter( "id")); SnuddewissList = new Studentism: ArrayList<Sulee list - new ArrayListo ; switch ("Position/ case "Delete":
list-sList.delere(id): session.sezittribute("list Student". "Position ):
request." Passions("display.jsp") forward request, response): break:
Consider the following HTML page code, which method can be used in subjectServlet to retrieve the value of "language" parameter, when the form is submitted. <body>
<form method="post" action="subjectServlet'>
<fieldset
legend Languages legend <input type="checkbox" name "Ingunge" value="javn" checked Java
<input type="checkbox" name="language" value"cs">C# <fieldsep
<input type"submit" value"SEND"> <form <body>
a. String[] languages = request.getParameterValues("language");
b. String languages = request.getParameterValues("language");
c. String java = request.getParameterValues("Java");
String cs = request.getParameterValues("C#");
d. String java = request.getParameterValues("java");
String cs = request.getParameterValues("cs");
n the request life cycle of Struts 2, which component invokes the Interceptors to apply the common functionalities?
a. Action Mapping
b. FilterDispatcher
c. ActionServlet
d. ActionInvocation
Fill in the blank to display the value of variable "number"
<%@page contentType="text/html" pageEncoding="UTF-8"%> 8 <%@ taglib prefix="c" uni="http://java.sun.com/jsp/jstl/core" %> 9 <!DOCTYPE html> 10 <html> 11 <head> 12 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title JSP Page<title> 14 Chead> 15 <body>
<h4>Hello JSTL</h4> 17 <c:set va="number" value="50"></c:set> 18 <p>Number: 19 <body> 20 <html>
a. <cout "${number}"> </cout>
b. <c value="${number}"></c:>
c. <c:out value="${number}"></cout>
d. <c:out value="number"></c.out>
Suppose we have the servlet "NewServlet" with the code to retrieve the value of parameter "gender" from the input.html protected void doPost(HttpServletRequest request. HttpServletResponse response)
throws ServletException. IOException Print Writer out = response.getWriter(); String gender = request.getParameter("gender"); if (gender.equals("male")) {
out.println("<p Gender: male-p>');
out.println("<p>Gender: female_p>");
Please choose the correct HTML code from the input.html for the "gender". Choose TWO:
a. Gender: <input type="password" name="gender" value="male" checked />Male
<input type="password" name="gender" value="female" />Female
b. Gender: <input type="radio" name="gender" value="male" checked />Male
<input type="radio" name="gender" value="female" />Female
c. Gender: <input type="text" name="gender" value="male" checked />
<input type="text" name="gender" value="female"/>
d. Gender: <input type="checkbox" name="gender" value="male" checked />Male
<input type="checkbox" name="gender" value="female" />Female
Please choose the right code to display information as bellows: Your chosen Books[quantity*price] are:
• Java [3 $10] = 30
• C# [5 $15] = 75
a.Your chosen Books[quantity*price) are:
<ul>
<li>Java [3 $10] = $[310]</li>
<li>C# [5 $15] = $[515]</li>
</ul>
b. Your chosen Books[quantity*price] are:
<ul>
<li> Java [3 $10] = ${310}</li>
<li>C# [5 $15] = ${515}</li> </ul>
c. Your chosen Books[quantity*price) are:
<ul>
<li>Java [3 $10] = {310}</li> <li>C# [5 $15] = {515}</li>
</ul>
d. Your chosen Books[quantity*price] are:
Java [3 $10] = ${310} C# [5 $15] = ${515)
What is the output of this code
<%@ page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="littp:/java.sun.com/jsp/jstl/core" %> <html><head>
<title>JSP Page</title> <head> <body>
<c:set var = "mrk" scope = "session" value="${8.3/2"/> <p-Your mark is: <cout value = Simark;" p <c:choose
<c:when test = "Smark <= 4;>
Need a retake for this subject. <c:when> <c:when test="S!mark > 4>
You Pass. <c:when> cc:choose <body><html>
a. You Pass.
b. Need a retake for this subject
c. Your mark is : 4.15
You Pass.
d. Your mark is: 4.00
Need a retake for this subject
А _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. session
b. request
c. cookie
d. response
You are creating a web form with this HTML: <html> <body>
<form action="login.jsp">
ID:<input type="text" name="id"><br> Name:<input type="text" name="name"X<br> Sinput type="submit" value="Login"> <form> <body> <html>
Which HTTP method is used when user press the "Login" button from the browser?
a. PUT
b. SEND
c. POST
d. GET
Given a web application in which the request parameter productID contains a product identifier. Which two El expressions evaluate the value of the product|D? (Choose two.)
a. ${paramValues.productID[0]}
b. ${param.productID}
c. ${productID}
d. ${params.productID[1]}
e.${params.productID}
f. ${paramValues.productID}
Which method we must override in the extend ActionSupport class to provide the implementation of validation in Struts 2?
a. checkParams() method
b. validate() method
c. input() method
d. validate() method for each input data
What object will represent the output stream for the JSP page?
a. response
b. writer
c. dispatch
d. out
Choose the correct way to use the JSTL Function Tags
a. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
b. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
c. <%@ taglib uri="http://java.sun.com/jsp/jstl/JSTLFunction Tags prefix="fn" %>
d. <%@ taglib uri="http://java.sun.com/jsp prefix="c" %>
Which interface is chosen to be extended by many tag handlers to create a custom tag?
a. Iteration Tag
b. BodyTagSupport
c. Tag
d. TagSupport
e. BodyTag
When destroy method() of servlet called?
a. When you remove the application from server
b. When you close the browser window
c. When the servlet is executed for the first time.
d. When the servlet is executed, it runs for the last time.
Which is true about TLD files?
a. TLD files may be placed in the META-INF directory of the WAR file.
b. TLD files can declare both Simple and Classic tags, but TLD files are NOT used to declare Tag files.
c. TLD files may be placed in any subdirectory of WEB-INF.
d. TLD files are used to configure JSP environment attributes, such as scripting-invalid.
Which components are required to use in JSP page after custom tag implemented?
a. Custom taglib class that extends from JSTL, tld file, declaration in context.xml file
b. Custom taglib class that extends from tagext, tags file, declaration in both web.xml and JSP files
c. None of the others
d. Custom taglib class that extends from tagext, tldfile, declaration in web deployment descriptor
What type of servlets use these methods such as doGeto, do Posto,doHead, doDelete(), doTrace()?
a. GenereicServlets
b. HttpServlets
c. ConfigServlets
d. RequestServlets
Which of the following is not a part of Struts architecture?
a. Actions
b. EJB
c. Value Stack / OGNL
d. Interceptors
HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a servlet?
a. response.addHeader( new Cookie( "username", "joe'))
b. request.addHeader( new Cookie( "username", "joe"))
c. response.addCookie( "username", "joe")
d. response.addCookie( new Cookie( "username", "joe"))
e. request.addCookie( "username", "joe")
Which of the following components is used by application to work with database server?
a. Connection
b. DriverManager
C. JDBC driver
d. Statement
Which statements about JDBC are NOT true?
a. JDBC provides a standard API for tool/database developers and makes it possible to write database applications using a pure Java
API.
b. The combination of Java and JDBC lets a programmer write it once and run it anywhere.
c. JDBC is a Java database system.
d. It consists of a set of classes and interfaces written in the Java
programming language.
FTP uses the services of_
?
a. UDP
b. PPP
C. IP
d. TCP
Which Design Pattern does Struts2 Framework apply?
a. MVC 2 Data Transfer Object as Controller
a. MVC 2 Data Transfer Object as Controller
c. MVC 2 using Filter as Controller
d. MVC 2 using DAO add Connect Database
Select the method to get form data into jsp?
a. request.getParameter()
b. request.getparametero
c. request.getStringo
d.getParametero
What is NOT true about RequestDispatcher in Servlet?
a. Uses include method, the control retains with the current Servlet and it just includes the processing done by the calling of Servlet or
the JSP
b. uses forward method, the control is transferred to the next Servlet or JSP the application is calling
c. provides the facility of dispatching the request to another resource it may be html, servlet or jsp
d. Uses getRequestDispatcher() method to return the forward/include object
In web application, these tasks such as authentication-blocking of requests, data compression, logging and auditing are performed by
a. servlet filter
b.servlet container
C. servlet context
d.servlet config
Verification of a login name and password is known as?
a. logging in
b. accessibility
c. configuration
d. authentication
Which of the following statement is not correct about HTTP method?
a. HTTP OPTIONS request for communication options available on the request/response chain
b. A POST request append data to the end of the URL.
c. A GET request append data to the end of the URL.
d. HTTP DELETE method request for the Server to delete the resource
How many Tags are provided by JSTL?
a. 6 (Core tags, Function tags, Formatting tags, XML tags, SQL tags, Math tags)
b. 4 (Core tags, Function tags, XML tags, SQL tags)
c. 3 (Core tags, XML tags, SQL tags)
d. 5 (Core tags, Function tags, Formatting tags, XML tags, SQL tags)
Which method is used to perform DML statements in JDBC?
a. execute()
b. executeQuery()
c. executeUpdate()
d. executeResult()
____ are small pieces of information that are deposited on the client by the server.
a. Cookie
b. Directive
c. Session
d. Scriptlet
Choose the corect JSTL statement to check whether the emptyCart is empty or not?
a. <c:if var="${emptyCart == empty}">
<p> Your cart is empty.</p> </c:if>
b. <c:if test="${emptyCart == null)">
<p>Your cart is empty.</p>
</c.if>
C: <c:if var="${emptyCart == null;">
<p>Your cart is empty.</p>
</c:jf>
d. <if test="${emptyCart == null}">
<p>Your cart is empty.</p> </if>
Which of the following methods can be used to add cookies to a servlet response?
Select one
a. ServletResponse.addCookie( Cookie cookie)
b.ServletResponse.addHeader( String name, String value)
c. HttpServletResponse.addCookie( String contents)
d. ServletResponse.addCookie( String contents)
e. HttpServletResponse.addCookie( Cookie cookie)
___ includes a static file in a JSP file, parsing the file's JSP elements (choose the most correct one)
Select one:
a. import directive
@
b.include directive
c. <jsp:useBean>
d. <jsp:forward>
e. <jsp:include>
How does container initialize Servlet Object at deploy time?
a. The servlet does not need to be declared
b. The servlet must be declared into web deployment descriptor with servlet tag
c. The servlet must be declared into web deployment descriptor with servlet-mapping tag
d. The servlet must be declared into context deployment descriptor with servlet tag
Which is not method of the request object - an instance of HttpServletRequest
a. getSession
b.getParameterValues(name)
c. send Redirect(url)
d.getCookies
You can use the test attribute to specify the Boolean condition for a when tag in JSTL.
Select one:
T
F
Which JSTL tag sets a parameter in an SQL statement to the specified value?
Select one:
a. <sql:setparameter>
b. <sql:parameter>
c. <sql:setparam>
d. <sql:param>
Which of the following method should not be overriden in JSP?
a. jsplnit()
b. jsp Destroy()
c. jspService()
d. doGet() - dopost()
Which one of the following must be done before authorization takes place?
Select one:
a. Auditing
b. User authentication
c. Data compression
d. Data encryption
e. Data validation
Which method we must override in the extend Action Support class to provide the implementation of validation in Struts 2?
a. checkParams() method
b. validate() method
c. input() method
d. validate() method for each input data
a _____ subscription to a topic means that a JMS subscriber receives all messages, even if the subscriber is inactive.
Select one:
a. nondurable
b. permanent
c. durable
d. temporary
What is the expired time of the cookie if we set the value of time = 0.5
19 public static Cookie add(String name, String value, int time, HttpServletResponse response) { 20 Cookie cookie = new Cookie(name, value);
cookie.setMaxAge(60 60 time); cookie.setPath("/"); response.addCookie(cookie);
return cookie; 26 }
a. 30 minutes
b. 60 minutes
c. 1.800 minutes
d. 45 minutes
In a web application, Where filters are defined?
a. Filters are defined in the ServletRequest
b. Filters are defined in the jsp pages.
c. Filters are defined in the deployment descriptor file web.xml
d. Filters are defined in the ServletContext
Which tag is used to insert java source code in JSP?
a. Application tag
b. Declaration Tag
C. Scriptlet tag
d. Expression tag
In order to get the value from the request parameter, please choose the correct code
a. String the Studentld = request.getStudent("studentld");
b. String the Studentld = request.getParameter("studentld");
c. String the Studentld = request.getID("studentld");
d. String the Studentld = getParameter("studentld");
When destroy method of a filter is called?
a. called after the filter has executed doFilter method
b. called after the filter has executed
c. called only once at the end of the life cycle of a filter
d. called only once at the begining of the life cycle of a filter
In the web deployment descriptor, the tag of tag is used for
a. accessing or calling the servlet instance
b. applying the security on the servlet instance
c. applying the filter on the servlet instance
d. informing server about the location of servlet in web application directory
Which of the following is not component of MVC architecture?
a. XML
b. View
c. Controller
d. Model
Which of the following is not a valid type of statement in JDBC?
a. Statement
b. PreparedStatement
c. CallableStatement
d. QueryStatement
DriverManager.getConnection What is the order of parameters included
a. URL where server runs, UserID, Password
b. URL where server runs; Password, UserID
c. Password, URL where server runs, UserID
d. User ID, Password, URL where server runs
When compiling a project in java web, which of the following error code indicates an error inside the HTTP server which prevents it from fulfilling the request?
a. 400
b. 403
c. 404
d. 500
Which HTTP method is used when sending request from the browser?
a. POST
b. PUT
C. SET
d. GET
JSP ___ let you insert arbitrary code into the servlet's _JspService() method.
a. scriptlets
b. declarations
c. comment
d. custom tag
Please choose to correct statement to include a header.jsp page in to an jsp page?
a. <jsp:includes page="/includes/header.jsp" />
b. <jsp:include page="/includes/header.jsp" />
c. <include page="/includes/header.jsp" />
d. < page="/includes/header.jsp" />
Suppose we have the model class Student {private int id;}, now to set up a link for "Update" Action in jsp page and then send the Id value of student object to the Servlet StudentControllerServlet.
E
F
Tran
Van
First Name
Last Name
Email
Action TEO
Nguyen
a@b.c
Update Delete n@f.h
Update Delete cag.t
Undate Delete vad.c
Update Delete Please choose the the correct code in the space <c:url var="tempLink" value="StudentControllerServlet">
<c:param name="command" value="UPDATE"></c:param> <c:param name="studentId" value="
"X</c:param> </c:url>
In JSTL, which type of Java conditional statement is the tag similar to?
a. if
b. foreach
C. switch
d. when
Please choose the option in the blank.
when the web developers want to include the value of command and studentID without being seen or modified by users when a form is submitted?
7 <%@page contentType="text/html" pageEncoding="UTF-8"%> 8 <!DOCTYPE html> 9 <html> 10 <head> 11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 12 <title>JSP Page</title> 13 <head> 14 <body>
<form action="StudentControllerServlet" method="GET">
<input type=
name="command" value="UPDATE"> <input type=
name="studentId" value="${THE STUDENT.id}"> Name:<input type="text" name="firstName" value='S THE STUDENT.firstNamex /td>
<input type="submit" value="UPDATE" class="save" />
</form> 21 </body> 22 </html>
a. "hidden" & "text"
b. "submit" & "text"
c. "hidden" & "hidden
d. "submit" & "submit"
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 = "xml">
b. <%@page contentType = "text/xml">
c. <%@page contentType = "html/xml">
d. <%@page contentType = "text/html">
Which attribute of @page define an jsp page to be an error page?
a. "true"
b. "false"
c. isErrorPage
d. session.setAttribute("true")
e. session.setAttribute("false")
f. isError Page
When a JSP page is translated, what is it turned into?
a. Servlet
b. Midlet
c. Application
d. Applet
Suppose we have the model Calculator Model class, please fill in the blank to add the value of model to the object request.
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException String numl = request.getParameter("num!"); String num2 = request.getParameter("num2"); String action=request.getParameter("action"); Calculator Model model = new Calculator Mode/(Float.parseFloat(numl).
Float.parseFloat(num2), action);
("RS", model); request.getRequestDispatcher("result.jsp").include(request, response);
a. request.setValueOf
b. request.getRequest Pispatcher
c. request.setAttribute
d. request.getAttribute
Which of the following listeners will respond to events that a request comes to server or gets out of its scope?
a. ServletRequestListener
b.ServletRequestAttributeListener
c. ServletContextListener
d. ServletResponseListener
Which of these characteristics of a filter is true?
a. A logging and auditing filter allow users to log in to a Web application
b. A filter is an object that is invoked at the preprocessing and postprocessing of a request.
c. Filters used to store session
d. An authentication filter tracks the activities of users of a Web application
Choose the statement that best describes the relationship between JSP and servlets:
a. JSP and servlets are unrelated technologies.
b.Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The
two technologies are not useful in combination.
c. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.
d. JSPs are built on servlet semantics and all JSPs are translaled to servlets for runtime usage.
The value of session timeout in web deployment descriptor using the unit of ......
a. Second
b. Hour
c. Minute
d. Millisecond
What is the purpose of this code? 72 protected void do Post(HttpServletRequest request, HttpServletResponse response) 73 throws ServletException, IOException {
String username = request.getParameter("username"); String password = request.getParameter("password"); if(username.equals("admin") && password.equals("abc123')) {
RequestDispatcher rd = request.getRequestDispatcher("admin/index.jsp");
rd.forward(request, resonse);79}}
a. Checking whether the username equals "admin" and password equals "abc123" or not. If yes, forward the requests to admin
index.jsp
b. Setting the value of username = "admin" and password = "abc123
c. Checking whether the username equals "admin" and password equals "abc123" or not
d. Checking whether the username equals "admin" and password equals "abc123" or not. If yes, forward the requests to index.jsp
Please correct the code as bellowing, supposed that the parameters in sql has String value.
public void addStudent(Student student) {
String sql =" INSERT INTO studentTBL(first name, last_name, email)\n"
+ "VALUES (?, ?, ?):: ComectDB db = ComectDB.getInstance(); Connection con; try {
con = db.openConnection(); PreparedStatement statement = con.prepare Statement(sql):
(1, student.getFirstName(): (2. student.getLastName();
(3, student.getEmail(); statement.execute(; statement.close(:
con.close(); } catch (Exception ex)
Logger.getLogger(StudentDAO.class.getName().log(Level.SEVERE, null, ex);
a. statement.setStringo
b. statement.setTypeCastString
c. statement.setString
d. statement.setValueString
What is the out put of this code?
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html>
<head>
<title>Tag Example</title> </head> <body>
<c:forEach var="product" begin="0" end="10" step="2">
${product} </c:forEach> </body> </html>
a. var="item" begin="0" end="10" step="2"
b.${product}
c. 0246 8 10
d. 0 1 2 3 4 5 6 7 8 9 10
Which method is used to perform DML statements in JDBC?
a. executeResulto
b.execute()
c. executeQueryo
d. executeUpdate()
When compiling a project in java web, which of the following error codes is associated with the "Resource not found" message?
a. 400
b. 403
c. 500
d. 404
What is the purpose of this code?
7<%@page contentType="text/html" pageEncoding="UTF-8"%> 8 <!DOCTYPE html> 9 <html> 10 <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <jsp:useBean id="user" class="model. User" scope="session"> </jsp:useBean> <jsp:setProperty name="user" property="*"/> </head> <body>
11<hr> 19 First Name: <jsp:getProperty name="user" property="firstName"></jsp:getProperty> 20 </br> 21 Last Name: <jsp:getProperty name="user" property="lastName"></jsp:getProperty> 22 </body> 23 </html>
a. Set properties of a bean object user
b. Delete properties of a bean object user
c. Update properties of a bean object user
d. Get properties of a bean object user
