Font size
WorksheetsPRJ301
Total questions: 95
Worksheet time: 2hrs 35mins
How much time for this Cookies
30 mins
1800 mins
60 mins
45 mins
Choose all options :
Get properties of a bean object user
Set properties of a bean object user
Update properties of a bean object user
Delete properties of a bean object user
Fill the blank :
request.setAttribute
request.getRequestDispatcher
request.getAttribute
request.setValueOf
Which tag is used to insert java source code in JSP?
Declaration Tag
Scriptlet tag
Expression tag
Application tag
What is INCORRECT about the GET method ?
Should never be used when dealing with sensitive data
Used for sending huge amounts of information having visible in a URL.
Is one of the most common HTTP methods.
Used to request data from a specified resource.
Please choose the the correct code in the space
${student.id}
{student.id}
@{student.id}
${student}
Fill the blanks
statement.setString
statement.setString()
statement.setValueString
statement.setTypeCastString
DriverManager.getConnection(_____ , ____ , ____) What is the order of parameters included?
URL where server runs; Password, UserID
URL where server runs, UserID, Password
User ID, Password, URL where server runs
Password, URL where server runs, UserID
Which of the following SQL options is suitable for using PreparedStatement?
insert into departmentTBL values(?,?,?)
insert into departmentTBL values(x,x,x)
SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)
SQLTransact(conn, SQL ROLLBACK)
Why use RequestDispatcher to forward a request to another resource, instead of using a sendRedirect?
Redirects are no longer supported in the current servlet API.
Redirects are not a cross-platform portable mechanism.
The RequestDispatcher does not use the reflection API.
The RequestDispatcher does not require a round trip to the client, and thus is more efficient and allows the server to maintain request state.
Result is ?
Final Test
Final Test Study Tonight
Study Tonight
Pass PRJ301
What is the output of this code ?
0 2 4 6 8 10
0 1 2 3 4 5 6 7 8 9 10
${ product}
var="item" begin="0" end="10" step="2"
Fill the blanks ?
"hidden" & "hidden"
"submit" & "submit"
"hidden" & "text"
"submit" & "text"
In order to get the value from the request parameter, please choose the correct code
String theStudentId = request.getParameter("studentId");
String theStudentId = getParameter("studentId");
String theStudentId = request.getID("studentId");
String theStudentId = request.getStudent("studentId");
How can you open a link in a new browser window?
< a href = "url" target = "new">
<a href = "url" target= "_blank">
<a href = "url" target= "blank">
<a href = "url" target ="open">
Consider the following HTML page code, which method can be used in subjectServlet to retrieve the value of "language parameter when the form submit ?
String[] languages = request.getParameterValues("language");
String languages = request.getParameterValues("language");
String java = request.getParameter("java");
String cs = request.getParameter("cs");
String java = request.getParameter("Java");
String cs = request.getParameter("C#");
Suppose we have the servlet "NewServlet" with the code to retrieve the value of parameter "gender" from input HTML (2 options)
Gender : <input type="radio" name = "gender" value = "male" checked/> Male
<input type="radio" name = "gender" value = "Female"/> Female
Gender : <input type="text" name = "gender" value = "male" /> Male
<input type="text" name = "gender" value = "Female"/> Female
Gender : <input type="checkbox" name = "gender" value = "male"/> Male
<input type="checkbox" name = "gender" value = "Female"/> Female
Gender : <input type="password" name = "gender" value = "male"/> Male
<input type="password" name = "gender" value = "Female"/> Female
What happens if you call deleteRow() on a ResultSet object?
The row you are positioned on is deleted from the ResultSet, but not from the database
The row you are positioned on is deleted from the ResultSet and from the database
The result depends on whether the property synchronizeWithDataSource is set to true or false
You will get a compile error: the method does not exist because you cannot delete rows from a ResultSet
Choose the option to make jsp page as an error page
isErrorPage = "true"
isErrorPage = true
Session = "true"
Session = true;
Which option is for discard an entire session
session.discontinue()
session.invalidate()
session.disconnect()
session.falsify()
Which of the following is used for session tracking
URL rewriting
Hidden form fields
SSL sessions
Cookies
A
B
C
D
What will be the output fr om the following expression?
<%
request.setAttribute("a", 15);
request.setAttribute("b", 6);
%>
${a%b}
1
2
3
4
Fill the blank ?
<c: value = "${number}"</c>
<c:out value = "number"></c:out>
<c:out value = "${number}"></c:out>
<c:out value = number></c:out>
What is the output ?
Your mark is : 4.15
You pass PRJ301
You pass PRJ301
Your mark is : 4.00
Need a retake
Your mark is : 4.15
Choose the correct way to use the JSTL Function Tags
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/JSTLFunctionTags prefix="fn" %>
Choose option is NOT types of filters in JSP
Logging Filters
Data Compression Filters
Authentication Filters
Time Controlling Filters
Which structure of Request Line in Request Message is
None of the others
[HTTP Method] [Protocol Version] [Requested Resourse Forming URI]
[HTTP Method] [Requested Resourse Forming URI] [Protocol Version]
[Requested Resourse Forming URI] [HTTP Method] [Protocol Version]
Where can Request Parameter be put in Request Message?
Select one:
Only in Message Body
Request Line And Message Body
None of the others
Header Information and Message Body
Which following sentence does present 'Implicit Objects' object?
pageContext, servlet, application, parameter
pageContext, config, context, exception
pageContext, config, application, exception
None of the others
Which component can be used call method and output to response object in JSP code?
Select one:
declaration
scriplets
expression
None of the others
Which tags in web deployment descriptor are used to refer datasource in configuring to connect dynamic DB?
resource-ref-name, resource-type, resource-auth
res-ref-name, res-type, res-auth
None of the others
name, type, auth
Which methods in session tracking are used to store information in server side?
Select one:
Cookies
Http Session
Http Servlet
None of the others
Given :
${2+ "2"} = \${2 + 2}
Which result is correct ?
None
${2+ "2"} = 4
4 = ${2+ "2"}
${2+ "2"} = ${2 + 2}
Which following function in core library taglib of JSTL is used to traverse the collection objects?
Select one:
forLoop
forEach
forTokens
None
Which following sentence is correct about Filter Life Cycle?
The Filter is trigger before Context Initialization Parameter is created
The Filter is trigger before Request Message is created
The Filter is trigger before Request Object is created
None of the others
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:
POST
PUT
DELETE
SEND
GET
Which of the following statements about the Servlet is false?
Choose one answer.
Servlets are easy to use
Initialization code in servlets is executed every time the program is made to run
Servlets are portable
All of these
None of these
In the web deployment descriptor, the url-pattern tag of servlet-mapping tag is used for _________
Select one:
informing server about the location of servlet in web application directory
accessing or calling the servlet instance
applying the security on the servlet instance
applying the filter on the servlet instance
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:
response.setDataType( "image/gif"); After
response.setContentType( "image/gif"); Before
response.setContentType( "image/gif"); After
response.setDataType( "image/gif"); Before
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?
context.xml file
In JSP file that uses DB in progress
None of the others
web deployment descriptor file
Which differences between Context Initialization Parameter and Config Initialization Parameter are ?
Context Initialization Parameter is initialized after servlet is load into memory but Config Initialization Parameter is initialized when application is deployed
Context Initialization Parameter is initialized when the application is deploying but Config Initialization Parameter is initialized when servlet is load into memory
None of the others
Context Initialization Parameter is initialized when the user requests application at the first time but Config Initialization Parameter is initialized when application is deployed
Which implicit object is supported in jsp page to access pageScope, requestScope, sessionScope, applicationScope?
scope object
pageContext object
context object
application object
Which following tag is correct when it is applied above configuration? Assume that the prefix of tag is test in used ?
<test:test a = “5”>abc</test:test>
<test:test a = “${2 + 2}/>
<test:test a = “5”/>
None of the others
Which components are required to use in JSP page after custom tag implemented?
Select one:
None of the others
Custom taglib class that extends from JSTL, tld file, declaration in context.xml file
Custom taglib class that extends from JSTL, tld file, declaration in context.xml file
Custom taglib class that extends from tagext, tags file, declaration in both web.xml and JSP files
Which following syntax in core library taglib of JSTL is same as function of include standard action?
<c:import url=”abc.jsp”/>
<c:import var=”test”/>
None of the others
<c:import url=”abc.jsp” var=”test”/>
How are Filters triggered in order when filter chain is applied?
Select one ?
The filter is declared in sequence in web deployment descriptor
None of the others
The filter is declared in sequence in servlet code and JSP page code
The filter is declared in sequence in context.xml file
Which Design Pattern does Struts2 Framework apply?
MVC 2 using Servlet as Controller
None of these
MVC 2 using Filter as Controller
MVC 2 using Data Transfer Object as Controller
Which following methods of HttpServlet class stores a resource under the request URL?
doGet
doPost
doPut
doDelete
A web application is located in a directory named sales. Where should its deployment descriptor be located?
Select one :
WEB-INF/sales
sales
sales/WEB
sales/deployment
sales/WEB-INF
Your servlet class depends on a utility class named com.abc.TaxUtil. Where would you keep the TaxUtil.class file?
Select one:
WEB-INF/classes
WEB-INF/classes/com/abc
WEB-INF/lib
WEB-INF
WEB-INF/jars
What file is the deployment descriptor of a web application named BankApp stored in?
server.xml
web.xml
deployment.xml
WebApp.xml
BankApp.xml
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 ?
doForm
doHref
doForm
serviceGet
doGet
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:
POST
SEND
GET
PUT
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.
/WEB-INF/xml
/WEB-INF/classes
None of others
/WEB-INF
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.
cookie
session
request
response
Which sub-element is used to define a logical name of servlet in web deployment descriptor?
Select one:
url-pattern
All of the other choices
servlet-class
servlet-name
What are two principal methods to manage session?
Choose 2 :
request
HTML field
Cookie
response
URL rewriting
Servlets and JavaBean classes that are parts of a packages are placed in the _______ directory.
Select one:
classes
All of the others
lib
tld
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:
1,4
2
2,3
4
Which of the following statements about Request and Response message structure are false?
Header information in response message contains information such as server, last modified date, content-length and content type
Request message structure consists of request line and header information
Request line returns the User-Agent along with the Accept header
None of these
The _____ directory contains the archive files requires for Web Application such as database drivers
Select one:
lib
tags
tld
classes
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:
POST
GET
Both of them
None of them
The ________ method called by the servlet container to allow the servlet to response to a request.
Select one:
service( )
getServletContext( )
init( )
getInitParameter( )
_____________ 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:
URL Rewrite
Hidden Field
Cookie
Session management
Which of the following error code indicates an error inside the HTTP server which prevented it from fulfilling the request?
404
401
500
403
Which object is passed as parameter in attributedAdded, attributedReplaced, and attributedRemoved method of the HttpSessionAttributeListener?
Choose one :
HttpSession
HttpSessionBindingEvent
HttpSessionListenerEvent
HttpSessionEvent
The ________ method returns an array containing all the Cookie objects the client sent along with the request
getHeader()
getCookie()
getCookies()
getHeaders()
Which classes or interfaces provide a getSession method?
Select one:
javax.servlet.http.HttpServletResponse
javax.servlet.http.HttpServletResponse
javax.servlet.http.HttpServletRequest
javax.servlet.http.HttpSessionContext
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.
false, false, false
true, true, true
true, false, true
true, false, false
The ________ method returns a string containing the value of the named initialization parameter
Select one:
init( )
getInitParameter( )
getServletConfig( )
jspInit
Which of the following error code is associated with the message "Resource not found”?
404
403
401
500
Which of the following error code indicates that the HTTP server is temporarily overloaded, and unable to handle the request?
Select one:
503
500
404
401
What is the HTTP 1.1 status code that indicates the request accepted?
Select one:
101
202
201
200
JSTL stands for
JavaBean Standard Tag Library
Enterprise JavaBean Standard Tag Library
Servlet Pages Standard Tag Library
JavaServer Pages Standard Tag Library
Following is the syntax to include ___________in your JSP
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
JSTL XML library
JSTL SQL library
JSTL Core library
JSTL Formatting library
Which tag executes the SQL query defined in its body or through the sql attribute?
Select one:
<sql:update>
<sql:executeQuery>
<sql:executeUpdate>
<sql:query>
Which JSTL tag likes <%= ... >?
Select one :
<c:out >
<c:out.print >
<c:in >
<c:output >
Which JSTL tag sets a parameter in an SQL statement to the specified value?
<sql:setparam>
<sql:param>
<sql:parameter>
<sql:setparameter>
To connect to the database, which JSTL tag do we use?
<sql:setDataSource>
<sql:setDataBase>
<sql:setConnection>
<sql:setDatabase>
Given that session is a valid HttpSession object:
int max = session.getAttribute( "MyReallyLongName");
Which is true?
Select one:
The HttpSession attribute name must NOT exceed eight characters
The getAttribute method takes two arguments
Primitives CANNOT be stored in the HttpSession
All of the others
_________ is the process of ensuring that an authenticated party gains access only to the resources it is entitled to.
Authentication
Confidentiality
Authorization
Data integrity
Digest authentiction is based on _________
A hash function and encryption
A plaintext and SSL
A decoded password and encrypted username
None of the others.
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:
<%@ page errorPage="true" session="true" %>
<%@ page pageType="errorPage" session="required" %>
<%@ page isErrorPage="true" session="true" %>
<%@ page errorPage="true" session="mandatory" %>
<%@ page isErrorPage="true" session="mandatory" %>
Use a _________ to place code in the generated servlet outside of the _jspService( ) method
Select one:
scriptlet
comment
declaration
expression
Which of the following statements about JSP declaration is true?
Select one:
The JSP declarations allows the variable using in application scopes
The users are allowed to define methods in a JSP file
All of the others.
A single declaration tag can be used to define unique variable.
Which syntax is correct for JSP Declarations?
Select one:
<% code %>
<%! code %>
None of these
<%= code %>
In JSP, the prefix of a tag ________
is used for distinguishing tags for a library
is used for making easiness in detecting the body of the tag
None of the others
is used for the symmetric syntax
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 :
ServletConfig
HttpSession
HttpServletRequest
HttpServletResponse
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:
<%-- this is a comment --%>
<% // this is a comment %>
<% /** this is a comment **/ %>
<!-- this is a comment -->
The ______________ supplies business components, or enterprise beans.
Application assembler
Deployer
Tools vendor
Bean provider
The HttpServletResponse lets you:
All of the others.
specify response headers ( Content-Type, Set-Cookie, etc.)
obtain a PrintWriter used to send the document content back to the client.
specify outgoing information such as HTTP status codes ( 200, 404, etc.)
The ________ method returns the actual length of the request sent by the client
getContentLength( )
getAttribute( )
getParameter( )
getServerName( )
Which of the following lines would initialize the out variable for sending a Microsoft Word file to the browser? ( Select one)
OutputStream out = response.getOuputStream( );
OutputStream out = response.getWriter( );
PrintWriter out = response.getServletOutput( );
PrintWriter out = response.getPrintWriter( );
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 ......
getting parameters from the cookies attached in the request
getting parameters from the deployment descriptor file
getting parameters from the request's query string
All of the others
