wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PRJ103_PART2

Total questions: 130

Worksheet time: 1hrs 8mins

Name
Class
Date
1.

Which sub-element is used to define a logical name of servlet in web deployment descriptor?
Select one:

a)

a. All of the other choices

b)

b. url-pattern

c)

c. servlet-name

d)

d. servlet-class

2.

Which of these statements is true about the Filter implementation?
Select one:

a)

a. The doFilter(request, response) method examines the request or response headers and also customises them as per requirement

b)

b. All of the others

c)

c. The Filter Interface must be implemented to create a filter class

d)

d. The init() method is called by the servlet container many times to initialise the filter

3.

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)

a. <c:set var="cart" value="${sessionScope[].cart}"/>

b)

b. <c:set var="cart" value="${sessionContext.cart}"/>

c)

c. <c:set var="cart" value="${session.cart}"/>

d)

d. None of the others.

e)

e. <c:set var="cart" value="${sessionScope.cart}"/>

4.

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)

a. ${productID}

b)

b. None of the others

c)

c. ${pageContext.request.productID}

d)

d. ${param.productID}

5.

Which JSTL code snippet can be used to import content from another web resource?
Select one:

a)

a. <c:import url="foo.jsp"/>

b)

b. <c:import page="foo.jsp"/>

c)

c. All of the others

d)

d. <c:include url="foo.jsp"/>

6.

Which of the following statement is true about the Session Listeners?
Select one:

a)

a. HttpSessionBindingListener must not register in web deployment descriptor

b)

b. HttpSessionBindingListener must register in web deployment descriptor

c)

c. None of the others

d)

d. ServletContextListener must not register in web deployment descriptor

e)

e. ServletContextAttributeListener must not register in web deployment descriptor

7.

Which of the following statement relating to Hidden form fields is incorrect?
Select one:

a)

a. The session information can be extracted by the application by searching for Hidden form fields

b)

b. Hidden form fields send information from one HTML page to another thereby maintaining the connection between the two pages

c)

c. All of the others

d)

d. The servlets or JSP page read the Hidden form fields using response.sendParameter

8.

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)

a. None of the others

b)

b. Error

c)

c. excption

d)

d. errorPage

e)

e. isErrorPage

9.

Which of the following is a incorrect syntax of the getAttribute() method?
Select one or more:

a)

a. public Object getAttribute(String name)

b)

b. public Name getAttribute(String name)

c)

c. public Object getAttribute(String name, Object obj)

d)

d. public Object getAttribute(Object obj)

10.

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)

a. The request is applied the FilterF, FilterE in sequence

b)

b. None of the others

c)

c. The response is applied the FilterF, FilterE in sequence

d)

d. The request is applied the FilterE, FilterF in sequence

11.

What time is recorded as the last accessed time for an HttpSession object?
Select one:

a)

a. The last time an attribute was bound to or unbound from the HttpSession object.

b)

b. None of the others.

c)

c. The last time a method was executed against an HttpSession object.

d)

d. The last time the client sent a request associated with the session.

12.

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)

a. ${true or false}

b)

b. ${requestScope[foo][0] > 500}

c)

c. All of the others

d)

d. ${requestScope['foo'][1] = 420}

13.

Which element is the parent of the <filter> tag in the web application deployment descriptor?
Select one:

a)

a. <filter-list>

b)

b. None of the others.

c)

c. <filters>

d)

d. <web-app>

e)

e. <servlet>

14.

Which of the following is a correct syntax of the getAttribute() method of web development context?
Select one:

a)

a. public Object getAttribute(String name, Object obj)

b)

b. public Object getAttribute(String name)

c)

c. public Name getAttribute(String name)

d)

d. public Object getAttribute(Object obj)

15.

Which of the following constitute valid ways of importing Java classes into JSP page source?
Select one:

a)

a. <%! import java.util.*; %>

b)

b. <%@ import java.util.* %>

c)

c. <%@ page import="java.util.*" %>

d)

d. None of the others.

16.

Which of the following are false statements about standard action attributes?
Select one or more:

a)

a. If both are used, class and type attributes must have different values.

b)

b. The reference variable used for a bean doesn't always have the same type as the bean object it refers to.

c)

c. If the type attribute is used, the class attribute must be presented.

d)

d. If both are used, class and type attributes must have the same value.

e)

e. If class and type attributes are presented, the class attribute must match the object type of your bean.

17.

What will be the output of the code snippet ${"2" + "2"}?
Select one:

a)

a. 22

b)

b. None of the others.

c)

c. 4

d)

d. 2+2

18.

The JSP element <%!.....%> will be replaced by the tag .... in the JSP document.
Select one:

a)

The JSP element <%!.....%> will be replaced by the tag .... in the JSP document.
Select one:

b)

b. <jsp:method>></jsp:method>

c)

c. All of the others.

d)

d. <jsp:declaration> ... </jsp:declaration>

19.

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)

a. An error is generated because the value attribute of setAttribute is not defined

b)

b. None of the others

c)

c. The color attribute is assigned a value null

d)

d. The color attribute is assigned a value ""

e)

e. If there is a non-null request parameter with name color, then its value is assigned to color property of Java Bean fruit

20.

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)

a. The title attribute of book1 can be accessed using EL as ${sessionScope.book1.title}

b)

b. None of the others

c)

c. The title attribute of book1 can be accessed using EL as ${sessionScope.book1.getTitle}

d)

d. The title attribute of book1 can be accessed using EL as ${session.book1.title}

e)

e. The title attribute of book1 can be accessed using EL as ${requestScope.book1.title}

21.

Which of the following listeners will respond to events that a request comes to server or gets out of its scope?
Select one:

a)

a. ServletResponseListener

b)

b. ServletRequestListener

c)

c. None of the others

d)

d. ServletContextListener

e)

d. ServletContextList

22.

Which of the following statements about the standard actions is false?
Select one:

a)

a. JSP standard actions are performed when a browser requests for a JSP page

b)

b. Standard actions take the form of an XML tag with a name suffixed jsp

c)

c. None of the others.

d)

d. In standard action, the values in the attributes must be enclosed in double quotes

23.

Which of the following statements about the standard actions are true?
Select one:

a)

a. The Attributes in standard action can not distinguish between uppercase and lowercase

b)

b. None of the others

c)

c. JSP uses standard actions for calling the JavaBean methods

d)

d. Standard actions take the form of an XML tag with a name suffixed jsp

24.

Which classes or interfaces provide a getSession method?
Select one:

a)

a. javax.servlet.http.HttpServletRequest

b)

b. None of the others

c)

c. javax.servlet.http.HttpServletResponse

d)

d. javax.servlet.http.HttpSessionContext

e)

e. javax.servlet.http.HttpSessionAttributeEvent

25.

Given that session is a valid HttpSession object:
int max = session.getAttribute("MyReallyLongName");
Which is true?
Select one:

a)

a. The HttpSession attribute name must NOT exceed eight characters.

b)

b. Primitives CANNOT be stored in the HttpSession.

c)

c. All of the others

d)

d. The getAttribute method takes two arguments.

26.

What is the scope of variables in EL?
Select one:

a)

a. The scope of variables in EL has request Scope

b)

b. All of the others

c)

c. The scope of variables in EL has response Scope

d)

d. The scope of variables in EL has page Scope

27.

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)

a. The time is larger than 1000

b)

b. None of the others

c)

c. The code is not correct

d)

d. The time is smaller than 1000

28.

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)

a. None of the others.

b)

b. session

c)

c. application

d)

d. request

29.

Which of the following commands will successfully build a WAR file?
Select one:

a)

a. jar -cvf myfile.war

b)

b. jar -cfv myfile.war *.class

c)

c. jar -war myfile.war .

d)

d. jar -tvf myfile.war .

e)

e. None of the others.

30.

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)

a. updateItemID(int itemId)

b)

b. mutateItemId(int itemId)

c)

c. update(int itemId)

d)

d. itemID(int itemId)

e)

e. None of the others

31.

A JSP page needs to perform some operations before servicing the first request. Where can this be done?
Select one:

a)

a. within a method called jspInit

b)

b. within the XML element

c)

c. within the page directive of the JSP page

d)

d. within a scriptlet at the top of the JSP page

32.

Which object is passed as parameter in attributedAdded, attributedReplaced, and attributedRemoved method of the HttpSessionAttributeListener?
Select one:

a)

a. HttpSessionEvent

b)

b. HttpSession

c)

c. None of the others

d)

d. HttpSessionListenerEvent

e)

e. HttpSessionBindingEvent

33.

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)

a. public void setEnabled( boolean enabled) or public void isEnabled()

b)

b. public void setEnabled( boolean enabled) or public boolean isEnabled()

c)

c. public void setEnabled( boolean enabled) or public boolean getEnabled()

d)

d. public boolean setEnabled( boolean enabled) or public boolean getEnabled()

34.

Name the class that includes the getSession method that is used to get the HttpSession object
Select one:

a)

a. None of the others

b)

b. SessionConfig

c)

c. SessionContext

d)

d. HttpServletRequest

e)

e. HttpServletResponse

35.

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)

a. ${productID}

b)

b. ${param.productID}

c)

c. ${pageContext.request.productID}

d)

d. None of the others

36.

Which of the following statement relating to create static methods in EL is false?
Select one:

a)

a. To access the function using EL, the function must be implemented as a static function in a java class

b)

b. None of the others

c)

c. The function need to be mapped with EL using a Tag Library Descriptor file

d)

d. Only a single function should be defined in a single class

e)

e. The static java methods can be called within the EL expression

37.

Given a JSP code fragment
<% int a = Integer.parseInt("a"); %>
Choose the correct statement
Select one:

a)

a. None of the others

b)

b. The code is generated besides of _jspService method by JSP engine

c)

c. The code is generated in jspInit method by JSP enginer

d)

d. The code is generated in _jspService method by JSP engine

38.

Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in the page being invoked?
Select one:

a)

a. exception

b)

b. request.exception

c)

c. error

d)

d. None of the others

e)

e. throwable

39.

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)

a. <jsp:insert>

b)

b. <jsp:include>

c)

c. <jsp:import>

d)

d. <%@include>

e)

e. None of the others

40.

Which of the following represents the XML equivalent of this statement
<%@ include file="a.jsp"%> .
Select one correct statement.
Select one:

a)

a. There is no XML equivalent of include directive.

b)

b. None of the others

c)

c. <jsp:include page="a.jsp"/>

d)

d. <jsp:include file="a.jsp"/>

e)

e. <jsp:directive.include file="a.jsp"/>

41.

Which of the following methods can be used to add cookies to a servlet response?
Select one or more

a)

a. HttpServletResponse.addCookie(Cookie cookie)

b)

b. ServletResponse.addCookie(Cookie cookie)

c)

c. ServletResponse.addHeader(String name, String value)

d)

d. ServletResponse.addCookie(String contents)

f. HttpServletResponse.addCookie(String contents)

e)

e. HttpServletResponse.addHeader(String name, String value)

42.

What http method send by browser that gives the server what user data typed in the form?

a)

a. delete

b)

b. post

c)

c. put

d)

d. head

43.

Which among the following components acts as a Controller in Struts 2 framework? Choose TWO answer.

a)

a. Interceptors

b)

b. FilterDispatcher

c)

c. Configuration Manager

d)

d. Action Mapper

44.

Choose the option to make jsp page as an error page?

a)

a. isErrorPage= "false"

b)

b. Session= "false"

c)

c. Session="true"

d)

d. isError Page= "true"

45.

Which following methods of HttpServlet class stores a resource under the request URL?

a)

a, doput

b)

b. doGet

c)

c. doHead

d)

d. do Delete

e)

e. doTrace
f. do Post

46.

What is NOT true about MVC Model 2 Architecture?

a)

a. It is applied for little applications only, not for substantial applications

b)

b. The model represents the application object or data.

c)

c. The view represents the user interface component of the data model

d)

d. The controller transmits the request, and selects a view for presenting data to the user.

47.

Choose option is NOT types of filters in JSP

a)

a. Authentication Filters

b)

b. Data Compression Filters

c)

c. Logging Filters

d)

d. Time Controlling Filters

48.

Which of the following is not a directive in JSP?

a)

a. taglib

b)

b. page

c)

c. include

d)

d. export

49.

Which is the methods of generated Servlet??

a)

a._jsplnit()

b)

b._jspBuild()

c)

c. _jspDestroy()

d)

d. jspService()

50.

Which statement is CORRECT about Struts 2?

a)

a. Provides multiple tag libraries.

b)

b. Uses JSTL.

c)

c. Implements the Action interface.

d)

d. Provide a single tag library.

51.

How can you open a link in a new browser window?

a)

a. <a href = "url" target="_blank">

b)

b. <a href = "url" target ="open">

c)

c. <a href = "url".new>

d)

d. <a href = "url" target = "new">

52.

_______interface with all methods for contacting a database?

a)

a. Driver

b)

b. Connection

c)

c. ResultSet

d)

d. Statement

53.

Which implicit object is supported in jsp page to access pageScope, requestScope, sessionscope, applicationScope?

a)

a. scope object

b)

b. pageContext object

c)

c. application object

d)

d. context object

54.

The class java.sql.Timestamp has its super class as

b)

b. java.util.Time

d)

d. java.sql.Time

55.

What does the FilterChain do?

a)

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)

b. It invokes the first filter in the chain.

c)

c. FilterChain is a function of the web.xml file

d)

d. It does nothing.

56.

To connect to the database, which JSTL tag do we use?

a)

a. <sql:setConnection>

b)

b. <sql:setDataSource>

c)

c. <sql:setDatabase>

d)

d. <sql.setDataBase>

57.

Choose the default scope value of this declared bean:
<jsp:useBean id="userlist" class="model.UserList"> </jsp:useBean>

a)

a. page

b)

b. session

c)

c. application

d)

d. request

58.

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:

a)

a. "action", "list", getRequest
b.id, listStudent, getRequestDispatcher
c.id, listStudent, getRequest
d. action, list, getRequestDispatcher

b)

b.id, listStudent, getRequestDispatcher

c)

c.id, listStudent, getRequest

d)

d. action, list, getRequestDispatcher

59.

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)

a. String[] languages = request.getParameterValues("language");

b)

b. String languages = request.getParameterValues("language");

c)

c. String java = request.getParameterValues("Java");
String cs = request.getParameterValues("C#");

d)

d. String java = request.getParameterValues("java");
String cs = request.getParameterValues("cs");

60.

n the request life cycle of Struts 2, which component invokes the Interceptors to apply the common functionalities?

a)

a. Action Mapping

b)

b. FilterDispatcher

c)

c. ActionServlet

d)

d. ActionInvocation

61.

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)

a. <cout "${number}"> </cout>

b)

b. <c value="${number}"></c:>

c)

c. <c:out value="${number}"></cout>

d)

d. <c:out value="number"></c.out>

62.

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)

a. Gender: <input type="password" name="gender" value="male" checked />Male
<input type="password" name="gender" value="female" />Female

b)

b. Gender: <input type="radio" name="gender" value="male" checked />Male
<input type="radio" name="gender" value="female" />Female

c)

c. Gender: <input type="text" name="gender" value="male" checked />
<input type="text" name="gender" value="female"/>

d)

d. Gender: <input type="checkbox" name="gender" value="male" checked />Male
<input type="checkbox" name="gender" value="female" />Female

63.

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)

a.Your chosen Books[quantity*price) are:
<ul>
<li>Java [3 $10] = $[310]</li>
<li>C# [5 $15] = $[515]</li>
</ul>

b)

b. Your chosen Books[quantity*price] are:
<ul>
<li> Java [3 $10] = ${310}</li>
<li>C# [5 $15] = ${515}</li> </ul>

c)

c. Your chosen Books[quantity*price) are:
<ul>
<li>Java [3 $10] = {310}</li> <li>C# [5 $15] = {515}</li>
</ul>

d)

d. Your chosen Books[quantity*price] are:
Java [3 $10] = ${310} C# [5 $15] = ${515)

64.

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)

a. You Pass.

b)

b. Need a retake for this subject

c)

c. Your mark is : 4.15
You Pass.

d)

d. Your mark is: 4.00
Need a retake for this subject

65.

А _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)

a. session

b)

b. request

c)

c. cookie

d)

d. response

66.

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)

a. PUT

b)

b. SEND

c)

c. POST

d)

d. GET

67.

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)

a. ${paramValues.productID[0]}

b)

b. ${param.productID}

c)

c. ${productID}

d)

d. ${params.productID[1]}

e)

e.${params.productID}
f. ${paramValues.productID}

68.

Which method we must override in the extend ActionSupport class to provide the implementation of validation in Struts 2?

a)

a. checkParams() method

b)

b. validate() method

c)

c. input() method

d)

d. validate() method for each input data

69.

What object will represent the output stream for the JSP page?

a)

a. response

b)

b. writer

c)

c. dispatch

d)

d. out

70.

Choose the correct way to use the JSTL Function Tags

a)

a. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

b)

b. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

c)

c. <%@ taglib uri="http://java.sun.com/jsp/jstl/JSTLFunction Tags prefix="fn" %>

d)

d. <%@ taglib uri="http://java.sun.com/jsp prefix="c" %>

71.

Which interface is chosen to be extended by many tag handlers to create a custom tag?

a)

a. Iteration Tag

b)

b. BodyTagSupport

c)

c. Tag

d)

d. TagSupport

e)

e. BodyTag

72.

When destroy method() of servlet called?

a)

a. When you remove the application from server

b)

b. When you close the browser window

c)

c. When the servlet is executed for the first time.

d)

d. When the servlet is executed, it runs for the last time.

73.

Which is true about TLD files?

a)

a. TLD files may be placed in the META-INF directory of the WAR file.

b)

b. TLD files can declare both Simple and Classic tags, but TLD files are NOT used to declare Tag files.

c)

c. TLD files may be placed in any subdirectory of WEB-INF.

d)

d. TLD files are used to configure JSP environment attributes, such as scripting-invalid.

74.

Which components are required to use in JSP page after custom tag implemented?

a)

a. Custom taglib class that extends from JSTL, tld file, declaration in context.xml file

b)

b. Custom taglib class that extends from tagext, tags file, declaration in both web.xml and JSP files

c)

c. None of the others

d)

d. Custom taglib class that extends from tagext, tldfile, declaration in web deployment descriptor

75.

What type of servlets use these methods such as doGeto, do Posto,doHead, doDelete(), doTrace()?

a)

a. GenereicServlets

b)

b. HttpServlets

c)

c. ConfigServlets

d)

d. RequestServlets

76.

Which of the following is not a part of Struts architecture?

a)

a. Actions

b)

b. EJB

c)

c. Value Stack / OGNL

d)

d. Interceptors

77.

HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a servlet?

a)

a. response.addHeader( new Cookie( "username", "joe'))

b)

b. request.addHeader( new Cookie( "username", "joe"))

c)

c. response.addCookie( "username", "joe")

d)

d. response.addCookie( new Cookie( "username", "joe"))

e)

e. request.addCookie( "username", "joe")

78.

Which of the following components is used by application to work with database server?

a)

a. Connection

b)

b. DriverManager

c)

C. JDBC driver

d)

d. Statement

79.

Which statements about JDBC are NOT true?

a)

a. JDBC provides a standard API for tool/database developers and makes it possible to write database applications using a pure Java
API.

b)

b. The combination of Java and JDBC lets a programmer write it once and run it anywhere.

c)

c. JDBC is a Java database system.

d)

d. It consists of a set of classes and interfaces written in the Java
programming language.

80.

FTP uses the services of_
?

a)

a. UDP

b)

b. PPP

c)

C. IP

d)

d. TCP

81.

Which Design Pattern does Struts2 Framework apply?

a)

a. MVC 2 Data Transfer Object as Controller

b)

a. MVC 2 Data Transfer Object as Controller

c)

c. MVC 2 using Filter as Controller

d)

d. MVC 2 using DAO add Connect Database

82.

Select the method to get form data into jsp?

a)

a. request.getParameter()

b)

b. request.getparametero

c)

c. request.getStringo

d)

d.getParametero

83.

What is NOT true about RequestDispatcher in Servlet?

a)

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)

b. uses forward method, the control is transferred to the next Servlet or JSP the application is calling

c)

c. provides the facility of dispatching the request to another resource it may be html, servlet or jsp

d)

d. Uses getRequestDispatcher() method to return the forward/include object

84.

In web application, these tasks such as authentication-blocking of requests, data compression, logging and auditing are performed by

a)

a. servlet filter

b)

b.servlet container

c)

C. servlet context

d)

d.servlet config

85.

Verification of a login name and password is known as?

a)

a. logging in

b)

b. accessibility

c)

c. configuration

d)

d. authentication

86.

Which of the following statement is not correct about HTTP method?

a)

a. HTTP OPTIONS request for communication options available on the request/response chain

b)

b. A POST request append data to the end of the URL.

c)

c. A GET request append data to the end of the URL.

d)

d. HTTP DELETE method request for the Server to delete the resource

87.

How many Tags are provided by JSTL?

a)

a. 6 (Core tags, Function tags, Formatting tags, XML tags, SQL tags, Math tags)

b)

b. 4 (Core tags, Function tags, XML tags, SQL tags)

c)

c. 3 (Core tags, XML tags, SQL tags)

d)

d. 5 (Core tags, Function tags, Formatting tags, XML tags, SQL tags)

88.

Which method is used to perform DML statements in JDBC?

a)

a. execute()

b)

b. executeQuery()

c)

c. executeUpdate()

d)

d. executeResult()

89.

____ are small pieces of information that are deposited on the client by the server.

a)

a. Cookie

b)

b. Directive

c)

c. Session

d)

d. Scriptlet

90.

Choose the corect JSTL statement to check whether the emptyCart is empty or not?

a)

a. <c:if var="${emptyCart == empty}">
<p> Your cart is empty.</p> </c:if>

b)

b. <c:if test="${emptyCart == null)">
<p>Your cart is empty.</p>
</c.if>

c)

C: <c:if var="${emptyCart == null;">
<p>Your cart is empty.</p>
</c:jf>

d)

d. <if test="${emptyCart == null}">
<p>Your cart is empty.</p> </if>

91.

Which of the following methods can be used to add cookies to a servlet response?
Select one

a)

a. ServletResponse.addCookie( Cookie cookie)

b)

b.ServletResponse.addHeader( String name, String value)

c)

c. HttpServletResponse.addCookie( String contents)

d)

d. ServletResponse.addCookie( String contents)

e)

e. HttpServletResponse.addCookie( Cookie cookie)

92.

___ includes a static file in a JSP file, parsing the file's JSP elements (choose the most correct one)
Select one:

a)

a. import directive
@

b)

b.include directive

c)

c. <jsp:useBean>

d)

d. <jsp:forward>

e)

e. <jsp:include>

93.

How does container initialize Servlet Object at deploy time?

a)

a. The servlet does not need to be declared

b)

b. The servlet must be declared into web deployment descriptor with servlet tag

c)

c. The servlet must be declared into web deployment descriptor with servlet-mapping tag

d)

d. The servlet must be declared into context deployment descriptor with servlet tag

94.

Which is not method of the request object - an instance of HttpServletRequest

a)

a. getSession

b)

b.getParameterValues(name)

c)

c. send Redirect(url)

d)

d.getCookies

95.

You can use the test attribute to specify the Boolean condition for a when tag in JSTL.
Select one:

a)

T

b)

F

96.

Which JSTL tag sets a parameter in an SQL statement to the specified value?
Select one:

a)

a. <sql:setparameter>

b)

b. <sql:parameter>

c)

c. <sql:setparam>

d)

d. <sql:param>

97.

Which of the following method should not be overriden in JSP?

a)

a. jsplnit()

b)

b. jsp Destroy()

c)

c. jspService()

d)

d. doGet() - dopost()

98.

Which one of the following must be done before authorization takes place?
Select one:

a)

a. Auditing

b)

b. User authentication

c)

c. Data compression

d)

d. Data encryption

e)

e. Data validation

99.

Which method we must override in the extend Action Support class to provide the implementation of validation in Struts 2?

a)

a. checkParams() method

b)

b. validate() method

c)

c. input() method

d)

d. validate() method for each input data

100.

a _____ subscription to a topic means that a JMS subscriber receives all messages, even if the subscriber is inactive.
Select one:

a)

a. nondurable

b)

b. permanent

c)

c. durable

d)

d. temporary

101.

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)

a. 30 minutes

b)

b. 60 minutes

c)

c. 1.800 minutes

d)

d. 45 minutes

102.

In a web application, Where filters are defined?

a)

a. Filters are defined in the ServletRequest

b)

b. Filters are defined in the jsp pages.

c)

c. Filters are defined in the deployment descriptor file web.xml

d)

d. Filters are defined in the ServletContext

103.

Which tag is used to insert java source code in JSP?

a)

a. Application tag

b)

b. Declaration Tag

c)

C. Scriptlet tag

d)

d. Expression tag

104.

In order to get the value from the request parameter, please choose the correct code

a)

a. String the Studentld = request.getStudent("studentld");

b)

b. String the Studentld = request.getParameter("studentld");

c)

c. String the Studentld = request.getID("studentld");

d)

d. String the Studentld = getParameter("studentld");

105.

When destroy method of a filter is called?

a)

a. called after the filter has executed doFilter method

b)

b. called after the filter has executed

c)

c. called only once at the end of the life cycle of a filter

d)

d. called only once at the begining of the life cycle of a filter

106.

In the web deployment descriptor, the tag of tag is used for

a)

a. accessing or calling the servlet instance

b)

b. applying the security on the servlet instance

c)

c. applying the filter on the servlet instance

d)

d. informing server about the location of servlet in web application directory

107.

Which of the following is not component of MVC architecture?

a)

a. XML

b)

b. View

c)

c. Controller

d)

d. Model

108.

Which of the following is not a valid type of statement in JDBC?

a)

a. Statement

b)

b. PreparedStatement

c)

c. CallableStatement

d)

d. QueryStatement

109.

DriverManager.getConnection What is the order of parameters included

a)

a. URL where server runs, UserID, Password

b)

b. URL where server runs; Password, UserID

c)

c. Password, URL where server runs, UserID

d)

d. User ID, Password, URL where server runs

110.

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)

a. 400

b)

b. 403

c)

c. 404

d)

d. 500

111.

Which HTTP method is used when sending request from the browser?

a)

a. POST

b)

b. PUT

c)

C. SET

d)

d. GET

112.

JSP ___ let you insert arbitrary code into the servlet's _JspService() method.

a)

a. scriptlets

b)

b. declarations

c)

c. comment

d)

d. custom tag

113.

Please choose to correct statement to include a header.jsp page in to an jsp page?

a)

a. <jsp:includes page="/includes/header.jsp" />

b)

b. <jsp:include page="/includes/header.jsp" />

c)

c. <include page="/includes/header.jsp" />

d)

d. < page="/includes/header.jsp" />

114.

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>

a)
b)
c)

c. ${student}

d)
115.

In JSTL, which type of Java conditional statement is the tag similar to?

a)

a. if

b)

b. foreach

c)

C. switch

d)

d. when

116.

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)

a. "hidden" & "text"

b)

b. "submit" & "text"

c)

c. "hidden" & "hidden

d)

d. "submit" & "submit"

117.

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)

a. <%@page contentType = "xml">

b)

b. <%@page contentType = "text/xml">

c)

c. <%@page contentType = "html/xml">

d)

d. <%@page contentType = "text/html">

118.

Which attribute of @page define an jsp page to be an error page?

a)

a. "true"

b)

b. "false"

c)

c. isErrorPage

d)

d. session.setAttribute("true")

e. session.setAttribute("false")

e)

f. isError Page

119.

When a JSP page is translated, what is it turned into?

a)

a. Servlet

b)

b. Midlet

c)

c. Application

d)

d. Applet

120.

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)

a. request.setValueOf

b)

b. request.getRequest Pispatcher

c)

c. request.setAttribute

d)

d. request.getAttribute

121.

Which of the following listeners will respond to events that a request comes to server or gets out of its scope?

a)

a. ServletRequestListener

b)

b.ServletRequestAttributeListener

c)

c. ServletContextListener

d)

d. ServletResponseListener

122.

Which of these characteristics of a filter is true?

a)

a. A logging and auditing filter allow users to log in to a Web application

b)

b. A filter is an object that is invoked at the preprocessing and postprocessing of a request.

c)

c. Filters used to store session

d)

d. An authentication filter tracks the activities of users of a Web application

123.

Choose the statement that best describes the relationship between JSP and servlets:

a)

a. JSP and servlets are unrelated technologies.

b)

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)

c. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.

d)

d. JSPs are built on servlet semantics and all JSPs are translaled to servlets for runtime usage.

124.

The value of session timeout in web deployment descriptor using the unit of ......

a)

a. Second

b)

b. Hour

c)

c. Minute

d)

d. Millisecond

125.

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)

a. Checking whether the username equals "admin" and password equals "abc123" or not. If yes, forward the requests to admin
index.jsp

b)

b. Setting the value of username = "admin" and password = "abc123

c)

c. Checking whether the username equals "admin" and password equals "abc123" or not

d)

d. Checking whether the username equals "admin" and password equals "abc123" or not. If yes, forward the requests to index.jsp

126.

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)

a. statement.setStringo

b)

b. statement.setTypeCastString

c)

c. statement.setString

d)

d. statement.setValueString

127.

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)

a. var="item" begin="0" end="10" step="2"

b)

b.${product}

c)

c. 0246 8 10

d)

d. 0 1 2 3 4 5 6 7 8 9 10

128.

Which method is used to perform DML statements in JDBC?

a)

a. executeResulto

b)

b.execute()

c)

c. executeQueryo

d)

d. executeUpdate()

129.

When compiling a project in java web, which of the following error codes is associated with the "Resource not found" message?

a)

a. 400

b)

b. 403

c)

c. 500

d)

d. 404

130.

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)

a. Set properties of a bean object user

b)

b. Delete properties of a bean object user

c)

c. Update properties of a bean object user

d)

d. Get properties of a bean object user