Final Exam Paper (Volume)
Course Name: JAVA WEB Exam Mode: Open ( ) Closed (√)
Question No. I II III IV V VI Total Marks
Signature of the Marks Holder
Score
Note to Candidates. ** 4 pages, please check if there are any missing pages in the question paper. 2. Candidates are not allowed to take the question paper and answer sheet out of the examination room after the examination.
I. Multiple Choice (1 point per question, *** 20 points)
Score Marker
1. The processing file to which the data in the form is to be submitted is specified by the ( ) attribute of the form.
A. method B. name C. action D. None of the above 2. To run a JSP program, the following statements are incorrect ( )
A. A Servlet container such as Tomcat needs to be installed on the server side. B. The client side needs to install Servlet containers, such as Tomcat. C. The server side needs to install the JDK.
D. The client side needs to install a browser, such as IE.
3. When publishing a Web application, it is common to place the Web application directory and files in the ( ) directory of Tomcat
.
A. work B. temp C. webapps D. conf 4. The following statements about the HTTP protocol are incorrect ( )
A. The HTTP protocol is the main protocol used by Web applications
B. The HTTP protocol is a Hypertext Transfer Protocol (HTTP),
B. HTTP is a Hypertext Transfer Protocol (HTTP),
based on the request/response model.
C. HTTP is a stateless protocol.
D. HTTP can save
passed information if the request and response messages are not sent and delivered successfully.
5. The following descriptions of Servlets are incorrect. ( ).
A. A Servlet is a class in Java
B. A Servlet is a server-side Java application that sits inside a Web server C. A Servlet can be interpreted and executed by the client's browser
D. The Web server that loads the Servlet must contain a Java virtual machine that supports Servlets. 6. The following is not a JSP directive: ( )
A. include B. import C. page D. taglib 7. The ( ) action is used to redirect to another page.
A. next B. forward C. include D. param 8. In the project has created a JavaBean, the class is: bean.student, the bean has
has a name attribute, then the following tags are used correctly: ( )
A. <jsp. useBean id="student" class="Student" scope="session">
</jsp:useBean>
B. <jsp:useBean id="student" class="Student " scope="session">
</jsp:useBean>
C.<jsp:useBean id="student" class="bean.Student" scope="session">
</jsp:useBean id="student" class="bean.student" scope="session">
& lt;/jsp:useBean>
D. <jsp:getProperty name="name" property="student"/>
9. Of the following options, ( ) accurately fetches the input of a text box on the request page (the text box name is name) ).
A. request.getParameter(name) B. request.getParameter("name") C. request.getParameterValues(name)
JAVA WEB DEVELOPMENT APPLICATIONS Page 2 *** 6
D. request.getParameterValues("name")
10. The method to use for redirection with the response object is ( ).
A. getAttribute B. setContentType C. sendRedirect D. setAttribute
11. The method used in the session object to set the value of the attribute with the specified name and store it in the session pair
image is ( ).
A. setAttribute B. getAttributeNames C. getValue D. getAttribute
12. You can get all the
variable names in the application object with the ( ) method in the application object.
A. getServerInfo B. nextElements() C. removeAttribute D. getRealPath 13. Incorrectly stated about struts 2 ( )
A. Struts is a framework used to simplify the development of MVC frameworks (Framework).
A. Struts is a framework for simplifying the development of MVC frameworks (Framework) B. Struts 2 does not need to be configured for the application C. Struts 2 contains a rich set of tags
D. Struts 2 uses the core technology of WebWork 14. Web applications do not include the way to enjoy the data **** ( ).
A. request-based ****enjoyment B. session-based ****enjoyment C. page-based ****enjoyment D. application-based ****enjoyment
15. To output 2+3=${2+3} on a page, the corresponding program code should be ( ).
A. 2+3=\${2+3} B. 2+3=${2+3} C. 2+3=/${2+3} D. None of the above
16. The following is related to the ELs ". " and "[ ]" access operators in EL are incorrect ( )
A. Both are equivalent in some cases
B. The "[ ]" operator is mainly used to access arrays, lists, or other collections C. Both can be implemented if values are to be taken dynamically
D. When the name of the property to be accessed contains some special characters such as . or ? and other symbols that are not letters or numbers
, you must use "[ ]"
17. To use JSTL's core tag library, you need to add the following declaration statement to the beginning of the JSP source file
( )
A. <%@ taglib prefix="c"
uri=":80/software/home.html B. telnet://bdysseu.bbb.com:70 C. ftp://ftp.btbu.edu.cn D. www0.btbu.edu.cn
20. page directive is used to define global properties in a JSP file. The following description of the usage of this directive is not
correct: ( )
A. <%@ page %> acts on the entire JSP page.
B. Multiple <%@ page %> directives can be used in a single page
JAVA WEB DEVELOPMENT APPLICATIONS Page 3 of 6 *** 6
C. To enhance the readability of the program, it is recommended, but not mandatory, that the <%@ page %> directive be placed at the beginning of the JSP file.
D. Attributes in the <%@ page %> directive can appear only once.
II. Fill in the blanks (2 points per blank, ***20 points)
Score Marker
1. When writing Servlets, you need to inherit the class, and declaring doGet() and doPost() in a Servlet requires two parameters of type and.
2. jsp main built-in objects are: , exception, pageContext, request, , _____ __, out, config, page. 3. use useBean action tag when the scope attribute has four options, the role of the scope of the smallest to the largest is the _________, _________, _________, _________, where _________ means that when the browser is closed this javabean expires, ____ _____ means that when the server is closed this javabean expires.
4. The three commonly used dynamic web technologies are _________, _________, _________, or 3P technology.
5. JSP using JDBC to operate the database steps: (1) load the driver, call ___________ will automatically load the driver class; (2) to establish a connection, if the connection string is:
String url = "jdbc:mysql://localhost/" + dbName +"? user=" +userName +"&password=" +userPwd, where dbName, userName and userPwd 3 represent , respectively, the database and , (3) to establish the StateMent; (4) , the execution of sql statements, which, querying the contents of the table in the database is Statement interface using the __ __________ method; (5) close the database. Third, short answer questions: (6 points per question, ***30 points)
Score Marker
1. What is the default port of the Tomcat server? How to change the port of tomcat
2. What is a cookie? What is the purpose of a cookie?
3. Briefly describe the difference between dynamic and static include in JSP?
4. Briefly explain the difference between POST and GET in forms.
5. What do M, V, and C in MVC refer to? Please describe their respective roles. Fourth, programming questions (15 points per question, *** 30 points)
"JAVA WEB DEVELOPMENT APPLICATIONS" Page 4 *** 6
Score Marker
1. Write a simple JavaBean that accesses its attributes through the access operator of EL. Answer: The file userLogin.java defines a user bean with 3 attributes Name, Password and Email with the following code:
package bean;
public class userLogin { private String userName; private String (1) private String email; public userLogin() { userName = "Li Ping"; password = "123";
email = "liping@sohu.com";
}
public void setuserName(String userName) { this.userName = userName; }
public String getuserName() { return this.userName; }
public void setpassword(String password) { this.password = password; }
public String getpassword() {
return this. public void setemail(String email) { this.email = email;
}
public String getemail() { return this.email; }
}
File accessBean.jsp uses EL's access operator to get the properties of a JavaBean with the following code:
<%@ page contentType="text/html; charset=gb2312"%> (2)
<jsp:useBean id="user" class="bean.userLogin" scope="session"> </jsp:useBean> <html> <header>
<title> Using access operators to access the JavaBean properties</title>
</head> <body> <! --Accessing Properties of a JavaBean via EL Access Operators --> Username: (3) <br>
Password: (4)
<br>
Email: (5)
JAVA WEB DEVELOPMENT APPLICATIONS PAGE 5 *** 6