wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PRJ301_PART1

Total questions: 130

Worksheet time: 1hrs 6mins

Name
Class
Date
1.

Entity bean is _______

Select one:

a)

a. a persistent data component

b)

b. a database object

c)

c. an object-relational mapping

d)

d. an application logic component

2.

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)

a. 2 - 4 - 3 - 1

b)

b. 3 - 1 - 4 - 2

c)

c. 1 - 2 - 3 - 4

d)

d. 2 - 1 - 4 - 3

3.

When using Form Based Authentication, which pair of fields must be used in the login form?

Select one:

a)

a. j_username and j_password

b)

b. j_login and j_password

c)

c. j_user and j_password

d)

d. j_id and j_password

4.

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)

a. <% List catalog = application.getAttribute( "catalog"); %>

b)

b. <% List catalog = servletContext.getAttribute( "catalog"); %>

c)

c. <% List catalog = context.getAttribute( "catalog"); %>

d)

d. <% List catalog = config.getAttribute( "catalog"); %>

5.

Which statement is not true when contrasting the use of entity beans and JDBC for database operations?
Select one:

a)

a. The container-managed entity bean automatically retrieves the data from the persistent storage ( database).

b)

b. When using JDBC, you must explicitly handle the database transaction and the database connection pooling.

c)

c. Entity beans represent real data in a database.

d)

d. The bean managed entity bean functionally replaces the JDBC API.

6.

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. Standard actions take the form of an XML tag with a name suffixed jsp

c)

c. None of the others

d)

d. JSP uses standard actions for calling the JavaBean methods

7.

Which request headers identifies the MIME types that the browser prefers?
Select one:

a)

a. Referer

b)

b. Accept

c)

c. Host

d)

d. Accept-Charset

8.

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)

a. ${request.get("com.example.bean").toString()}

b)

b. ${value}

c)

c. None of the others.

d)

d. ${bean}

e)

e. ${requestScope['com.example.bean']}

9.

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

Select one:

a)

a. resource-ref-name, resource-type, resource-auth

b)

b. res-ref-name, res-type, res-auth

c)

c. name, type, auth

d)

d. None of the others

10.

In EJB 3.0, Which statement about entity manager is true?

Select one:

a)

a. An entity manager injected into session beans can use either JTA or resource-local transaction control

b)

b. An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses
JTA transaction control.

c)

c. A container-managed entity manager must be a JTA entity manager.

d)

d. An entity manager obtained through resource injection in a stateful session bean can use a resource-local EntityTransaction for transaction control.

11.

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)

a. Both 1 and 2 are not true.

b)

b. Only statement 1 is true.

c)

c. Both 1 and 2 are true.

d)

d. Only statement 2 is true.

12.

Which statement is true if the doStartTag method returns EVAL_BODY_BUFFERED ?

Select one:

a)

a. The setBodyContent method is called once

b)

b. The doAfterBody method is NOT called

c)

c. The tag handler must implement BodyTag

d)

d. It is never legal to return EVAL_BODY_BUFFERED from doStartTag.

13.

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)

a. All of the others.

b)

b. Use the action

c)

c. Use the request.getParameter() method

14.

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)

a. It will throw a runtime exception while executing the expression.

b)

b. If you remove "!", it will not flag any compile time or runtime errors.

c)

c. It will print "The value of aNum is 5" to the output.

d)

d. It will not flag any compile time or runtime errors and will not print anything to the output.

e)

e. It will flag a compile-time error because of an incorrect declaration.

15.

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)

a. All of the others.

b)

b. Servlet

c)

c. JSP

16.

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

Select one:

a)

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

b)

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

c)

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

d)

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

17.

Giving the session timeout defined in web.xml is 0, which one is true:

Select one:

a)

a. Error occurs, the project cannot run

b)

b. Session can be created and never expired

c)

c. Session can be created but it will be timeout immediately

d)

d. Session cannot be created

18.

Which of the options are correct about attributes of <jsp:invoke> standard action?

a)

(A) fragment

b)

(B) var

c)

[C) varReader

d)

(D) begin

19.

Message Driven Beans ( MDBs) are designed to function as: ( Select one)

Select one:

a)

a. Asynchronous message consumer

b)

b. Synchronous message publisher

c)

c. Synchronous message consumer

d)

d. Asynchronous message publisher

20.

Which of the followings is not a valid setting for the scope attribute of <jsp:useBean> tag?
Select one:

a)

a. session

b)

b. local

c)

c. application

d)

d. request

21.

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)

a. Bean fetched from the passive state, Dependency injection, PostActivate , PrePassivate

b)

b. Bean instantiated, Dependency injection, PostConstruct , PreDestroy

c)

c. Bean instantiated, Dependency injection, PostActivate , PrePassivate

d)

d. Bean fetched from the passive state, PostActivate , PrePassivate

22.

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)

a. Both statements I and III are correct.

b)

b. Both statements I and II are correct.

c)

c. Only statement III is correct.

d)

d. Only statement I is correct.

e)

e. Only statement II is correct.

23.

________ class is responsible for the execution of the action including the sequential invocation of the Interceptor stack.

Select one:

a)

a. Action

b)

b. ActionInvocation

c)

c. ActionSupport

d)

d. ActionContext

24.

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)

a. EL: Scriptlet: EL: 5

b)

b. EL: Scriptlet: final exam EL: 5

c)

c. EL: final Scriptlet: final exam EL: 5

d)

d. None of the others

25.

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)

a. green

b)

b. red

c)

c. blue

d)

d. The answer cannot be determined.

26.

Which of the following methods will erase a session object?

Select one:

a)

a. session.end( );

b)

b. session.destroy( );

c)

c. session.invalidate( );

d)

d. session.close( );

e)

e. session.erase( );

27.

What is the url-pattern tag in filter-mapping tag for?

Select one:

a)

a. Determining the resource is applied by configurating Filter

b)

b. Determining the access path to access the Filter from the browser

c)

c. Define the mechanism to resource accessing the Filter

d)

d. None of the others

28.

Which http method send by browser that asks the server to get the page only?

Select one:

a)

a. PUT

b)

b. POST

c)

c.. GET

d)

d. OPTION

29.

What is data-source?

Select one:

a)

a. Logical name is get from database's name

b)

b. Logical name binds to context path that is in the context.xml file and container read it at deploy time

c)

c. Logical name binds to database server address with its authentication and connection drivers

d)

d. None of the others

30.

Which statement is true about web container session management?

Select one

a)

a. To activate URL rewriting, the developer must used the HttpServletResponse.setURLRewriting method

b)

b. None of the others

c)

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)

d. Access to session-scoped attributes is guaranteed to be thread-safe by the web container

31.

Given the hyperlink:

http://localhost:8084/MyProject/index.jsp?param1=&param2=

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)

a. ANDnull

b)

b. AND

c)

c. nullAND

d)

d. nullANDnull

32.

Which of the following statements about the jsp:forward is false?
Select one:

a)

a. The jsp:forward element is used to redirect the request object

b)

b. To pass parameter names and values to the target file, you can use a jsp:param clause with jsp:forward element

c)

c. In the source JSP file, the code before the jsp:forward element is not processed.

d)

d. To redirect the request, the target file can be an HTML file, JSP file or a servlet

33.

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)

a. cookie

b)

b. request

c)

c. response

d)

d. session

34.

The EntityManager interface defines the methods that are used to interact with the persistence context.

Select one:

a)

T

b)

F

35.

Which of the following statements about the standard actions is true?

Select one:

a)

a. JSP uses standard actions for calling the JavaBean methods.

b)

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

c)

c. The attributes in standard action can not distinguish between uppercase and lowercase.

d)

d. All of the others.

36.

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

a)

a. WEB-INF/classes

b)

b. WEB-INF

c)

c. WEB-INF/lib

d)

d. WEB-INF/classes/com/abc

e)

e. WEB-INF/jars

37.

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. In standard action, the values in the attributes must be enclosed in double quotes

c)

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

d)

d. None of the others.

38.

Which security mechanism proves that data has not been tampered with during its transit through the network?

Select one:

a)

a. Data validation

b)

b. Data integrity

c)

c. Data privacy

d. Authorization

d)

e. Packet sniffing

e)

f. Authentication

39.

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

Select one:

a)

a. getCookies( )

b)

b. getHeader( )

c)

c. getHeaders( )

d)

d. getCookie( )

40.

Which of the important methods are present in servlet object?
Select one:

a)

a. init, processRequest, destroy

b)

b. init, doGet, doPost

c)

c. init, service, destroy

d)

d. init, service, doXXX

41.

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

Select one:

a)

a. Cookies

b)

b. Sessions

c)

c. Directives

d)

d. Scriptlets

42.

You can use the JSTL for tag to loop through most types of collections, including regular arrays.

Select one:

a)

T

b)

F

43.

An instance of entity bean is mapping with _____

Select one:

a)

a. Database

b)

b. Table Row

c)

c. Table column

d)

d. Table

44.

In EJB 2.0, which is the legal callback method in the bean class of a stateless session bean?

Select one:

a)

a. public void ejbCreate ( int sessionId) {}

b)

b. public void ejbCreate( ) {}

c)

c. public boolean ejbRemove ( ) {return true;}

d)

d. public void ejbFinalize( ) {}

45.

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)

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

b)

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

c)

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

d)

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

e)

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

46.

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)

a. <%@ taglib library="/accounting" prefix="acc"%>

b)

b. <%@ taglib uri="/accounting" prefix="acc"%>

c)

c. <%@ taglib name="/accounting" prefix="acc"%>

d)

d. <%@ taglib uri="/acc" prefix="/accounting"%>

47.

In WAR file, which of the following folders contains servlet class files?

a)

a. lib

b)

b. servlet

c)

c. None of the others

d)

d. classes

e)

e. tags

48.

The ________ method initializes the servlets
Select one:

a)

a. getInitParameter()

b)

b. service()

c)

c. init()

d)

d. getServletContext()

49.

Given the HTTP message fragment:
HTTP/1.1 500 Internal Server Errors
Choose the correct statement

Select one:

a)

a. The fragment message describes the status line of HTTP request message

b)

b. The fragment message describes the status line of HTTP response message

c)

c. The fragment message describes the header information of HTTP response message

d)

d. The fragment message describes the request line of HTTP response message

50.

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)

a. doPut

b)

b. doHead

c)

c. doGet

d)

d. None of the others.

e)

e. doPost

51.

Which of the following exceptions may be thrown by the _jspService( ) method? ( Select one)
Select one:

a)

a. javax.servlet.ServletException

b)

b. javax.servlet.jsp.JSPException

c)

c. javax.servlet.ServletException and java.io.IOException

d)

d. javax.servlet.ServletException and javax.servlet.jsp.JSPException

52.

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

a)

a. tags

b)

b. lib

c)

c. tlds

d)

d. classes

53.

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)

a. "Initialization Parameter is: null" returned to the requester

b)

b. A runtime error

c)

c. None of the others

d)

d. "Initialization Parameter is: null" written to the console

e)

e. "Initialization Parameter is: Final Test" returned to the requester

54.

Which of the following statement is true about the Session Listeners?

Select one:

a)

a. ServletContextAttributeListener must not register in web deployment descriptor

b)

b. HttpSessionBindingListener must register in web deployment descriptor

c)

c. HttpSessionBindingListener must not register in web deployment descriptor

d)

d. ServletContextListener must not register in web deployment descriptor

55.

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)

a. B, D

b)

b. A, D

c)

c. B, C

d)

d. A, C

56.

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)

a. None of the others.

b)

b. redirect

c)

c. forward

d)

d. include

57.

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

a)

a. 504

b)

b. 503

c)

c. 404

d)

d. 403

58.

The ________ method returns a string containing the value of the named initialisation parameter
Select one:

a)

a. jspInit

b)

b. getInitParameter()

c)

c. init()

d)

d. getServletConfig()

59.

_____ sends a request to an object and includes the result in a JSP file.

a)

a. import directive

b)

b. <jsp:include>

c)

c. include directive

d)

d. <jsp:forward>

60.

Which of the following statements are correct and true for Controller component?

Select one:

a)

a. There is only one controller in MVC architecture based on JSP Model 2

b)

b. Controller class access the database through View component

c)

c. There can be many number of controllers in MVC architecture

d)

d. The Controller is typically a JSP that receives requests from the browser

61.

Which of the following statements about Web Container is true?

a)

a. The performance of a servlet is independent of the efficiency of the container

b)

b. Container is a program, which manages the execution of servlets

c)

c. The Web Container takes request from a servlet and passes it to a Web Server for processing

d)

d. A Web application is accessible to all users connected to the Web e. None of the others

62.

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

Select one:

a)

a. getHeaders( )

b)

b. getHeader( )

c)

c. getCookies( )

d)

d. getCookie( )

63.

Which is a benefit of precompiling a JSP page?

a)

a. It provides the ability to debug runtime errors in the application.

b)

b. It avoids execution of the _jspService method on the first request.

c)

c. It avoids initialization on the first request.

d)

d. It provides better performance on the first request for the JSP page.

64.

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)

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

b)

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

c)

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

d)

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

e)

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

65.

Message Driven Beans ( MDBs) are designed to function as: ( Select one)

Select one:

a)

a. Synchronous message consumer

b)

b. Synchronous message publisher

c)

c. Asynchronous message publisherd. Asynchronous message consumer

d)

d. Asynchronous message consumer

66.

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)

a. The EVAL_PAGE constant is a valid return value for the doEndTag method.

b)

b. The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method

c)

c. The doStartTag method is called once

d)

d. The SKIP_PAGE constant is a valid return value for the doStartTag method.

e)

e. The doAfterBody method is NOT callec

67.

Which of the following statement is false about security mechanism used in Web application?

Select one:

a)

a. None of the others.

b)

b. In HTTP digest authentication, the server has the digest value of password based on a hash function.

c)

c. In form-based authentication, an error page is shown at user's side if the login failed.

d)

d. In basic security mechanism, the Web browser never pops-up a login page

68.

In which two locations can library dependencies be defined for a web application?

Select one or more:

a)

a. the /META-INF/MANIFEST.MF manifest file

b)

b. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath

c)

c. the web application deployment descriptor

d)

d. the /META-INF/dependencies.xml file

69.

Which implicit object is used in a JSP page to retrieve values associated with entries in the deployment descriptor?

a)

a. application

b)

b. config

c)

c. session

d)

d. request

70.

Which of information are needed when declaring the web resource collection in the deployment descriptor?

a)

a. The users allowed access to the web resource

b)

b. The URL pattern that requires authorization

c)

c. None of the others

d)

d. The authentication mechanism required by the web resource

71.

If the bean needs to hold information about the client across method invocations then .... should be used. ( select the best option)
Select one:

a)

a. None of the others.

b)

b. stateless session beanc. stateful session bean

c)

c. stateful session bean

d)

d. session bean

72.

Message Driven Beans ( MDBs) can be directly accessed by internal or external clients.

a)

a. True

b)

b. False

73.

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)

a. <% int count = 0;
if ( request.getSession( false) == null ) count++; %>

b)

b. <%@ int count = 0; %>
<% if ( request.getSession( false) == null ) count++; %>

c)

c. <%! int count = 0; %>
<% if ( request.getSession( false) == null ) count++; %>

d)

d. <%@ int count = 0;
if ( request.getSession( false) == null ) count++; %>

74.

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)

a. <jsp:include page="other.jsp"><jsp:param value="mary" name="user" /></jsp:include>

b)

b. <jsp:include page="other.jsp"><jsp:param param="user" value="mary"/></jsp:include>

c)

c. <jsp:include page="other.jsp"><jsp:param user="mary" /></jsp:include>

d)

d. <jsp:include page="other.jsp"><jsp:param paramName="user" paramValue="mary" /></jsp:include>

e)

e. <jsp:include page="other.jsp"><jsp:param name="mary" value="user" /></jsp:include>

75.

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)

a. It will flag a compile-time error because of an incorrect declaration.

b)

b. It will throw a runtime exception while executing the expression.

c)

c. If you remove "!", it will not flag any compile time or runtime errors.

d)

d. It will print "The value of aNum is 5" to the output.

e)

e. It will not flag any compile time or runtime errors and will not print anything to the output.

76.

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:

a)

(1) getInputStream()

b)

(2) getAttribute()

c)

(3) getContentLength()

d)

(4) getServerName()

e)

(5) getParameter()

77.

Which JSP standard action can be used to import content from a resource called foo.jsp?

Select one:

a)

a. <jsp:include file='foo.jsp' />

b)

b. <jsp:import file='foo.jsp' />

c)

c. <jsp:include page='foo.jsp' />

d)

d. <jsp:import>foo.jsp</jsp:import>

78.

The HttpServletResponse lets you:

Select one:

a)

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

b)

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

c)

c. All of the others.

d)

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

79.

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)

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

b)

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

c)

c. <!-- this is a comment -->

d)

d. <% // this is a comment %>

80.

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)

a. <jsp:include page="other.jsp" >
<jsp:param name="mary" value="user" />
</jsp:include>

b)

b. <jsp:include page="other.jsp" >
<jsp:param param="user" value="mary"/>
</jsp:include>

c)

c. <jsp:include page="other.jsp" >
<jsp:param value="mary" name="user" />
</jsp:include>

d)

d. <jsp:include page="other.jsp" >
<jsp:param paramName="user" paramValue="mary" />
</jsp:include>

81.

Which syntax is correct for JSP Scriptlets?
Select one:

a)

a. <%= code %>

b)

b. None of these

c)

c. <% code %>

d)

d. <%! code %>

82.

In EJB 3.0, Which statement about entity manager is true?

Select one:

a)

a. An entity manager obtained through resource injection in a stateful session bean can use a resource-local EntityTransaction for transaction control.

b)

b. A container-managed entity manager must be a JTA entity manager.

c)

c. An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses
JTA transaction control.

d)

d. An entity manager injected into session beans can use either JTA or resource-local transaction control.

83.

Which of the following are advantages of asynchronous messaging architectures? ( Choose three)

Select one or more:

a)

a. Better use of bandwidth

b)

b. Scalability

c)

c. Supports load balancing

d)

d. Provides sender with instant response

84.

Which of the following tag file directives control Tag processing?

(A) tag

(B) varReader

(C) include

(D) attribute

Select one:

a)

a. A, C, D

b)

b. B, C, D

c)

c. A, B, D

d)

d. A, B, C

85.

Which of the following scopes permit(s) its (their) attributes lasting in a duration of a session of a client?

Select one:

a)

a. session

b)

b. page

c)

c. context

d)

d. request

e)

e. session, context

86.

Which defines the welcome files in a web application deployment descriptor?
Select one:

a)

a. <welcome>
<welcome- file >/ welcome - jsp</welcome-file>
</welcome>
<welcome>
<welcome-file>/index-html</welcome-file>
</welcome>

b)

b. <welcome-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>

c)

c. <welcome-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

d)

d. <welcome>
<welcome-file>welcome.jsp</welcome </we1come >
</welcome >
<welcome-file>index.html<//welcome-file>
</we1come >

87.

Which of the followings will declare the variable x in the servlet class declaration?

Select one:

a)

a. All of the others.

b)

b.<%! int x=10; %>

c)

c.<%= int x=10; %>

d)

d.<% int x=10; %>

88.

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

Select one:

a)

a. classes

b)

b. tlds

c)

c. tags

d)

d. lib

89.

Which of the following would not be used in a client application performing point-to-point messaging?
Select one:

a)

a. Queue

b)

b. InitialContext

c)

c. Session

d)

d. Topic

90.

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

Select one:

a)

a. jar -war myfile.war

b)

b. jar -cvf myfile.war

c)

c. jar -cfv myfile.war *.class

d)

d. jar -tvf myfile.war .

e)

e. None of the others.

91.

Which defines the welcome files in a web application deployment descriptor?

Select one:

a)

a. <welcome>
<welcome- file >/ welcome - jsp</welcome-file>
</welcome>
<welcome>
<welcome-file>/index-html</welcome-file>
</welcome>

b)

b. <we1come-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

c)

c. <we1come-file-list>
<welcome-file> welcome .jsp</welcome-file>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>

d)

d. <welcome>
<welcome-file>welcome.jsp</welcome </we1come >
</welcome >
<welcome-file>index.html<//welcome-file>
</we1come >

92.

The empty operator in EL language returns true value for ______

a)

a. Only null value

b)

b. None of the others.

c)

c. null, empty Strings, empty arrays, and empty collections

d)

d. Only empty Strings because the null value in EL is converted to empty String

93.

Which is a benefit of precompiling a JSP page?

Select one:

a)

a. It avoids initialization o

b)

b. It provides better performance on the first request for the JSP page.

c)

c. It avoids execution of the _jspService method on the first request.

d)

d. It provides the ability to debug runtime errors in the application.

94.

Which of the options is incorrect about explain the various scope values for <jsp:useBean> tag.

Select one:

a)

a. page

b)

b. application

c)

c. session

d)

d. response

95.

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)

a. create a user called vip in the security realm

b)

b. define a security-role named vip in the deployment descriptor

c)

c. None of the others

d)

d. declare a security-role-ref for vip in the deployment descriptor

e)

e. define a group within the security realm and call it vip

96.

Which of the following statements about the JavaBean is true?
Select one:

a)

a. All of the others.

b)

b. It is impossible initialise the JavaBeans with arguments using jsp:useBean.

c)

c. The public methods give access to the properties of the bean.

d)

d. JavaBean component property must only be write-only format

97.

Given the HTTP message fragment: HTTP/1.1 500 Internal Server Errors Choose the correct statement Select one:

a)

a. The fragment message describes the request line of HTTP response message

b)

b. None of the others

c)

c. The fragment message describes the status line of HTTP response message

d)

d. The fragment message describes the status line of HTTP request message

e)

e. The fragment message describes the header information of HTTP response message

98.

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)

a. The program gives a syntax error because of the statement <%=test%>

b)

b. The program gives a syntax error because of the statement <% String myName=request.getParameter("name");%>

c)

c. The program gives a syntax error because of the statement <% String test= "Welcome " + myName; %>

d)

d. None of the others.

e)

e. The page display "Welcome John"

99.

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)

a. expression

b)

b. scriptlet

c)

c. None of the others

d)

d. declaration e. comment

100.

Which method returns the actual length of the request sent by the client? Select one:

a)

a. getContentLength()

b)

b. None of the others

c)

c. getParameter()

d)

d. getServerName()

e)

e. getAttribute()

101.

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)

a. String getInitializedParameter(String name);

b)

b. String getInitParameter(String name);

c)

c. All of the others.

d)

d. String getContextParameter(String name);

102.

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)

a. getOutputStream

b)

b. getBinaryStream

c)

c. getStream

d)

d. getWriter

103.

Which of the following statements about Web Container is true? Select one:

a)

a. Container is a program, which manages the execution of servlets

b)

b. A Web application is accessible to all users connected to the Web

c)

c. The performance of a servlet is independent of the efficiency of the container

d)

d. The Web Container takes request from a servlet and passes it to a Web Server for processing

e)

e. None of the others

104.

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

a)

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

b)

b. There is no XML equivalent of include directive.

c)

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

d)

d. None of the others

e)

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

105.

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. excption

b)

b. isErrorPage

c)

c. Error

d)

d. None of the others

e)

e. errorPage

106.

Name the implicit variable available to JSP pages that may be used to access all the other implicit objects. Select one:

a)

a. pageContext

b)

b. request

c)

c. response

d)

d. page

e)

e. out

107.

Which of the following statement is an expression in scripting element? Select one:

a)

a. <%= for(int i=0; i<n; i++) {out.println(i)} %>

b)

b. <%= x + y - 8 %>

c)

c. All of the others

d)

d. <%= x + y; %>

108.

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

a)

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

b)

b. None of the others

c)

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

d)

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

109.

Which of the following statements about Request and Response message structure is false? Select one:

a)

a. Request message structure consists of request line and header information

b)

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

c)

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

d)

d. None of the others

110.

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)

a. = sum = sum + j;

b)

b. sum = sum + j

c)

c. = sum = sum + j

d)

d. sum = sum + j;

111.

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

a)

a. Servlets are portable

b)

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

c)

c. None of the others

d)

d. Servlets are easy to use

112.

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

a)

a. within the page directive of the JSP page

b)

b. within a method called jspInit

c)

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

d)

d. within the XML element

113.

In a JSP life cycle, which of the following phases produces a Java Servlet (with extension *.java) file? Select one:

a)

a. None of the others

b)

b. Initialization

c)

c. Instantiation

d)

d. Compilation

e)

e. Translation

114.

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

a)

a. request.exception

b)

b. error

c)

c. throwable

d)

d. None of the others

e)

e. exception

115.

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)

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

b)

b. None of the others

c)

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

d)

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

e)

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

116.

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)

a. include

b)

b. forward

c)

c. None of the others.

d)

d. redirect

117.

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)

a. service

b)

b. None of the others

c)

c. processRequest

d)

d. doPost

e)

e. doGet

118.

Which object(s) can be used in JSP without declaring or initializing?
Select one:

a)

a. Server object

b)

b. Java objects

c)

c. Request object

d)

d. Implicit objects

e)

e. None of the others

119.

User-defined Servlets use two methods such are: Select one:

a)

a. init and post

b)

b. get and post

c)

c. init and destroy

d)

d. init and get

e)

e. None of the others

120.

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)

a. None of the others

b)

b. 2, 3

c)

c. 1

d)

d. 1, 4

e)

e. 2

121.

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)

a. The browser will print either hello or hi based upon the return value of random.

b)

b. The JSP file will not compile.

c)

c. The string hello will always get printed.

d)

d. The string hi will always get printed.

e)

e. None of the others.

122.

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)

a. \doc-root\dd.xml

b)

b. \doc-root\WEB-INF\dd.xml

c)

c. \doc-root\WEB_INF\web.xrnl

d)

d. \doc-root\WEB-INF\web.xml

e)

e. \doc-root\WEB_INF\dd.xml
f. None of the others
g. \doc-root\web.xml


123.

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)

a. The first fragment text describes the HTTP Response

b)

b. The second fragment text describes the HTTP Request

c)

c. None of the others

d)

d. The first fragment text describes the HTTP Request

124.

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. a status line, some response headers, and the document.

b)

b. None of the others

c)

c. a status line, some response headers, a blank line, and the document.

d)

d. a status line, a blank line, and the document.

e)

e. a blank line, a status line, some response headers and the document.

125.

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)

a. The program gives a syntax error because of the statement 6

b)

b. None of the others

c)

c. The program gives a syntax error because of the statement 7.

d)

d. The program prints "Welcome John"

e)

e. The program gives a syntax error because of the statement 5.

126.

Which of these are true about deployment descriptors?

Select one:

a)

a. The servlet-mapping element, if defined, must be included within the servlet element.

b)

b. The order of elements in deployment descriptor is important. The elements must follow a specific order

c)

c. The elements of deployment descriptor are case insensitive

d)

d. The web-app element must include the servlet element

e)

e. None of the others

127.

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)

a. An IllegalArgumentException is thrown.

b)

b. A blank page is returned to the client.

c)

c. "What's your name?" is returned to the client.

g. None of the others.

d)

d. An IllegalStateException is thrown.
e. Won't execute because of a compilation error.

e)

f. "What's" is returned to the client.

128.

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. request

c)

c. application

d)

d. session

129.

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)

a. None of the others

b)

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

c)

c. <!-- this is a comment -->

d)

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

e)

e. <% // this is a comment %>

130.

Which HTTP method represents a request for information about the supported methods on an HTTP server?
Select one:

a)

a. None of the others

b)

b.. HEAD

c)

c. OPTIONS

d)

d. TRACE

e)

e. GET