Computer Z20- Week 3-4 homework Total score: 100 points Score: 74.2 points
1. Fill in the blanks, easy, 5 points
In the web.xml file, the first '/' in <url-pattern>/xxxxServlet</url-pattern> means __________.
student answer
The root directory of the current web application
2. Fill in the blanks, easy, 5 points
When the Servlet container starts, it will create a unique ____________ object for each web application to represent the current web application.
student answer
ServletContext
3. Multiple choice questions, simple, 5 points
In the following options, which configuration file needs to be configured after creating the Servlet class ()
A.web-config.xml
B.application.xml
C.config.xml
D.web.xml
4. Fill in the blanks, easy, 5 points
When a user accesses a JSP file, for HTML tags and text, directly call the _______________ method in the converted Servlet to output it as a string.
Answer
out
5. Multiple choice questions, difficult, 5 points
Among the following options, the option that can increase the value of the "counter" counter in the user session by 1 is ()
A.
HttpSession session = request.getSession(true); int ival = session.getAttribute(“counter”); if(ival == null){ ival = 1; }else{ Ival = ival + 1; } session.setAttribute (“counter”, ival);
B.
HttpSession session = request.getSession (true); Integer ival = (Integer) session.getAttribute (“counter”); Session.setAttribute (“counter”, ival + 1);
C.
HttpSession session = request.getSession (true); Integer ival = (Integer) session.getAttribute (“counter”); if(ival == null){ Ival = new Integer (1); } else { Ival = new Integer (ival.intValue () + 1); } session.setAttribute (“counter”, ival);
D.
HttpSession session = request.getSession (); int ival = session.getAttribute(“counter”); if (ival == null){ ival = 1; } else { ival = ival + 1; } session.setAttribute (“counter”, new Integer (ival));
6. Multiple choice questions, simple, 5 points
In Java EE, the interface that defines the getSession() method is ()
A.HttpServlet
B.HttpSession
C.HttpServletRequest
D.HttpServletResponse
7. Multiple choice questions, simple, 5 points
Among the following options, the correct statement about obtaining the HttpSession object is ()
A. Create an HttpSession object with the new statement
B. Call the getSession() method of the ServletRequest object
C. Call the getSession() method of the ServletConfig object
D. None of the above statements are correct
8. Multiple choice questions, simple, 5 points
Among the following options, the interface that needs to be implemented to write a filter is ( )
A.javax.servlet.Servlet
B.java.servlet. Filter
C.javax.servlet. Listener
D.javax.servlet. Filter
9. Multiple choice questions, simple, 5 points
In the filter's doFilter method, the method that allows the target resource to execute is ( )
A.FilterChain.doFilter(request,response)
B. No need to release, the target will be executed directly after filtering
C. Use forwarding to let the target resource execute
D. Use request redirection to let the target resource execute
10 . Multiple choice questions Moderate 5 points
Regarding the execution order of the Filter chain, it is determined by which element in the web.xml file ( )
A. The order of <filter> elements is determined
B. <filter-mapping> element order determination
C. <filter-class> element order determination
D. Determined by the order of filter class names
11. Multiple choice questions, simple, 5 points
Among the following options, the listener interface used to monitor the creation and destruction of ServletRequest domain objects is ( )
A.ServletRequestAttributeListener
B.ServletRequestListener
C.HttpServletRequestListener
D.ServletRequestActivationListener
12. Fill in the blanks, easy, 5 points
In the Servlet technical specification, three technologies of Servlet, Filter, and Listener are defined, and ____________ can intercept and modify the access request and response.
student answer
Filter
13. Multiple choice questions, simple, 5 points
Regarding JavaBean, which of the following statements is incorrect? ( )
A. The JavaBean class must be specific and public, and have a parameterless constructor.
B. The class properties of JavaBean are private and must be accessed through public methods.
C. JavaBean, like Servlet, must be registered in the project's Web.xml before use.
D. The JavaBean property and the name of the form control can be well coupled to obtain the parameters submitted by the form.
14. Multiple choice questions, simple, 5 points
The object that the Servlet obtains the initialization parameters is ( ).
A.Request
B.Response
C.ServletConfig
D.ServletContext
15. Multiple choice questions, easy, 5 points
In the life cycle of JSP/Servlet, the method used for initialization is ().
A.doPost()
B.doGet()
C.init()
D.destroy()
16. Fill in the blanks, easy, 5 points
JavaBean is a ___ class, which must contain a ___ method.
student answer
java, no parameter construction
17. Fill in the blanks, easy, 5 points
The label using JavaBean in JSP is ___, and the purpose of id is ___.
student answer
<jsp:useBean class=BeanName id=Bean instance>, instantiate a Bean object
wrong answer
Answer
<jsp:userBeanclass="JavaBean name" id="JavaBean instance">, instantiate a JavaBean object
18. Fill in the blanks, easy, 5 points
The most widely used scope of JavaBean is ___.
Answer
application
19. Fill in the blanks, easy, 5 points
In the Servlet, the redirection method ___ method of the HttpServletResponse class is mainly used to realize the redirection, and the forwarding method ___ method of the ___ class is used to realize the forwarding function.
student answer
sendRedirect()、RequestDispatcher、forward()
correct answer
Answer
sendRedirect、RequestDispatcher、forward
20 . Multiple choice questions Moderate 5 points
When the scope attribute in the useBean tag takes the value page, the valid scope of the beans is ( ).
A. Current customers
B. Current page
C. Current server
D. All customers