PRJ321-FE (Full) || 100% Verified Answers.
A correct answers Which of the following statements are correct about the status of the Http
response? Select the one correct answer
A. A status of 200 to 299 signifies that the request was successful.
B. A status of 300 to 399 is informational messages.
C. A status of 400 to 499 indicates an error in the server
D. A status of 500 to 599 indicates an error in the client.
A correct answers Classes HttpServlet and GenericServlet implement the ___ interface.
A. Servlet
B. Http
C. HttpServletRequest
D. HttpServletResponse
A correct answers You have to send a gif image to the client as a response to a request.
Which of the following calls will you have to make?
A. response.setContentType("image/gif");
B. response.setType("application/gif");
C. response.setContentType("application/bin");
D. response.setType("image/gif");
C correct answers Consider the code of ReportServlet servlet of a web application. Assuming
generateReport() is valid method and have no problems, which of the following statement
about these servlet is true?
A. ReportServlet will throw exception at runtime.
B. ReportServlet.java won't compile.
C. ReportServlet.java will compile and run without any problems.
A correct answers Which method of ReportGeneratorServlet will be called when the user
clicks on the URL shown by the following HTML.
Assume that ReportGeneratorServlet does not override the service(HttpServletRequest,
HttpServletResponse) method of the HttpServlet class.
(Choose one)
A. doGet(HttpServletRequest, HttpServletResponse);
B. doPost(HttpServletRequest, HttpServletResponse);
C. doHead(HttpServletRequest, HttpServletResponse);
D. doOption(HttpServletRequest, HttpServletResponse);
E correct answers 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());
}
A. Won't execute because of a compilation error.
,B. An IllegalArgumentException is thrown.
C. An IllegalStateException is thrown.
D. A blank page is returned to the client.
E. "What's" is returned to the client.
F. "What's your name?" is returned to the client.
C correct answers Following is the code for doGet() and doPost() methods of TestServlet.
Which of the statement is correct?
A. This will only work for HTTP GET requests
B. This will only work for HTTP POST requests
C. This will work for HTTP GET as well as POST requests.
D. It'll throw an exception at runtime, as you cannot call doGet() from doPost().
E. It'll throw an exception at runtime only if a POST request is sent to it.
A correct answers Which of the following is indicated by URL, which is used on the
Internet?
A. Information resources(sources) on the Internet
B. E-mail addresses for use in the Internet
C. IP addresses of servers connected to the Internet
D. Owners of PCs connected to the Internet
D correct answers Identify correct statement about a WAR file.(Choose one)
A. It is an XML document.
B. It cannot be unpackaged by the container.
C. It is used by web application developer to deliver the web application in a single unit.
D. It contains web components such as servlets as well as EJBs.
A correct answers See the extract from web.xml of web application "mywebapp" on server
named myserver, runs on port 8080:
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/bservlet.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletC</servlet-name>
<url-pattern>*.servletC</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletD</servlet-name>
<url-pattern>/dservlet/*</url-pattern>
</servlet-mapping>
Given that a user enters the following into her browser, which (if any) of the mapped servlets
will execute? (Choose one.)
,http://myserver:8080/mywebapp
A. ServletA
B. ServletB
C. ServletC
D. ServletD
A correct answers A parameter is defined in a <context-param> element of the deployment
descriptor for a web application. Which of the following statements is correct?
A. It is accessible to all the servlets of the webapp.
B. It is accessible to all the servlets of all the webapps of the container.
C. It is accessible only to the servlet it is defined for.
A correct answers A .................... manages the threading for the servlets and JSPs and
provides the necessary interface with the Web server.
A. Web Container
B. EJB Container
C. Servlets
D. Applets
A correct answers A ________has a name, a single value, and optional attributes such as a
comment, path and domain qualifiers, a maximum age, and a version number.
A. Cookie
B. Session
C. Request
D. Response
D correct answers Which of the following method calls can be used to retrieve an object from
the session that was stored using the name "roleName"?
A. getObject("roleName");
B. getValue("roleName");
C. get("roleName");
D. getAttribute("roleName");
E. getParameter("roleName");
D correct answers Which is NOT a standard technique for a session be definitely invalidated?
A. The container is shutdown and brought up again.
B. No request comes from the client for more than "session timeout" period.
C. A servlet explicitly calls invalidate() on a session object.
D. If the session time out is set to 0 using setMaxInactiveInterval() method.
A correct answers Which method can be invoked on a session object so that it is never
invalidated by the servlet container automatically?
A. setMaxInactiveInterval(-1)
B. setTimeOut(Integer.MAX_INT)
C. setMaxInactiveInterval(Integer.MAX_INT)
D. setTimeOut(-1)
A correct answers What are the different scope values for the ‹jsp:useBean›? (Choose one
correct answer)
A. session, page, application, request
, B. session, page, application, global
C. session, page, application, context
D. session, page, response, request
A correct answers 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?
A. The page display "Welcome John"
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. The program gives a syntax error because of the statement
<%=test%>
A correct answers Name the default value of the scope attribute of <jsp:useBean>
A. page
B. session
C. application
D. request
B correct answers 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.
<%! String myName=request.getParameter();%>
<% String test= "welcome" + myName; %>
<%= test%>
What is the output?
A. The program prints "Welcome John"
B. The program gives a syntax error because of the statement <%! String
myName=request.getParameter();%>
C. The program gives a syntax error because of the statement <% String test= "welcome" +
myName; %>
D. The program gives a syntax error because of the statement <%= test%>
A correct answers Select the correct directive statement insert into the first line of following
lines of code (1 insert code here):
Today's Date is <%=new Date()%>
A. <%@page import='java.util.*' %>
B. <%@import package='java.util.*' %>
C. <%@ package import ='java.util.*' %>
D. <%! page import='java.util.*' %>
A correct answers Which of the following statements are correct about the status of the Http
response? Select the one correct answer
A. A status of 200 to 299 signifies that the request was successful.
B. A status of 300 to 399 is informational messages.
C. A status of 400 to 499 indicates an error in the server
D. A status of 500 to 599 indicates an error in the client.
A correct answers Classes HttpServlet and GenericServlet implement the ___ interface.
A. Servlet
B. Http
C. HttpServletRequest
D. HttpServletResponse
A correct answers You have to send a gif image to the client as a response to a request.
Which of the following calls will you have to make?
A. response.setContentType("image/gif");
B. response.setType("application/gif");
C. response.setContentType("application/bin");
D. response.setType("image/gif");
C correct answers Consider the code of ReportServlet servlet of a web application. Assuming
generateReport() is valid method and have no problems, which of the following statement
about these servlet is true?
A. ReportServlet will throw exception at runtime.
B. ReportServlet.java won't compile.
C. ReportServlet.java will compile and run without any problems.
A correct answers Which method of ReportGeneratorServlet will be called when the user
clicks on the URL shown by the following HTML.
Assume that ReportGeneratorServlet does not override the service(HttpServletRequest,
HttpServletResponse) method of the HttpServlet class.
(Choose one)
A. doGet(HttpServletRequest, HttpServletResponse);
B. doPost(HttpServletRequest, HttpServletResponse);
C. doHead(HttpServletRequest, HttpServletResponse);
D. doOption(HttpServletRequest, HttpServletResponse);
E correct answers 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());
}
A. Won't execute because of a compilation error.
,B. An IllegalArgumentException is thrown.
C. An IllegalStateException is thrown.
D. A blank page is returned to the client.
E. "What's" is returned to the client.
F. "What's your name?" is returned to the client.
C correct answers Following is the code for doGet() and doPost() methods of TestServlet.
Which of the statement is correct?
A. This will only work for HTTP GET requests
B. This will only work for HTTP POST requests
C. This will work for HTTP GET as well as POST requests.
D. It'll throw an exception at runtime, as you cannot call doGet() from doPost().
E. It'll throw an exception at runtime only if a POST request is sent to it.
A correct answers Which of the following is indicated by URL, which is used on the
Internet?
A. Information resources(sources) on the Internet
B. E-mail addresses for use in the Internet
C. IP addresses of servers connected to the Internet
D. Owners of PCs connected to the Internet
D correct answers Identify correct statement about a WAR file.(Choose one)
A. It is an XML document.
B. It cannot be unpackaged by the container.
C. It is used by web application developer to deliver the web application in a single unit.
D. It contains web components such as servlets as well as EJBs.
A correct answers See the extract from web.xml of web application "mywebapp" on server
named myserver, runs on port 8080:
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/bservlet.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletC</servlet-name>
<url-pattern>*.servletC</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletD</servlet-name>
<url-pattern>/dservlet/*</url-pattern>
</servlet-mapping>
Given that a user enters the following into her browser, which (if any) of the mapped servlets
will execute? (Choose one.)
,http://myserver:8080/mywebapp
A. ServletA
B. ServletB
C. ServletC
D. ServletD
A correct answers A parameter is defined in a <context-param> element of the deployment
descriptor for a web application. Which of the following statements is correct?
A. It is accessible to all the servlets of the webapp.
B. It is accessible to all the servlets of all the webapps of the container.
C. It is accessible only to the servlet it is defined for.
A correct answers A .................... manages the threading for the servlets and JSPs and
provides the necessary interface with the Web server.
A. Web Container
B. EJB Container
C. Servlets
D. Applets
A correct answers A ________has a name, a single value, and optional attributes such as a
comment, path and domain qualifiers, a maximum age, and a version number.
A. Cookie
B. Session
C. Request
D. Response
D correct answers Which of the following method calls can be used to retrieve an object from
the session that was stored using the name "roleName"?
A. getObject("roleName");
B. getValue("roleName");
C. get("roleName");
D. getAttribute("roleName");
E. getParameter("roleName");
D correct answers Which is NOT a standard technique for a session be definitely invalidated?
A. The container is shutdown and brought up again.
B. No request comes from the client for more than "session timeout" period.
C. A servlet explicitly calls invalidate() on a session object.
D. If the session time out is set to 0 using setMaxInactiveInterval() method.
A correct answers Which method can be invoked on a session object so that it is never
invalidated by the servlet container automatically?
A. setMaxInactiveInterval(-1)
B. setTimeOut(Integer.MAX_INT)
C. setMaxInactiveInterval(Integer.MAX_INT)
D. setTimeOut(-1)
A correct answers What are the different scope values for the ‹jsp:useBean›? (Choose one
correct answer)
A. session, page, application, request
, B. session, page, application, global
C. session, page, application, context
D. session, page, response, request
A correct answers 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?
A. The page display "Welcome John"
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. The program gives a syntax error because of the statement
<%=test%>
A correct answers Name the default value of the scope attribute of <jsp:useBean>
A. page
B. session
C. application
D. request
B correct answers 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.
<%! String myName=request.getParameter();%>
<% String test= "welcome" + myName; %>
<%= test%>
What is the output?
A. The program prints "Welcome John"
B. The program gives a syntax error because of the statement <%! String
myName=request.getParameter();%>
C. The program gives a syntax error because of the statement <% String test= "welcome" +
myName; %>
D. The program gives a syntax error because of the statement <%= test%>
A correct answers Select the correct directive statement insert into the first line of following
lines of code (1 insert code here):
Today's Date is <%=new Date()%>
A. <%@page import='java.util.*' %>
B. <%@import package='java.util.*' %>
C. <%@ package import ='java.util.*' %>
D. <%! page import='java.util.*' %>