WorksheetsPRJ301_PART1
Total questions: 130
Worksheet time: 1hrs 6mins
Entity bean is _______
Select one:
a. a persistent data component
b. a database object
c. an object-relational mapping
d. an application logic component
Identify the correct order of phases in the Public/Private Key encryption?
1. Server provides its public key
2. Client makes request for secure resource
3. Server provides secure resource, encrypted with the client's public key
4. Client provides its public key, encrypted with the server's public key
Select one:
a. 2 - 4 - 3 - 1
b. 3 - 1 - 4 - 2
c. 1 - 2 - 3 - 4
d. 2 - 1 - 4 - 3
When using Form Based Authentication, which pair of fields must be used in the login form?
Select one:
a. j_username and j_password
b. j_login and j_password
c. j_user and j_password
d. j_id and j_password
In a JSP-centric web application, you need to create a catalog browsing JSP page. The catalog is stored as a List object in the catalog
attribute of the webapp's ServletContext object. Which scriptlet code snippet gives you access to the catalog object?
Select one:
a. <% List catalog = application.getAttribute( "catalog"); %>
b. <% List catalog = servletContext.getAttribute( "catalog"); %>
c. <% List catalog = context.getAttribute( "catalog"); %>
d. <% List catalog = config.getAttribute( "catalog"); %>
Which statement is not true when contrasting the use of entity beans and JDBC for database operations?
Select one:
a. The container-managed entity bean automatically retrieves the data from the persistent storage ( database).
b. When using JDBC, you must explicitly handle the database transaction and the database connection pooling.
c. Entity beans represent real data in a database.
d. The bean managed entity bean functionally replaces the JDBC API.
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. Standard actions take the form of an XML tag with a name suffixed jsp
c. None of the others
d. JSP uses standard actions for calling the JavaBean methods
Which request headers identifies the MIME types that the browser prefers?
Select one:
a. Referer
b. Accept
c. Host
d. Accept-Charset
Given:
1. <% String value ="beanValue"; %>
2. <%request.setAttribute("com.example.bean", value); %>
3. <%-- insert code here --%>
Which EL expression, inserted at line 3, is valid and evaluates to "beanValue"?
Select one:
a. ${request.get("com.example.bean").toString()}
b. ${value}
c. None of the others.
d. ${bean}
e. ${requestScope['com.example.bean']}
Which tags in web deployment descriptor are used to refer datasource in configuring to connect dynamic DB?
Select one:
a. resource-ref-name, resource-type, resource-auth
b. res-ref-name, res-type, res-auth
c. name, type, auth
d. None of the others
In EJB 3.0, Which statement about entity manager is true?
Select one:
a. An entity manager injected into session beans can use either JTA or resource-local transaction control
b. An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses
JTA transaction control.
c. A container-managed entity manager must be a JTA entity manager.
d. An entity manager obtained through resource injection in a stateful session bean can use a resource-local EntityTransaction for transaction control.
Study the statements about web.xml file:
1)The deployment descriptor file is called web.xml, and it must be located in the WEB-INF directory.
2)web.xml is in XML ( extended markup language) format. Its root element is <web>.
Select one:
a. Both 1 and 2 are not true.
b. Only statement 1 is true.
c. Both 1 and 2 are true.
d. Only statement 2 is true.
Which statement is true if the doStartTag method returns EVAL_BODY_BUFFERED ?
Select one:
a. The setBodyContent method is called once
b. The doAfterBody method is NOT called
c. The tag handler must implement BodyTag
d. It is never legal to return EVAL_BODY_BUFFERED from doStartTag.
The <jsp:include/> action can pass parameters to the page which it is included. How does this second page obtain the value of these parameters?
Select one:
a. All of the others.
b. Use the action
c. Use the request.getParameter() method
Consider the following code and select the correct statement about it from the options below.
<html><body>
<%! int aNum=5 %>
The value of aNum is <%= aNum %>
</body></html>
Select one:
a. It will throw a runtime exception while executing the expression.
b. If you remove "!", it will not flag any compile time or runtime errors.
c. It will print "The value of aNum is 5" to the output.
d. It will not flag any compile time or runtime errors and will not print anything to the output.
e. It will flag a compile-time error because of an incorrect declaration.
Whenever the Web browser send a request to the Web server, the Web server passes the file to the _____ engine, then the HTML output from the servlet is send through the Internet and HTML results are displayed in the Web Browser
Select one:
a. All of the others.
b. Servlet
c. JSP
Which of the following statement relating to create static methods in EL is false?
Select one:
a. The function need to be mapped with EL using a Tag Library Descriptor file
b. To access the function using EL, the function must be implemented as a static function in a java class
c. The static java methods can be called within the EL expression
d. Only a single function should be defined in a single class
Giving the session timeout defined in web.xml is 0, which one is true:
Select one:
a. Error occurs, the project cannot run
b. Session can be created and never expired
c. Session can be created but it will be timeout immediately
d. Session cannot be created
Which of the options are correct about attributes of <jsp:invoke> standard action?
(A) fragment
(B) var
[C) varReader
(D) begin
Message Driven Beans ( MDBs) are designed to function as: ( Select one)
Select one:
a. Asynchronous message consumer
b. Synchronous message publisher
c. Synchronous message consumer
d. Asynchronous message publisher
Which of the followings is not a valid setting for the scope attribute of <jsp:useBean> tag?
Select one:
a. session
b. local
c. application
d. request
What is the typical order of life cycle stages an average stateful session bean goes through starting from its instantiation till retiring? ( Select two)
Select one or more:
a. Bean fetched from the passive state, Dependency injection, PostActivate , PrePassivate
b. Bean instantiated, Dependency injection, PostConstruct , PreDestroy
c. Bean instantiated, Dependency injection, PostActivate , PrePassivate
d. Bean fetched from the passive state, PostActivate , PrePassivate
Given the following statements about an EJB deployment descriptor for which the metadata-complete attribute is not specified:
I. The EJB deployment descriptor can provide additional metadata to bean class annotations.
II. The EJB deployment descriptor can partially override bean class annotations.
III. The EJB deployment descriptor can entirely override bean class annotations. Which is true?
Select one:
a. Both statements I and III are correct.
b. Both statements I and II are correct.
c. Only statement III is correct.
d. Only statement I is correct.
e. Only statement II is correct.
________ class is responsible for the execution of the action including the sequential invocation of the Interceptor stack.
Select one:
a. Action
b. ActionInvocation
c. ActionSupport
d. ActionContext
What is the output from the following JSP?
<%! String s = "final exam"; %>
EL: ${s}
Scriptlet: <% s %>
<% Integer test = new Integer(5);
request.setAttribute("num", test); %>
EL: ${num}
What is the output?
Select one:
a. EL: Scriptlet: EL: 5
b. EL: Scriptlet: final exam EL: 5
c. EL: final Scriptlet: final exam EL: 5
d. None of the others
Consider the contents of three JSP files:
File 1: one.jsp
<html><body><pre>
<jsp:include page="two.jsp" >
<jsp:param name="color" value="red" />
</jsp:include>
</pre></body></html>
File 2: two.jsp
<jsp:include page="three.jsp" >
<jsp:param name="color" value="green" />
</jsp:include>
File 3: three.jsp
<%= request.getParameter( "color") %>
What will be the output of accessing the one.jsp file via the following URL?
http://localhost:8080/chapter12/one.jsp?color=blue
Select one:
a. green
b. red
c. blue
d. The answer cannot be determined.
Which of the following methods will erase a session object?
Select one:
a. session.end( );
b. session.destroy( );
c. session.invalidate( );
d. session.close( );
e. session.erase( );
What is the url-pattern tag in filter-mapping tag for?
Select one:
a. Determining the resource is applied by configurating Filter
b. Determining the access path to access the Filter from the browser
c. Define the mechanism to resource accessing the Filter
d. None of the others
Which http method send by browser that asks the server to get the page only?
Select one:
a. PUT
b. POST
c.. GET
d. OPTION
What is data-source?
Select one:
a. Logical name is get from database's name
b. Logical name binds to context path that is in the context.xml file and container read it at deploy time
c. Logical name binds to database server address with its authentication and connection drivers
d. None of the others
Which statement is true about web container session management?
Select one
a. To activate URL rewriting, the developer must used the HttpServletResponse.setURLRewriting method
b. None of the others
c. If the web application uses HTTPS, then the web container may used the data on the HTTPS request stream to identify the client
d. Access to session-scoped attributes is guaranteed to be thread-safe by the web container
Given the hyperlink:
http://localhost:8084/MyProject/index.jsp?param1=¶m2=
and the body of index.jsp:
<body>
<%= request.getParameter("param1") %>AND<%= request.getParameter("param2") %> </body>
What is showed on the browser window after a user accessed the hyperlink?
Select one:
a. ANDnull
b. AND
c. nullAND
d. nullANDnull
Which of the following statements about the jsp:forward is false?
Select one:
a. The jsp:forward element is used to redirect the request object
b. To pass parameter names and values to the target file, you can use a jsp:param clause with jsp:forward element
c. In the source JSP file, the code before the jsp:forward element is not processed.
d. To redirect the request, the target file can be an HTML file, JSP file or a servlet
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.
Select one:
a. cookie
b. request
c. response
d. session
The EntityManager interface defines the methods that are used to interact with the persistence context.
Select one:
T
F
Which of the following statements about the standard actions is true?
Select one:
a. JSP uses standard actions for calling the JavaBean methods.
b. Standard actions take the form of an XML tag with a name suffixed jsp
c. The attributes in standard action can not distinguish between uppercase and lowercase.
d. All of the others.
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
c. WEB-INF/lib
d. WEB-INF/classes/com/abc
e. WEB-INF/jars
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. In standard action, the values in the attributes must be enclosed in double quotes
c. Standard actions take the form of an XML tag with a name suffixed jsp
d. None of the others.
Which security mechanism proves that data has not been tampered with during its transit through the network?
Select one:
a. Data validation
b. Data integrity
c. Data privacy
d. Authorization
e. Packet sniffing
f. Authentication
The ________ method returns an array containing all the Cookie objects the client sent along with the request
Select one:
a. getCookies( )
b. getHeader( )
c. getHeaders( )
d. getCookie( )
Which of the important methods are present in servlet object?
Select one:
a. init, processRequest, destroy
b. init, doGet, doPost
c. init, service, destroy
d. init, service, doXXX
_______ are small pieces of information that are deposited on the client by the server.
Select one:
a. Cookies
b. Sessions
c. Directives
d. Scriptlets
You can use the JSTL for tag to loop through most types of collections, including regular arrays.
Select one:
T
F
An instance of entity bean is mapping with _____
Select one:
a. Database
b. Table Row
c. Table column
d. Table
In EJB 2.0, which is the legal callback method in the bean class of a stateless session bean?
Select one:
a. public void ejbCreate ( int sessionId) {}
b. public void ejbCreate( ) {}
c. public boolean ejbRemove ( ) {return true;}
d. public void ejbFinalize( ) {}
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="mandatory" %>
b. <%@ page isErrorPage="true" session="mandatory" %>
c. <%@ page isErrorPage="true" session="true" %>
d. <%@ page pageType="errorPage" session="required" %>
e. <%@ page errorPage="true" session="true" %>
Consider the following <taglib> element, which appears in a deployment
descriptor of a web application:
<taglib>
<taglib-uri>/accounting</taglib-uri>
<taglib-location>/WEB-INF/tlds/SmartAccount.tld</taglib-location>
</taglib>
Which of the following correctly specifies the use of the above tag library in a JSP page? ( Select one)
Select one:
a. <%@ taglib library="/accounting" prefix="acc"%>
b. <%@ taglib uri="/accounting" prefix="acc"%>
c. <%@ taglib name="/accounting" prefix="acc"%>
d. <%@ taglib uri="/acc" prefix="/accounting"%>
In WAR file, which of the following folders contains servlet class files?
a. lib
b. servlet
c. None of the others
d. classes
e. tags
The ________ method initializes the servlets
Select one:
a. getInitParameter()
b. service()
c. init()
d. getServletContext()
Given the HTTP message fragment:
HTTP/1.1 500 Internal Server Errors
Choose the correct statement
Select one:
a. The fragment message describes the status line of HTTP request message
b. The fragment message describes the status line of HTTP response message
c. The fragment message describes the header information of HTTP response message
d. The fragment message describes the request line of HTTP response message
Consider the following HTML page code:
<form action="UploaderServlet" method="HEAD">
<input type="text" name="test" value="123"/>
<input type="submit" value="Test"/>
</form>
Which method will be called on UploaderServlet when a user clicks on the submit button displayed by the above page?
Select one:
a. doPut
b. doHead
c. doGet
d. None of the others.
e. doPost
Which of the following exceptions may be thrown by the _jspService( ) method? ( Select one)
Select one:
a. javax.servlet.ServletException
b. javax.servlet.jsp.JSPException
c. javax.servlet.ServletException and java.io.IOException
d. javax.servlet.ServletException and javax.servlet.jsp.JSPException
The _____ directory contains the archive files requires for Web Application such as database drivers
Select one:
a. tags
b. lib
c. tlds
d. classes
Given the following deployment descriptor:
<web-app>
<servlet>
<servlet-name>InitParams</servlet-name>
<servlet-class>com.osborne.c02.InitParamsServlet</servlet-class>
<init-param>
<param-name>initParm</param-name>
<param-value>Final Test</param-value>
</init-param>
</servlet>
</web-app>
What is the outcome of running the following servlet?
public class InitParamsServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletContext sc = this.getServletContext();
PrintWriter out = response.getWriter();
out.write("Initialization Parameter is: " + sc.getInitParameter("initParm"));
}
}
Select one:
a. "Initialization Parameter is: null" returned to the requester
b. A runtime error
c. None of the others
d. "Initialization Parameter is: null" written to the console
e. "Initialization Parameter is: Final Test" returned to the requester
Which of the following statement is true about the Session Listeners?
Select one:
a. ServletContextAttributeListener must not register in web deployment descriptor
b. HttpSessionBindingListener must register in web deployment descriptor
c. HttpSessionBindingListener must not register in web deployment descriptor
d. ServletContextListener must not register in web deployment descriptor
Identify which of the following statements related to JSP pages are true.
(A) JSP implements presentation logic in a JSP page and content logic on server in a JavaBean.
(B) JavaBeans cannot be shared and exchanged among Web programmers.
(C) By using standard tags, even programmers with limited knowledge in scripting language, can design a JSP page.
(D) Java Server Pages is used in Application layer.
Select one:
a. B, D
b. A, D
c. B, C
d. A, C
Which of the following request dispatching techniques can be used to include the content of another servlet into the current output stream?
Select one:
a. None of the others.
b. redirect
c. forward
d. include
Which of the following error code indicates that the HTTP server is temporarily overloaded, and unable to handle the request?
Select one
a. 504
b. 503
c. 404
d. 403
The ________ method returns a string containing the value of the named initialisation parameter
Select one:
a. jspInit
b. getInitParameter()
c. init()
d. getServletConfig()
_____ sends a request to an object and includes the result in a JSP file.
a. import directive
b. <jsp:include>
c. include directive
d. <jsp:forward>
Which of the following statements are correct and true for Controller component?
Select one:
a. There is only one controller in MVC architecture based on JSP Model 2
b. Controller class access the database through View component
c. There can be many number of controllers in MVC architecture
d. The Controller is typically a JSP that receives requests from the browser
Which of the following statements about Web Container is true?
a. The performance of a servlet is independent of the efficiency of the container
b. Container is a program, which manages the execution of servlets
c. The Web Container takes request from a servlet and passes it to a Web Server for processing
d. A Web application is accessible to all users connected to the Web e. None of the others
The ________ method returns an array containing all the Cookie objects the client sent along with the request
Select one:
a. getHeaders( )
b. getHeader( )
c. getCookies( )
d. getCookie( )
Which is a benefit of precompiling a JSP page?
a. It provides the ability to debug runtime errors in the application.
b. It avoids execution of the _jspService method on the first request.
c. It avoids initialization on the first request.
d. It provides better performance on the first request for the JSP page.
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 isErrorPage="true" session="mandatory" %>
c. <%@ page pageType="errorPage" session="required" %>
d. <%@ page isErrorPage="true" session="true" %>
e. <%@ page errorPage="true" session="mandatory" %>
Message Driven Beans ( MDBs) are designed to function as: ( Select one)
Select one:
a. Synchronous message consumer
b. Synchronous message publisher
c. Asynchronous message publisherd. Asynchronous message consumer
d. Asynchronous message consumer
Given:
6. <myTag:foo bar='42'>
7. <%="processing" %>
8. </myTag:foo> and a custom tag handler for foo which extends TagSupport. Which two are true about the tag handler referenced by foo? ( Choose two.)
Select one or more
a. The EVAL_PAGE constant is a valid return value for the doEndTag method.
b. The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method
c. The doStartTag method is called once
d. The SKIP_PAGE constant is a valid return value for the doStartTag method.
e. The doAfterBody method is NOT callec
Which of the following statement is false about security mechanism used in Web application?
Select one:
a. None of the others.
b. In HTTP digest authentication, the server has the digest value of password based on a hash function.
c. In form-based authentication, an error page is shown at user's side if the login failed.
d. In basic security mechanism, the Web browser never pops-up a login page
In which two locations can library dependencies be defined for a web application?
Select one or more:
a. the /META-INF/MANIFEST.MF manifest file
b. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath
c. the web application deployment descriptor
d. the /META-INF/dependencies.xml file
Which implicit object is used in a JSP page to retrieve values associated with entries in the deployment descriptor?
a. application
b. config
c. session
d. request
Which of information are needed when declaring the web resource collection in the deployment descriptor?
a. The users allowed access to the web resource
b. The URL pattern that requires authorization
c. None of the others
d. The authentication mechanism required by the web resource
If the bean needs to hold information about the client across method invocations then .... should be used. ( select the best option)
Select one:
a. None of the others.
b. stateless session beanc. stateful session bean
c. stateful session bean
d. session bean
Message Driven Beans ( MDBs) can be directly accessed by internal or external clients.
a. True
b. False
For debugging purposes, you need to record how many times a given JSP is invoked before the user's session has been created. The JSP's destroy method stores this information to a database. Which JSP code snippet keeps track of this count for the lifetime of the JSP page?
a. <% int count = 0;
if ( request.getSession( false) == null ) count++; %>
b. <%@ int count = 0; %>
<% if ( request.getSession( false) == null ) count++; %>
c. <%! int count = 0; %>
<% if ( request.getSession( false) == null ) count++; %>
d. <%@ int count = 0;
if ( request.getSession( false) == null ) count++; %>
Which of the followings is a correct way to pass a parameter equivalent to the query string user=mary at request time to an included component?
a. <jsp:include page="other.jsp"><jsp:param value="mary" name="user" /></jsp:include>
b. <jsp:include page="other.jsp"><jsp:param param="user" value="mary"/></jsp:include>
c. <jsp:include page="other.jsp"><jsp:param user="mary" /></jsp:include>
d. <jsp:include page="other.jsp"><jsp:param paramName="user" paramValue="mary" /></jsp:include>
e. <jsp:include page="other.jsp"><jsp:param name="mary" value="user" /></jsp:include>
Consider the following code and select the correct statement about it from the options below.
<html><body>
<%! int aNum=5 %>
The value of aNum is <%= aNum %>
</body></html>
a. It will flag a compile-time error because of an incorrect declaration.
b. It will throw a runtime exception while executing the expression.
c. If you remove "!", it will not flag any compile time or runtime errors.
d. It will print "The value of aNum is 5" to the output.
e. It will not flag any compile time or runtime errors and will not print anything to the output.
Match the methods of the ServletRequest interface with their corresponding description.
Description:
(A) Returns the actual length of the request sent by the client.
(B) Returns the binary data requested by the client and stores it in a ServletInputStream object.
(C) Gives additional information about the servlet.
(D) Used to get the additional information that is sent along with the request information.
(E) Returns the name of the server to which the request was sent.
Method:
(1) getInputStream()
(2) getAttribute()
(3) getContentLength()
(4) getServerName()
(5) getParameter()
Which JSP standard action can be used to import content from a resource called foo.jsp?
Select one:
a. <jsp:include file='foo.jsp' />
b. <jsp:import file='foo.jsp' />
c. <jsp:include page='foo.jsp' />
d. <jsp:import>foo.jsp</jsp:import>
The HttpServletResponse lets you:
Select one:
a. specify outgoing information such as HTTP status codes (200, 404, etc.)
b. obtain a PrintWriter used to send the document content back to the client.
c. All of the others.
d. specify response headers (Content-Type, Set-Cookie, etc.)
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?
a. <%-- this is a comment --%>
b. <% /* this is a comment */ %>
c. <!-- this is a comment -->
d. <% // this is a comment %>
Which of the following is a correct way to pass a parameter equivalent to the query string user=mary at request time to an included component? ( Select one)
Select one:
a. <jsp:include page="other.jsp" >
<jsp:param name="mary" value="user" />
</jsp:include>
b. <jsp:include page="other.jsp" >
<jsp:param param="user" value="mary"/>
</jsp:include>
c. <jsp:include page="other.jsp" >
<jsp:param value="mary" name="user" />
</jsp:include>
d. <jsp:include page="other.jsp" >
<jsp:param paramName="user" paramValue="mary" />
</jsp:include>
Which syntax is correct for JSP Scriptlets?
Select one:
a. <%= code %>
b. None of these
c. <% code %>
d. <%! code %>
In EJB 3.0, Which statement about entity manager is true?
Select one:
a. An entity manager obtained through resource injection in a stateful session bean can use a resource-local EntityTransaction for transaction control.
b. A container-managed entity manager must be a JTA entity manager.
c. An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses
JTA transaction control.
d. An entity manager injected into session beans can use either JTA or resource-local transaction control.
Which of the following are advantages of asynchronous messaging architectures? ( Choose three)
Select one or more:
a. Better use of bandwidth
b. Scalability
c. Supports load balancing
d. Provides sender with instant response
Which of the following tag file directives control Tag processing?
(A) tag
(B) varReader
(C) include
(D) attribute
Select one:
a. A, C, D
b. B, C, D
c. A, B, D
d. A, B, C
Which of the following scopes permit(s) its (their) attributes lasting in a duration of a session of a client?
Select one:
a. session
b. page
c. context
d. request
e. session, context
Which defines the welcome files in a web application deployment descriptor?
Select one:
a. <welcome>
<welcome- file >/ welcome - jsp</welcome-file>
</welcome>
<welcome>
<welcome-file>/index-html</welcome-file>
</welcome>
b. <welcome-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
c. <welcome-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
d. <welcome>
<welcome-file>welcome.jsp</welcome </we1come >
</welcome >
<welcome-file>index.html<//welcome-file>
</we1come >
Which of the followings will declare the variable x in the servlet class declaration?
Select one:
a. All of the others.
b.<%! int x=10; %>
c.<%= int x=10; %>
d.<% int x=10; %>
The _____ directory contains the archive files requires for Web Application such as database drivers
Select one:
a. classes
b. tlds
c. tags
d. lib
Which of the following would not be used in a client application performing point-to-point messaging?
Select one:
a. Queue
b. InitialContext
c. Session
d. Topic
Which of the following commands will successfully build a WAR file?
Select one:
a. jar -war myfile.war
b. jar -cvf myfile.war
c. jar -cfv myfile.war *.class
d. jar -tvf myfile.war .
e. None of the others.
Which defines the welcome files in a web application deployment descriptor?
Select one:
a. <welcome>
<welcome- file >/ welcome - jsp</welcome-file>
</welcome>
<welcome>
<welcome-file>/index-html</welcome-file>
</welcome>
b. <we1come-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
c. <we1come-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
d. <welcome>
<welcome-file>welcome.jsp</welcome </we1come >
</welcome >
<welcome-file>index.html<//welcome-file>
</we1come >
The empty operator in EL language returns true value for ______
a. Only null value
b. None of the others.
c. null, empty Strings, empty arrays, and empty collections
d. Only empty Strings because the null value in EL is converted to empty String
Which is a benefit of precompiling a JSP page?
Select one:
a. It avoids initialization o
b. It provides better performance on the first request for the JSP page.
c. It avoids execution of the _jspService method on the first request.
d. It provides the ability to debug runtime errors in the application.
Which of the options is incorrect about explain the various scope values for <jsp:useBean> tag.
Select one:
a. page
b. application
c. session
d. response
A developer has used this code within a servlet:
62. if(request.isUserInRole("vip")) {
63. // VIP-related logic here
64. }
What else must the developer do to ensure that the intended security goal is achieved?
Select one:
a. create a user called vip in the security realm
b. define a security-role named vip in the deployment descriptor
c. None of the others
d. declare a security-role-ref for vip in the deployment descriptor
e. define a group within the security realm and call it vip
Which of the following statements about the JavaBean is true?
Select one:
a. All of the others.
b. It is impossible initialise the JavaBeans with arguments using jsp:useBean.
c. The public methods give access to the properties of the bean.
d. JavaBean component property must only be write-only format
Given the HTTP message fragment: HTTP/1.1 500 Internal Server Errors Choose the correct statement Select one:
a. The fragment message describes the request line of HTTP response message
b. None of the others
c. The fragment message describes the status line of HTTP response message
d. The fragment message describes the status line of HTTP request message
e. The fragment message describes the header information of HTTP response message
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/Final/test.jsp?name=John. The test.jsp contains the following code. <% String myName=request.getParameter("name");%> <% String test= "Welcome " + myName; %> <%=test%> What is the output? Select one:
a. The program gives a syntax error because of the statement <%=test%>
b. The program gives a syntax error because of the statement <% String myName=request.getParameter("name");%>
c. The program gives a syntax error because of the statement <% String test= "Welcome " + myName; %>
d. None of the others.
e. The page display "Welcome John"
Which scripting element lets you define methods or fields that get inserted into the main body of the servlet class (outside of the _jspService method that is called by service to process the request)? Select one:
a. expression
b. scriptlet
c. None of the others
d. declaration e. comment
Which method returns the actual length of the request sent by the client? Select one:
a. getContentLength()
b. None of the others
c. getParameter()
d. getServerName()
e. getAttribute()
Which of the followings is a correct syntax of the method that is used to get the initialized parameter in ServletContext or ServletConfig? Select one:
a. String getInitializedParameter(String name);
b. String getInitParameter(String name);
c. All of the others.
d. String getContextParameter(String name);
To send text outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select one or more:
a. getOutputStream
b. getBinaryStream
c. getStream
d. getWriter
Which of the following statements about Web Container is true? Select one:
a. Container is a program, which manages the execution of servlets
b. A Web application is accessible to all users connected to the Web
c. The performance of a servlet is independent of the efficiency of the container
d. The Web Container takes request from a servlet and passes it to a Web Server for processing
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. <jsp:include page="a.jsp"/>
b. There is no XML equivalent of include directive.
c. <jsp:directive.include file="a.jsp"/>
d. None of the others
e. <jsp:include file="a.jsp"/>
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. excption
b. isErrorPage
c. Error
d. None of the others
e. errorPage
Name the implicit variable available to JSP pages that may be used to access all the other implicit objects. Select one:
a. pageContext
b. request
c. response
d. page
e. out
Which of the following statement is an expression in scripting element? Select one:
a. <%= for(int i=0; i<n; i++) {out.println(i)} %>
b. <%= x + y - 8 %>
c. All of the others
d. <%= x + y; %>
Given a JSP code fragment <% int a = Integer.parseInt("a"); %> Choose the correct statement Select one:
a. The code is generated in jspInit method by JSP enginer
b. None of the others
c. The code is generated in _jspService method by JSP engine
d. The code is generated besides of _jspService method by JSP engine
Which of the following statements about Request and Response message structure is false? Select one:
a. Request message structure consists of request line and header information
b. Request line returns the User-Agent along with the Accept header
c. Header information in response message contains information such as server, last modified date, content-length and content type
d. None of the others
Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.
<% int sum = 0;
for(j = 0; j < 10; j++) { %>
<% // XXX --- Add j to sum %>
<% } %>
<% // YYY --- Display ths sum %>
Which statement when placed at the location XXX can be used to compute the sum.
Select the one correct statement Select one:
a. = sum = sum + j;
b. sum = sum + j
c. = sum = sum + j
d. sum = sum + j;
Which of the following statements about the Servlet is false? Select one:
a. Servlets are portable
b. Initialization code in servlets is executed every time the program is made to run
c. None of the others
d. Servlets are easy to use
A JSP page needs to perform some operations before servicing the first request. Where can this be done? Select one:
a. within the page directive of the JSP page
b. within a method called jspInit
c. within a scriptlet at the top of the JSP page
d. within the XML element
In a JSP life cycle, which of the following phases produces a Java Servlet (with extension *.java) file? Select one:
a. None of the others
b. Initialization
c. Instantiation
d. Compilation
e. Translation
Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in the page being invoked? Select one:
a. request.exception
b. error
c. throwable
d. None of the others
e. exception
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? Select one:
a. <%@page contentType ="text/html">
b. None of the others
c. <%@page contentType ="html/xml">
d. <%@page contentType ="xml">
e. <%@page contentType ="text/xml">
Which of the following request dispatching techniques can be used to include the content of another servlet into the current output stream? Select one:
a. include
b. forward
c. None of the others.
d. redirect
Consider the description:
-The method is called by the servlet container in response to a client request
- The method is implemented in HttpServlet classes
- The method accepts a HttpServletRequest and HttpServletResponse as parameters
- The method dispatches to the appropriate doXXX() methods
- The method is one of important methods in Servlet Life Cycle
What's the method's name?
Select one:
a. service
b. None of the others
c. processRequest
d. doPost
e. doGet
Which object(s) can be used in JSP without declaring or initializing?
Select one:
a. Server object
b. Java objects
c. Request object
d. Implicit objects
e. None of the others
User-defined Servlets use two methods such are: Select one:
a. init and post
b. get and post
c. init and destroy
d. init and get
e. None of the others
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. None of the others
b. 2, 3
c. 1
d. 1, 4
e. 2
What will be printed when the following JSP code is invoked in a browser.
Select the one correct answer.
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>
Select one:
a. The browser will print either hello or hi based upon the return value of random.
b. The JSP file will not compile.
c. The string hello will always get printed.
d. The string hi will always get printed.
e. None of the others.
Which of the following files are the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer
a. \doc-root\dd.xml
b. \doc-root\WEB-INF\dd.xml
c. \doc-root\WEB_INF\web.xrnl
d. \doc-root\WEB-INF\web.xml
e. \doc-root\WEB_INF\dd.xml
f. None of the others
g. \doc-root\web.xml
Consider the following declarations:
1.
GET http://cms.fpt.edu.vn/index.jsp HTTP/1.1
Accept: image/*, application/vnd.txt
Accept-Language: en-cd
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0) Host: www.fpt.edu.vn
2. HTTP/1.0 404 File Not Found
Connection: Close
Date: Sat, 07 Aug 2010 08:30:30 GMT
Content-Type: text/html
Server: J2EE/ 2.0
Which of the following statements is true?
Select one
a. The first fragment text describes the HTTP Response
b. The second fragment text describes the HTTP Request
c. None of the others
d. The first fragment text describes the HTTP Request
When a Web server responds to a request from a browser or other Web client, the response typically consists of: (choose one)
Select one:
a. a status line, some response headers, and the document.
b. None of the others
c. a status line, some response headers, a blank line, and the document.
d. a status line, a blank line, and the document.
e. a blank line, a status line, some response headers and the document.
A JSP page called test.jsp is passed a parameter name in the URL using
http://localhost/test.jsp?name="John".
The test.jsp contains the following code.
5. <%! String myName=request.getParameter();%>
6. <% String test= "welcome" + myName; %>
7. <%= test%>
Select one:
a. The program gives a syntax error because of the statement 6
b. None of the others
c. The program gives a syntax error because of the statement 7.
d. The program prints "Welcome John"
e. The program gives a syntax error because of the statement 5.
Which of these are true about deployment descriptors?
Select one:
a. The servlet-mapping element, if defined, must be included within the servlet element.
b. The order of elements in deployment descriptor is important. The elements must follow a specific order
c. The elements of deployment descriptor are case insensitive
d. The web-app element must include the servlet element
e. None of the others
What will be the outcome of executing the following code?
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
response.setContentLength(6);
PrintWriter out = response.getWriter();
out.write("What's your name? ");
out.write("" + response.isCommitted()); }
Select one:
a. An IllegalArgumentException is thrown.
b. A blank page is returned to the client.
c. "What's your name?" is returned to the client.
g. None of the others.
d. An IllegalStateException is thrown.
e. Won't execute because of a compilation error.
f. "What's" is returned to the client.
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. request
c. application
d. session
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. None of the others
b. <%-- this is a comment --%>
c. <!-- this is a comment -->
d. <% /* this is a comment */ %>
e. <% // this is a comment %>
Which HTTP method represents a request for information about the supported methods on an HTTP server?
Select one:
a. None of the others
b.. HEAD
c. OPTIONS
d. TRACE
e. GET
