Questions and CORRECT Answers
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 -
CORRECT ANSWER -c
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" - CORRECT ANSWER -e
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 - CORRECT ANSWER -d
,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() - CORRECT ANSWER -a
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); - CORRECT ANSWER -b
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 - CORRECT ANSWER - a,d
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 - CORRECT ANSWER -a
,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"/> - CORRECT ANSWER -c
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 - CORRECT ANSWER -e
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 - CORRECT ANSWER -a
, 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; %> - CORRECT ANSWER -b
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 - CORRECT
ANSWER -c
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 - CORRECT ANSWER -b
Assume that you need to write a JSP page that adds numbers from one to ten, and then print the
output.
<% int sum = 0;