wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PRJ301

Total questions: 95

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

How much time for this Cookies

a)

30 mins

b)

1800 mins

c)

60 mins

d)

45 mins

2.

Choose all options :

a)

Get properties of a bean object user

b)

Set properties of a bean object user

c)

Update properties of a bean object user

d)

Delete properties of a bean object user

3.

Fill the blank :

a)

request.setAttribute

b)

request.getRequestDispatcher

c)

request.getAttribute

d)

request.setValueOf

4.

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

a)

Declaration Tag

b)

Scriptlet tag

c)

Expression tag

d)

Application tag

5.

What is INCORRECT about the GET method ?

a)

Should never be used when dealing with sensitive data

b)

Used for sending huge amounts of information having visible in a URL.

c)

Is one of the most common HTTP methods.

d)

Used to request data from a specified resource.

6.

Please choose the the correct code in the space

a)

${student.id}

b)

{student.id}

c)

@{student.id}

d)

${student}

7.

Fill the blanks

a)

statement.setString

b)

statement.setString()

c)

statement.setValueString

d)

statement.setTypeCastString

8.

DriverManager.getConnection(_____ , ____ , ____) What is the order of parameters included?

a)

URL where server runs; Password, UserID

b)

URL where server runs, UserID, Password

c)

User ID, Password, URL where server runs

d)

Password, URL where server runs, UserID

9.

Which of the following SQL options is suitable for using PreparedStatement?

a)

insert into departmentTBL values(?,?,?)

b)

insert into departmentTBL values(x,x,x)

c)

SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)

d)

SQLTransact(conn, SQL ROLLBACK)

10.

Why use RequestDispatcher to forward a request to another resource, instead of using a sendRedirect?

a)

Redirects are no longer supported in the current servlet API.

b)

Redirects are not a cross-platform portable mechanism.

c)

The RequestDispatcher does not use the reflection API.

d)

The RequestDispatcher does not require a round trip to the client, and thus is more efficient and allows the server to maintain request state.

11.

Result is ?

a)

Final Test

b)

Final Test Study Tonight

c)

Study Tonight

d)

Pass PRJ301

12.

What is the output of this code ?

a)

0 2 4 6 8 10

b)

0 1 2 3 4 5 6 7 8 9 10

c)

${ product}

d)

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

13.

Fill the blanks ?

a)

"hidden" & "hidden"

b)

"submit" & "submit"

c)

"hidden" & "text"

d)

"submit" & "text"

14.

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

a)

String theStudentId = request.getParameter("studentId");

b)

String theStudentId = getParameter("studentId");

c)

String theStudentId = request.getID("studentId");

d)

String theStudentId = request.getStudent("studentId");

15.

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

a)

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

b)

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

c)

<a href = "url" target= "blank">

d)

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

16.

Consider the following HTML page code, which method can be used in subjectServlet to retrieve the value of "language parameter when the form submit ?

a)

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

b)

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

c)

String java = request.getParameter("java");

String cs = request.getParameter("cs");

d)

String java = request.getParameter("Java");

String cs = request.getParameter("C#");

17.

Suppose we have the servlet "NewServlet" with the code to retrieve the value of parameter "gender" from input HTML (2 options)

a)

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

<input type="radio" name = "gender" value = "Female"/> Female

b)

Gender : <input type="text" name = "gender" value = "male" /> Male

<input type="text" name = "gender" value = "Female"/> Female

c)

Gender : <input type="checkbox" name = "gender" value = "male"/> Male

<input type="checkbox" name = "gender" value = "Female"/> Female

d)

Gender : <input type="password" name = "gender" value = "male"/> Male

<input type="password" name = "gender" value = "Female"/> Female

18.

What happens if you call deleteRow() on a ResultSet object?

a)

The row you are positioned on is deleted from the ResultSet, but not from the database

b)

The row you are positioned on is deleted from the ResultSet and from the database

c)

The result depends on whether the property synchronizeWithDataSource is set to true or false

d)

You will get a compile error: the method does not exist because you cannot delete rows from a ResultSet

19.

Choose the option to make jsp page as an error page

a)

isErrorPage = "true"

b)

isErrorPage = true

c)

Session = "true"

d)

Session = true;

20.

Which option is for discard an entire session

a)

session.discontinue()

b)

session.invalidate()

c)

session.disconnect()

d)

session.falsify()

21.

Which of the following is used for session tracking

a)

URL rewriting

b)

Hidden form fields

c)

SSL sessions

d)

Cookies

22.
a)

A

b)

B

c)

C

d)

D

23.

What will be the output fr om the following expression?

<%

request.setAttribute("a", 15);

request.setAttribute("b", 6);

%>

${a%b}

a)

1

b)

2

c)

3

d)

4

24.

Fill the blank ?

a)

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

b)

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

c)

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

d)

<c:out value = number></c:out>

25.

What is the output ?

a)

Your mark is : 4.15

You pass PRJ301

b)

You pass PRJ301

c)

Your mark is : 4.00

Need a retake

d)

Your mark is : 4.15

26.

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 prefix="c" %>

d)

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

27.

Choose option is NOT types of filters in JSP

a)

Logging Filters

b)

Data Compression Filters

c)

Authentication Filters

d)

Time Controlling Filters

28.

Which structure of Request Line in Request Message is

a)

None of the others

b)

[HTTP Method] [Protocol Version] [Requested Resourse Forming URI]

c)

[HTTP Method] [Requested Resourse Forming URI] [Protocol Version]

d)

[Requested Resourse Forming URI] [HTTP Method] [Protocol Version]

29.

Where can Request Parameter be put in Request Message?

Select one:

a)

Only in Message Body

b)

Request Line And Message Body

c)

None of the others

d)

Header Information and Message Body

30.

Which following sentence does present 'Implicit Objects' object?

a)

pageContext, servlet, application, parameter

b)

pageContext, config, context, exception

c)

pageContext, config, application, exception

d)

None of the others

31.

Which component can be used call method and output to response object in JSP code?

Select one:

a)

declaration

b)

scriplets

c)

expression

d)

None of the others

32.

Which tags in web deployment descriptor are used to refer datasource in configuring to connect dynamic DB?

a)

resource-ref-name, resource-type, resource-auth

b)

res-ref-name, res-type, res-auth

c)

None of the others

d)

name, type, auth

33.

Which methods in session tracking are used to store information in server side?

Select one:

a)

Cookies

b)

Http Session

c)

Http Servlet

d)

None of the others

34.

Given :

${2+ "2"} = \${2 + 2}

Which result is correct ?

a)

None

b)

${2+ "2"} = 4

c)

4 = ${2+ "2"}

d)

${2+ "2"} = ${2 + 2}

35.

Which following function in core library taglib of JSTL is used to traverse the collection objects?

Select one:

a)

forLoop

b)

forEach

c)

forTokens

d)

None

36.

Which following sentence is correct about Filter Life Cycle?

a)

The Filter is trigger before Context Initialization Parameter is created

b)

The Filter is trigger before Request Message is created

c)

The Filter is trigger before Request Object is created

d)

None of the others

37.

Your web application requires the ability to load and remove web files dynamically to the web container's file system? Which two HTTP methods are used to perform these actions?Select one or more:

a)

POST

b)

PUT

c)

DELETE

d)

SEND

e)

GET

38.

Which of the following statements about the Servlet is false?

Choose one answer.

a)

Servlets are easy to use

b)

Initialization code in servlets is executed every time the program is made to run

c)

Servlets are portable

d)

All of these

e)

None of these

39.

In the web deployment descriptor, the url-pattern tag of servlet-mapping tag is used for _________

Select one:

a)

informing server about the location of servlet in web application directory

b)

accessing or calling the servlet instance

c)

applying the security on the servlet instance

d)

applying the filter on the servlet instance

40.

You need to send a GIF file to the browser. Which of the following lines should becalled after ( or before) a call to response.getOutputStream( ) ?

Select one:

a)

response.setDataType( "image/gif"); After

b)

response.setContentType( "image/gif"); Before

c)

response.setContentType( "image/gif"); After

d)

response.setDataType( "image/gif"); Before

41.

Given xml fragment code

<Resource name="DS007" type="javax.sql.DataSource" auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

url="jdbc:sqlserver://localhost:1433;databaseName=Sinhvien2K17;instanceName=SQL2017" username="sa" password="trongkhanh"/>

Where should above code put?

a)

context.xml file

b)

In JSP file that uses DB in progress

c)

None of the others

d)

web deployment descriptor file

42.

Which differences between Context Initialization Parameter and Config Initialization Parameter are ?

a)

Context Initialization Parameter is initialized after servlet is load into memory but Config Initialization Parameter is initialized when application is deployed

b)

Context Initialization Parameter is initialized when the application is deploying but Config Initialization Parameter is initialized when servlet is load into memory

c)

None of the others

d)

Context Initialization Parameter is initialized when the user requests application at the first time but Config Initialization Parameter is initialized when application is deployed

43.

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

a)

scope object

b)

pageContext object

c)

context object

d)

application object

44.

Which following tag is correct when it is applied above configuration? Assume that the prefix of tag is test in used ?

a)

<test:test a = “5”>abc</test:test>

b)

<test:test a = “${2 + 2}/>

c)

<test:test a = “5”/>

d)

None of the others

45.

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

Select one:

a)

None of the others

b)

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

c)

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

d)

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

46.

Which following syntax in core library taglib of JSTL is same as function of include standard action?

a)

<c:import url=”abc.jsp”/>

b)

<c:import var=”test”/>

c)

None of the others

d)

<c:import url=”abc.jsp” var=”test”/>

47.

How are Filters triggered in order when filter chain is applied?

Select one ?

a)

The filter is declared in sequence in web deployment descriptor

b)

None of the others

c)

The filter is declared in sequence in servlet code and JSP page code

d)

The filter is declared in sequence in context.xml file

48.

Which Design Pattern does Struts2 Framework apply?

a)

MVC 2 using Servlet as Controller

b)

None of these

c)

MVC 2 using Filter as Controller

d)

MVC 2 using Data Transfer Object as Controller

49.

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

a)

doGet

b)

doPost

c)

doPut

d)

doDelete

50.

A web application is located in a directory named sales. Where should its deployment descriptor be located?

Select one :

a)

WEB-INF/sales

b)

sales

c)

sales/WEB

d)

sales/deployment

e)

sales/WEB-INF

51.

Your servlet class depends on a utility class named com.abc.TaxUtil. Where would you keep the TaxUtil.class file?

Select one:

a)

WEB-INF/classes

b)

WEB-INF/classes/com/abc

c)

WEB-INF/lib

d)

WEB-INF

e)

WEB-INF/jars

52.

What file is the deployment descriptor of a web application named BankApp stored in?

a)

server.xml

b)

web.xml

c)

deployment.xml

d)

WebApp.xml

e)

BankApp.xml

53.

Consider the following HTML page code:

<html><body>

<a href="/servlet/HelloServlet">POST</a>

</body></html>

Which method of HelloServlet will be invoked when the hyperlink displayed by the above page is clicked?

Select one ?

a)

doForm

b)

doHref

c)

doForm

d)

serviceGet

e)

doGet

54.

You are creating a web form with this HTML:

11. <form action="sendOrder.jsp">

12. <input type="text" name="creditCard">

13. <input type="text" name="expirationDate">

14. <input type="submit">

15. </form>

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

Select one:

a)

POST

b)

SEND

c)

GET

d)

PUT

55.

Which of the following directories are legal locations for the deployment descriptor file? Note that all paths are shown as from the root of

the machine or drive.

a)

/WEB-INF/xml

b)

/WEB-INF/classes

c)

None of others

d)

/WEB-INF

56.

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

57.

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

Select one:

a)

url-pattern

b)

All of the other choices

c)

servlet-class

d)

servlet-name

58.

What are two principal methods to manage session?

Choose 2 :

a)

request

b)

HTML field

c)

Cookie

d)

response

e)

URL rewriting

59.

Servlets and JavaBean classes that are parts of a packages are placed in the _______ directory.

Select one:

a)

classes

b)

All of the others

c)

lib

d)

tld

60.

Consider the following code statement:

response.sendRedirect( “/abc/FinalServlet”);

Assume that the current context root of application is Final. Which of the following statements about the servlet container translating above

code statements to the following URL is true?

1. http://localhost:8080/Final/abc/FinalServlet

2. http://localhost:8080/abc/FinalServlet

3. http://localhost:8080/FinalServlet/abc

4. http://localhost:8080/FinalServlet/abc/Final

Select one:

a)

1,4

b)

2

c)

2,3

d)

4

61.

Which of the following statements about Request and Response message structure are false?

a)

Header information in response message contains information such as server, last modified date, content-length and content type

b)

Request message structure consists of request line and header information

c)

Request line returns the User-Agent along with the Accept header

d)

None of these

62.

The _____ directory contains the archive files requires for Web Application such as database drivers

Select one:

a)

lib

b)

tags

c)

tld

d)

classes

63.

Which of the following methods of HTTP will send data from clients to servers using security format in the body of the request?

Select one:

a)

POST

b)

GET

c)

Both of them

d)

None of them

64.

The ________ method called by the servlet container to allow the servlet to response to a request.

Select one:

a)

service( )

b)

getServletContext( )

c)

init( )

d)

getInitParameter( )

65.

_____________ provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user.

Select one:

a)

URL Rewrite

b)

Hidden Field

c)

Cookie

d)

Session management

66.

Which of the following error code indicates an error inside the HTTP server which prevented it from fulfilling the request?

a)

404

b)

401

c)

500

d)

403

67.

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

Choose one :

a)

HttpSession

b)

HttpSessionBindingEvent

c)

HttpSessionListenerEvent

d)

HttpSessionEvent

68.

The ________ method returns an array containing all the Cookie objects the client sent along with the request

a)

getHeader()

b)

getCookie()

c)

getCookies()

d)

getHeaders()

69.

Which classes or interfaces provide a getSession method?

Select one:

a)

javax.servlet.http.HttpServletResponse

b)

javax.servlet.http.HttpServletResponse

c)

javax.servlet.http.HttpServletRequest

d)

javax.servlet.http.HttpSessionContext

70.

Study the following statements:


1) A session object can be accessed by all web applications in the same server.


2) Session object exists longer than the application object.


3) The request object lives longer than the session object.


The statement (1) is ...., (2) is .... and (3) is .......


Choose one answer.

a)

false, false, false

b)

true, true, true

c)

true, false, true

d)

true, false, false

71.

The ________ method returns a string containing the value of the named initialization parameter

Select one:

a)

init( )

b)

getInitParameter( )

c)

getServletConfig( )

d)

jspInit

72.

Which of the following error code is associated with the message "Resource not found”?

a)

404

b)

403

c)

401

d)

500

73.

Which of the following error code indicates that the HTTP server is temporarily overloaded, and unable to handle the request?

Select one:

a)

503

b)

500

c)

404

d)

401

74.

What is the HTTP 1.1 status code that indicates the request accepted?

Select one:

a)

101

b)

202

c)

201

d)

200

75.

JSTL stands for

a)

JavaBean Standard Tag Library

b)

Enterprise JavaBean Standard Tag Library

c)

Servlet Pages Standard Tag Library

d)

JavaServer Pages Standard Tag Library

76.

Following is the syntax to include ___________in your JSP

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

a)

JSTL XML library

b)

JSTL SQL library

c)

JSTL Core library

d)

JSTL Formatting library

77.

Which tag executes the SQL query defined in its body or through the sql attribute?

Select one:

a)

<sql:update>

b)

<sql:executeQuery>

c)

<sql:executeUpdate>

d)

<sql:query>

78.

Which JSTL tag likes <%= ... >?

Select one :

a)

<c:out >

b)

<c:out.print >

c)

<c:in >

d)

<c:output >

79.

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

a)

<sql:setparam>

b)

<sql:param>

c)

<sql:parameter>

d)

<sql:setparameter>

80.

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

a)

<sql:setDataSource>

b)

<sql:setDataBase>

c)

<sql:setConnection>

d)

<sql:setDatabase>

81.

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)

The getAttribute method takes two arguments

c)

Primitives CANNOT be stored in the HttpSession

d)

All of the others

82.

_________ is the process of ensuring that an authenticated party gains access only to the resources it is entitled to.

a)

Authentication

b)

Confidentiality

c)

Authorization

d)

Data integrity

83.

Digest authentiction is based on _________

a)

A hash function and encryption

b)

A plaintext and SSL

c)

A decoded password and encrypted username

d)

None of the others.

84.

Which of the followings correctly declares that the current page is an error page and also enables it to take part in a session?

Select one:

a)

<%@ page errorPage="true" session="true" %>

b)

<%@ page pageType="errorPage" session="required" %>

c)

<%@ page isErrorPage="true" session="true" %>

d)

<%@ page errorPage="true" session="mandatory" %>

e)

<%@ page isErrorPage="true" session="mandatory" %>

85.

Use a _________ to place code in the generated servlet outside of the _jspService( ) method

Select one:

a)

scriptlet

b)

comment

c)

declaration

d)

expression

86.

Which of the following statements about JSP declaration is true?

Select one:

a)

The JSP declarations allows the variable using in application scopes

b)

The users are allowed to define methods in a JSP file

c)

All of the others.

d)

A single declaration tag can be used to define unique variable.

87.

Which syntax is correct for JSP Declarations?

Select one:

a)

<% code %>

b)

<%! code %>

c)

None of these

d)

<%= code %>

88.

In JSP, the prefix of a tag ________

a)

is used for distinguishing tags for a library

b)

is used for making easiness in detecting the body of the tag

c)

None of the others

d)

is used for the symmetric syntax

89.

Servlet A receives a request that it forwards to servlet B within another web application in the same web container. Servlet A needs to share data with servlet B and that data must not be visible to other servlets in A's web application. In which object can the data that A shares with B be stored?

Select one :

a)

ServletConfig

b)

HttpSession

c)

HttpServletRequest

d)

HttpServletResponse

90.

The JSP developer wants a comment to be visible in the final output to the browser. Which comment style needs to be used in a JSP page?

Select one:

a)

<%-- this is a comment --%>

b)

<% // this is a comment %>

c)

<% /** this is a comment **/ %>

d)

<!-- this is a comment -->

91.

The ______________ supplies business components, or enterprise beans.

a)

Application assembler

b)

Deployer

c)

Tools vendor

d)

Bean provider

92.

The HttpServletResponse lets you:

a)

All of the others.

b)

specify response headers ( Content-Type, Set-Cookie, etc.)

c)

obtain a PrintWriter used to send the document content back to the client.

d)

specify outgoing information such as HTTP status codes ( 200, 404, etc.)

93.

The ________ method returns the actual length of the request sent by the client

a)

getContentLength( )

b)

getAttribute( )

c)

getParameter( )

d)

getServerName( )

94.

Which of the following lines would initialize the out variable for sending a Microsoft Word file to the browser? ( Select one)

a)

OutputStream out = response.getOuputStream( );

b)

OutputStream out = response.getWriter( );

c)

PrintWriter out = response.getServletOutput( );

d)

PrintWriter out = response.getPrintWriter( );

95.

A servlet can contain instance variables but the developer can not create the servlet based on its constructors and parameters. A way to assign parameters to these variables is ......

a)

getting parameters from the cookies attached in the request

b)

getting parameters from the deployment descriptor file

c)

getting parameters from the request's query string

d)

All of the others