Java Web training group B Testing Questions

Source: Internet
Author: User
(1) assume that there is a hello. jsp in the helloapp application, and its file path is as follows:
% Catalina_home %/webapps/helloapp/Hello. jsp
So what is the URL for accessing hello. jsp on the browser? (Single choice)
Option:
(A) http: // localhost: 8080/Hello. jsp
(B) http: // localhost: 8080/helloapp/Hello. jsp
(C) http: // localhost: 8080/helloapp/Hello. jsp

(2) Suppose There Is A helloservlet class in the helloapp application, which is located under the org. javathinker package, then the class file of this class should be placed

Under what directory? (Single choice)
Option:
(A) helloapp/helloservlet. Class
(B) helloapp/WEB-INF/helloservlet. Class
(C) helloapp/WEB-INF/classes/helloservlet. Class
(D) helloapp/WEB-INF/classes/org/javathinker/helloservlet. Class

(3) assume that there is a helloservlet class in the helloapp application. Its configuration in the web. xml file is as follows:
<Servlet>
<Servlet-Name> helloservlet </servlet-Name>
<Servlet-class> org. javathinker. helloservlet </servlet-class>
</Servlet>

<Servlet-mapping>
<Servlet-Name> helloservlet </servlet-Name>
<URL-pattern>/Hello </url-pattern>
</Servlet-mapping>
So what is the URL for accessing helloservlet on the browser? (Single choice)
Option:
(A) http: // localhost: 8080/helloservlet
(B) http: // localhost: 8080/helloapp/helloservlet
(C) http: // localhost: 8080/helloapp/org/javathinker/Hello
(D) http: // localhost: 8080/helloapp/Hello

(4) What are the similarities and differences between the user's request to access the HTML page and the servlet? (Multiple options)
Option:
(A) Same: both use the HTTP protocol
(B) difference: the former web server directly returns the HTML page, and the latter web server calls the servlet method, and the servlet dynamically generates the HTML page
(C) Same: the former web server directly returns the HTML page, and the latter directly returns the source code of the servlet.
(D) difference: the latter must configure the URL path in Web. xml.
(E) difference: the former uses the HTTP protocol, and the latter uses the RMI protocol.

(5) who created the httpservletrequest object? (Single choice)
Option:
(A) The servlet container is responsible for creating an httpservletrequest object for each HTTP request.
(B) The servlet or JSP COMPONENT OF THE javaweb application is responsible for creating the servlet or JSP component. When the servlet or JSP component responds to the HTTP request, it is created first.

Httpservletrequest object

(6) which method should I call to obtain Request Parameters from an HTTP request? (Single choice)
Option:
(A) call the getattribute () method of the httpservletrequest object
(B) Call the getattribute () method of the servletcontext object
(C) Call the getparameter () method of the httpservletrequest object

(7) who created the servletcontext object? (Single choice)
Option:
(A) The servlet container is responsible for creating a servletcontext object for each HTTP request.
(B) The javaweb application is responsible for creating a servletcontext object for itself.
(C) The servlet container is responsible for creating the servlet container. When each javaweb application is started, the servlet container creates a servletcontext object.

(8) How should I implement jspforward1.jsp in jspforward1.jsp to forward requests to jspforward2.jsp? (Single choice)
Option:
(A) <a href = "jspforward2.jsp"> jspforward2.jsp </a>
(B) <JSP: Forward page = "jspforward2.jsp">

(9) What is the output result when the browser visits the following JSP page for the second time? (Single choice)

<! % Int A = 0; %>
<%
Int B = 0;
A ++;
B ++;
%>

A: <% = A %> <br>
B: <% = B %>

Option:
(A) A = 0 B = 0
(B) A = 1 B = 1
(C) A = 2 B = 1

(10) which of the following statements is true? (Single choice)
Option:
(A) For each HTTP request requesting access to maillogin. jsp, the servlet container creates an httpsession object.
(B) Each httpsession object has a unique ID.
(C) The Java Web application must assign a unique ID to the httpsession.

(11) What should I do if I do not want JSP pages to support sessions? (Single choice)
Option:
(A) call the invalidate () method of httpsession
(B) <% @ page session = "false/">

(12) In the tag processing class, how does one access Shared data within the session range? (Multiple options)
Option:
(A) Define the session member variable in the tagsupport class and directly call its getattribute () method.
(B) The pagecontext member variable is defined in the tagsupport class of the tag processing class. The current member variable is obtained through its getsession () method.

Httpsession object, and then call the getattribute () method of the httpsession object.
(C) pagecontext. getattribute ("attributename", pagecontext. session_scope)

(13) which of the following options are the valid return values of the dostarttag () method of the tagsupport class? (Multiple options)
Option:
(A) Tag. skip_body
(B) Tag. skiy_page
(C) Tag. eval_body_include
(D) Tag. eval_page

(14) Can the following code be compiled? If it can be compiled, what print results will be obtained during the runtime? (Single choice)
Request. setattribute (/"count/", new INTEGER (0 ));
Integer COUNT = request. getattribute (/"count /");
Option:
A) cannot be compiled. B) can be compiled and run normally.
C) the code is compiled, but classcastexception is thrown during runtime.

Answer:
(1) C (2) D (3) D (4) a, B, d (5) A (6) C (7) C (8) B (9) C (10) B
(11) B (12) B, c (13) a, c (14)
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.