JSP final exam review questions and answers

The following exercises are compiled for daily quizzes. Please correct me if there are any mistakes!
For knowledge points, please view the article: JSP Final Exam Review Key Points Outline.
Welcome to communicate together~
I wish you all good luck in the exam!

Test 1

1. Multiple choice questions


1. (Single choice question) When the user requests a jsp page, the JSP engine will execute the bytecode file of the page to respond to the customer’s request. The result of executing the bytecode file is ()
A. Send a JSP source file to Client
B. Send a Java file to the client
C. Send an HTML page to the client
D. Do nothing


2. (Single choice question) Which of the following incorrect descriptions of the fundamental differences between dynamic web pages and static web pages is (D) A. The HTML file returned by the server side of the static web page is stored in advance B. The HTML file returned by the server side of the dynamic web page is C. Static web page files generated by the program only have HTML tags and no program code.



D. There are only programs in dynamic web pages and no HTML code.


3. (Single choice question) Which of the following is not a WEB server ()
A. Tomcat
B. IIS
C. Apache
D.Java


4. (Single choice question) Which of the following statements is correct ( )
A.Apache is used as the server for websites developed with ASP technology
B.IIS is used as the server for websites developed with CGI technology
C.Tomcat is used as a server for websites developed with JSP technology
D.WebLogic is used as a server for websites developed with PHP technology


5. (Single choice question) The default port number of the Tomcat server is ( )
A. 80
B. 8080
C. 21
D. 2121


6. (Single choice question) What is not necessary for JSP to run ( )
A. Operating system
B. JavaJDK
C. Web server that supports Jsp
D.Database


7. (Single choice question) URL is the naming mechanism for resources on the Internet. URL consists of three parts ( )
A. Protocol, host DNS name or IP address, file name
B. Host, DNS name or IP address and file name, protocol
C. Protocol, file name, host name
D. Protocol, file name, IP address


8. (Single choice question) When multiple users request the same JSP page , the Tomcat server starts a ( )
A. process for each client.
B. Thread
C. Program
D. Service


9. (Single choice question) HTTP request, if the web page does not exist , the returned status code is ( )
A. 500
B. 404
C. 200
D. 403


10. (Single choice question) In the directory structure of the WEB application, the web page files should be placed in the ( ) directory of the project
A. src
B. META-INF
C. WebContent
D. lib


2. True or False Question
11. (True or False Question) Today’s more popular technology research and development models are implemented by B/S and C/S architectures.
right


12. (True or False question) Dynamic web page files can only contain dynamic program script codes and cannot contain HTML tags.
wrong


13. (True or False) The communication protocol used by the Internet is: TCP/IP
right


14. (True or False) The WAR package generated by the Eclipse development environment is placed in the lib directory of Tomcat and released.
wrong


15. (True or False Question) If you want to modify the Tomcat port number, you need to modify the /conf/server.xml file in Tomcat
right


16. (True or False) JSP will be compiled into Java Servlets by the JSP compiler
right

– 17. (True or False) Click File->New->Java Project (file→New→Dynamic Web Project)
in Eclipse to create a new Java Web project
wrong


18. (True or False) To package and publish a WEB project in Eclipse , you can right-click Export→WAR file , and the war package is the published package.
right


19. (True or False) Neither is open source
wrong


20. (True or False) The fundamental difference between dynamic web pages and static web pages is whether the HTML file returned by the server is stored in advance or generated by a dynamic web page program
right



Test2

1. Multiple choice questions

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here


2. Judgment questions


11. (True or False) W3C refers to the World Wide Web Consortium
right


12. (True or False) HTML tags are case-sensitive
wrong


13. (True or False) The background attribute in the HTML page <body> is used to set the color of the web page (bgcolor specifies the background color, and the background attribute specifies the background image of the document )
wrong


14. (True or False) <!–…--> is an HTML comment tag. Any content between the tags will be interpreted by the browser as a comment and will not in the browser.
right

– 15. (True or False) The larger the value of the size attribute
in the <font> tag , the larger the font size.
right


16. (True or False) The font in the <h1> tag is smaller than the font in the <h2> tag
wrong


17. (True or False) The <sub> tag indicates the font subscript
right


18. (True or False Question) Ordered lists can be nested, but unordered lists cannot be nested.
wrong


19. (True or False) Vector images are more colorful and richer than bitmaps
wrong


20. (True or False) The relative path refers to the path starting from the root directory of the WEB project
wrong

  • Hyperlinks, forms, redirects: paths starting with "/" are relative to the host root directory
    http://localhost:8080/
  • Forwarding, inclusion, <url-pattern>: The path starting with "/" is relative to the project root directory
    http://localhost:8080/project name/
  • Relative path without "/": access the path of the current file , not the directory where the current file is located


Test3

1. Multiple choice questions

  1. (Single-choice question) In HTML, the following ( ) can achieve table cross-column
    A. colspan attribute
    B. rowspan attribute (across rows)
    C. colspan label
    D. rowspan label


2. (Single choice question) In HTML, the ( ) attribute of the TD tag is used to create cells that span multiple rows
A. spancol
B. row
C. rowspan
D. span


3. (Single choice question) In HTML, the ( ) attribute of the <iframe> tag is used to set the address of the frame link page
A. src
B. href
C. target
D. id


4. (Single choice question) The basic grammatical structure of the table is ( )
A. <table><td><tr></tr></td></table>
B. <table><td></tr ><tr></td></table>
C. <tr><table><td></td></table></tr>
D. <table><tr><td></td></tr></table>

  • <tr> tag defines rows in HTML table
  • td, th define columns in HTML tables.
    The text inside the th element is usually rendered as centered bold text (table title).
    The text inside the td element is usually left-aligned normal text (table content).


5. (Single choice question) Among the following common attribute settings, ( ) is applicable to <iframe> tag
A. border="0" (the border around the display frame is frameborder)
B. frameborder="1" (specifies whether to display the border around the frame)
C. scrolling= "0" (specifies whether to display scroll bars in iframe, values ​​are yes, no, auto)
D. href="head.htm" (<iframe> tag hyperlink is src)


6. (Single choice question) In HTML, what is wrong with the form description ? ( )
A. Starting with the <form> tag and ending with the </form> tag
B. The action attribute refers to the address of the form submission
C. The method attribute Refers to the way the form is submitted
D. There can only be one form in a web page


7. (Single choice question) In HTML, the following ( ) attribute is used to set the address where the form is to be submitted
A. name
B. method (method of form submission)
C. action
D. id


8. (Single choice question) In HTML, which of the following statements to add a hidden field in a form is correct ( )
A. <input name="userid" value="invisible"/>
B. <input type=" file” name="userid" value="invisible"/>
C. <input type="hidden" name="userid" value="invisible"/>
D. <input type="text" name="userid" value="invisible"/>


9. (Single choice question) The following ( ) tags are used to build check boxes in the form
A. <input type="text"/>
B. <input type="radio"/>
C. <input type=“checkbox”/>
D. <a input type=“password”/>


10. (Single choice question) In HTML, when the type attribute value of the input element in the form is set to ( ), it is used to create a reset button
A. reset
B. set
C. button
D. image


2. True or False Questions


11. (True or False) In an HTML table, the number of table columns is equal to the sum of the colspan attributes of th and td in the first row.
wrong


12. (True or False) In an HTML table, using the align attribute in the TR, TD or TH tag can control the vertical alignment of the cell content.
wrong

Set text:
vertical-align:middle;
text-align:center


13. (True or False) HTML tables have borders by default
wrong


14. (True or False) Frames are a technology that can display multiple web pages in the same browser window
right


15. (True or False) The frame <frameset> tag should be written within the <body> tag of the HTML page ( )
wrong


16. (True or False) There are two ways to submit HTML forms: GET and POST.
right


17. (True or False) Type="submit", type="reset", type="button" in the form are all buttons
right


18. (True or False) _self means opening the web page in a new window
wrong

target attribute:
_self: Open in the current page
_blank: Open in a new window


19. (True or False) <input type=”password” >You can create a password box in HTML
right


20. (True or False) The form can only contain form controls, but not other content such as pictures.
wrong



Test 4

1. Multiple choice questions

  1. (Single choice question) Which of the following statements about external style sheets is incorrect ( )
    A. The file extension is .cs (.css)
    B. External style sheet content does not need to use the <style> tag
    C. Use the <link> tag to introduce external styles (<link rel="stylesheet" type="text/css" href="xxx.css">) D.
    Use External style sheets can make the website more concise and maintain a unified style


2. (Single choice question) In HTML, which of the following statements about text and font attributes in CSS styles is incorrect ( )
A. font-size is used to set the size of the text font
B. text-align is used to set the text Alignment
C. font-type (without this attribute) is used to set the font type(font-family sets the font)
D. font-weight is used to set the thickness of the font


3. (Single choice question) For #menu{font-size:14px;}, the following description is correct ( )
A. menu is a label selector
B. menu is an element selector
C. menu is a class selector ( .menu)
D. menu is the ID selector


4. (Single choice question) The meaning of style sheet background-position:-5px 10px is ( )
A. The background image is offset 5px to the left and 10px down.
B. The background image is offset 5px to the left and 10px up.
C. The background image is offset 5px to the right and 10px down.
D. The background image is offset 5px to the right and 10px up.


5. (Single choice question) In HTML, which of the following css attributes is not a box attribute is ( )
A. border
B. padding
C. float
D. margin

box model
Insert image description here


6. (Single choice question) Which of the following css attributes is used to specify a distance of 2px between the content and the border ( )
A. padding:2px;
B. border:2px;
C. margin:2px;
D. content:2px;


7. (Single choice question) Which of the following statements about standard document flow is correct ( )
A. Title tags, paragraph tags, and <span> tags are all block-level elements
B. <div>… …</div> tags are Inline elements
C. <div> tags can be included in <span> tags
D. The display attribute can control the display mode of block-level elements and inline elements.

  • Block elements: occupy one line, you can set the width and height,
    title tag h1-h6,
    paragraph tag p,
    horizontal line tag hr,
    ordered list tag ol–li,
    unordered list tag ul–li,
    definition description tag dl-dt-dd,
    Container tag div:
  • Row-level elements/inline elements: Width and height cannot be set, and they will not be displayed as independent rows
    span range tags
    img image tags
    <b>, <a>, <img>


8. (Single choice question) In the CSS box model, the attribute that represents the distance between the content and the border is ( ), and the attribute that represents the distance between the box and other boxes is ( )

A. padding margin
B. padding border
C. margin padding
D. margin border


9. (Single-choice question) In HTML, which of the following descriptions of the setting values ​​of the position attribute is wrong
( ) A. static is the default value, there is no positioning, and the elements are laid out according to the standard flow
B. The relative attribute value sets the relative positioning of the element. The vertical offset is specified using the up or down attribute.
C. Absolute means absolute positioning. It needs to be combined with the top, right, bottom, and left attributes to realize the offset of the element.
D. The values ​​of left and right attributes used to realize the offset can be negative numbers.


10. (Single-choice question) Regarding the following pseudo-classes of hyperlinks, ( ) is the hyperlink style when the mouse is hovering over it.
A. a:link
B. a:visited
C. a:hover
D. a:active


2. True or False Questions (10 questions in total, 50 points) 11. (True or False Question) Style sheets linked using the <link/> tag
in HTML are internal styles
wrong


12. (True or False) CSS rules consist of selectors and declarations. Selectors include tag selectors, ID selectors and class selectors.
right

– 13. (True or False) The element selector
in CSS uses HTML tags as the selector
right


14. (True or False) In the HTML document flow, <spa\n> is a block element by default
wrong


15. (True or False) In the HTML document flow, block elements and inline elements can be converted into each other.
right


16. (True or False Question) The position attribute of the element in CSS is fixed , which means that the upper left corner of the body of the web page is used as the basis.
right


17. (True or False) In the box model, if the border-style attribute is not set, the border of the box cannot be displayed.
right


18. (True or False) Among the ways to insert style sheets into HTML documents, the lowest priority is embedded style sheets.
wrong

Priority: Inline styles > Internal styles > External styles


19. (True or False) In CSS, a:visited represents the hyperlink style after clicking to visit
right


20. (True or False) In CSS syntax, each style rule is separated by a semicolon (;)
right



Test5

1. Multiple choice questions

  1. (Single choice question) In JSP, <%="1+4" %> will output ( )
    A. 1+4
    B. 5
    C. 14
    D. There will be no output because the expression is wrong


2. (Single choice question) In JSP, use the page command to set the script language to be Java , and import the java.rmi.* and java.util.* packages . The following is correct ( )
A. <% @ page Language=”Java”,import=”java.rmi.*;java.uitl.* ”%”>
B. <%@ page language=”Java” Import=”java.rmi.*,java.uitl. * ”%”>
C. <%@ page language=”Java”;import=”java.rmi.*;java.uitl.* ”%”>
D. <%@ page language=“Java” import=”java.rmi.* ,java.uitl.* ”%>


3. (Single choice question) In JSP, there is only one line of code: <%=A+B%> , and the operation will output ( )
A. A+B
B. AB
C. 113
D. There is no output because the expression is wrong

<%=A+B%>: Outputs the sum of A+B,
but there are no single quotes or double quotes, and A and B are not assigned values, so an error is reported.

<%='A'+'B'%> Single quotation mark , two-letter decimal ASC code A=65 B=66 addition, 131
<%=“A”+“B”%> Double quotation mark , string concatenation, AB


4. (Single choice question) In JSP, the test .jsp file is as follows. When trying to run, () will occur <html>
<
% String str = null; %>
str is <%= str %>
</html>
A. There is an error during translation
B. An error occurs when compiling the Servlet source code
C. An error occurs when executing the compiled Servlet
D. After running, the browser displays: str is null

– 5. (Single choice question) To obtain the request parameters
from the HTTP request, you should call () A. getAttribute() method of the request object

B. getParameter() method of request object
C. The getAttribute() method of the session object
D. The getParameter() method of the session object


6. (Single choice question) Given the following JSP code snippet, 2 customers browse the JSP in sequence, and each customer only browses once . The second customer will see the browser display ()

<%int x = 1; %>
<%!int x = 10; %>
X =< %= ++x%>

A. X = 1
B. X = 2
C. X = 10
D. X = 11

Variables and methods declared in <%! %>: variables declared in <% %> that exist as attributes and methods of the class : internal attributes of methods


7. (Single choice question) Regarding <jsp:include/>, which of the following statements is incorrect ( )
A. It can contain static files
B. It can contain dynamic files
C. When its flush attribute is true, it means When the buffer is full, it will be emptied
D. The default value of its flush attribute is true (false)

– 8. (Single choice question) Which of the following statements
about predefined **<%!predefined%> is incorrect**: ( ) A. Multiple variables can be declared at one time, as long as they end with ";" B. One The statement is only valid within one page


C. The declared variables will be used as local variables
D. Variables declared in the predefinition will be initialized when the JSP page is initialized.

Variables and methods declared in <%! %>: exist as attributes and methods of the class


9. (Single-choice question) Among the following options, ( ) is the correct expression
A. <% String s="hello world" ;%>
B. <%="hello world" ;%>
C. <%=“hello world”%>
D. <%@=“hello world”%>


10. (Single choice question) Which of the following is not a basic class loaded by JSP itself ( )
A. java.lang.*
B. java.io.*
C. javax.servlet.* 
D. javax.servlet.jsp.*


2. True or False Questions


11. (True or False) The instruction tags and JSP action tags in the JSP page are collectively called script elements.
wrong


12. (True or False) Java variables declared between the "<%!" and "%>" tags are valid within the entire page and are not shared between different clients.
wrong

Variables and methods declared in <%! %>: exist as attributes and methods of the class


13. (True or False) JSP output expression, the correct syntax is <%=expression%>
right


14. (True or False) The directive <%@page %> in JSP is not necessarily placed at the head of the page.
right


15. (True or False) The server is responsible for calculating the value of the Java expression in JSP and sending the calculated value to the client as a string for display.
right


16. (True or False) The default value of the Language attribute of the Page directive is java
right


17. (True or False) You can use the JAVA language annotation method in JSP, and the content of the annotation can be sent to the client.
wrong


18. (True or False Question) <jsp:param /> can be used alone in JSP ( )
wrong

The <jsp:param> operation is used to provide additional information to other tags in the form of "name-value" pairs, and is used together with <jsp:include>, <jsp:forward>, and <jsp:plugin>


19. (True or False) The <jsp:include> action tag and the <include> directive tag include files in different processing times and methods
== True ==


20. (True or False) The page attribute value of the <jsp:forword/> tag is a relative URL address and can only be a static URL.
wrong



Test6

1. Multiple choice questions


1. (Single choice question) The following are JSP internal objects but do not include ( )
A. request
B. response
C. application
D. int


2. (Single choice question) The following () can be used to retrieve the value of the session attribute userid
A. session. getAttribute (“userid”);
B. session. setAttribute (“userid”);
C. request. getParameter (“userid”);
D. request. getAttribute (“userid”);


3. (Single choice question) Regarding the use of sessions, which of the following statements is correct
() A. Different user windows have the same session
B. Different user windows have the same session
C. The session may time out
D. Session can never time out


4. (Single choice question) In JSP, session.setMaxInactiveInterval(30), the duration is 30 ( )
A. Milliseconds
B. seconds
C. minutes
D. hours


5. (Single choice question) In J2EE, to redirect to another page, the following () statement is correct
A. request . sendRedirect(“http://www.jb-aptech.com.cn”);
B .request .sendRedirect();
C. response . sendRedirect(“Http : // www . jb – aptech . com . cn”);
D. response. sendRedirect()


6. (Single choice question) In a JSP page, the range of data saved from small to large is ( )
A. pageContext, request, application, session
B. pageContext, application, session, request
C. pageContext,request,session,application
D. pageContext,session,request,application


7. (Single choice question) In the JSP page, if the request for this page is forwarded to the specified URL component through <jsp:forward page=urlname/> from a source page , it cannot be processed in the URL component (JSP page) The shared data range is ( )
A. session
B. request
C. page
D. application


8. (Single choice question) In the JSP page, the built-in object that can complete the output operation is: ( )
A. out
B. response
C. request
D. config


9. (Single-choice question) Which of the incorrect descriptions of forwarding and redirection is ( ) A. Redirection is a function that occurs on the client, and the page is redirected by requesting a new address. B. When forwarding is used, it is controlled internally by the server. The transfer of rights, so the URL in the address bar does not change. C. When using redirection, you can see the redirected URL in the address bar.



D. Both forwarding and redirection can achieve page jump, there is no difference


10. (Single choice question) When using the response object for redirection , the method used is ()
A. getRequestDispatcher()
B. forward()
C. sendRedirect()
D. setRequestDispatcher()


2. True or False Questions


11. (True or False) Session objects are created and destroyed by the client, so different clients have different session objects.
right


12. (True or False) Tomcat server supports direct use of the application object
wrong


13. (True or False) The sendRedirect method of the response object can only realize page jumps within this website, but cannot pass parameters.
wrong


14. (True or False) The response object is mainly used to send data to the client
right


15. (True or False) The getRemoteHost() method of the request object can obtain both the name of the client and the client’s IP address
wrong


16. (True or False Question) The setMaxInactiveInterval() method of the session object sets the maximum inactivity time (maximum survival time), in milliseconds
wrong


17. (True or False) The session object can be used to save data information that needs to be saved during the user session.
right


18. (True or False) The Application object is shared by all users , and any operation on it will affect all users.
right


19. (True or False) When using the request object to obtain information, a NullPointerException may occur.
right


20. (True or False) Redirection directs users to other JSP pages. The Request object can also be sent to the pointed resource.
wrong

Redirect only directs users to other jsp pages or servlets, but cannot forward the request object to the pointed resource.



Test7

1. Multiple choice questions

  1. (Single choice question) In the JSP page, the correct introduction of JavaBean is ()
    A. <%jsp: useBean id =”myBean” scope =”page” class =”z.MyBean” %>
    B. <jsp: useBean name =”myBean” scope =”page” class=”z.MyBean” >
    C. <jsp: useBean id =”myBean” scope =”page” class=”z.MyBean” />
    D. <%jsp: useBean name =”myBean” scope =”page” class=”z.MyBean” />


2. (Single choice question) The following test.jsp file contains the following line of code: <jsp: useBean id="user" scope="__" type="com.UserBean"> To make the user object available to the entire application Program , underline should be added ()
A. page
B. request
C. session
D. application


3. (Single choice question) In JSP, what is the correct description of the <jsp:setProperty> tag () A. <jsp: setProperty> and <jsp: getProPerty> must appear together in a JSP file B. Just like Same as session.setAttribute(), to design attribute/value pairs


C. Use it together with the <jsp:useBean> action to set the attribute value of the bean.
D. Just like request.setAttribute(), to set the attribute/value pair

<jsp:setProperty>

  • Used to set properties of instantiated Bean objects
    <jps:setProperty name = “JavaBean instance name” property = “*”/>
    <jsp:setProperty name = “JavaBean instance name” property = “JavaBean property name” />
    < jsp:setProperty name = "JavaBean instance name" property = "JavaBean property name" value = "BeanValue"/> <
    jsp:setProperty name = "JavaBean instance name" property = "propertyName" param = "Parameter name in the request object" />


4. (Single choice question) In JSP, the following is a description of jsp:setProperty and jsp:getProperty tags . The correct one is ()
A. Both <jsp:setProperty> and <jsp:getProperty> tags must be in <jsp : between the start tag and the end tag of useBean>
B. The value of the name attribute of these two tags must correspond to the value of the id attribute of the <jsp:usebean> tag.
C. The <jsp:setProperty> and <jsp:getProperty> tags can be used to select and set all properties defined in the bean. D. The
value of the name attribute of these two tags can be the same as the value of the attribute of the <jsp:userbean> tag. Values ​​are different


5. (Single choice question) Given the TheBean class, assuming that no instance of the TheBean class has been created yet, which of the following JSP standard action statements can create a new instance of this bean and store it in the request scope
A. < jsp :useBean name="myBean" type="com.example.TheBean"/>
B. < jsp :takeBean name="myBean" type="com.example.TheBean"/>
C. < jsp:useBean id="myBean"class=“com.example.TheBean” scope=“request”/>
D. < jsp:takeBean id=“myBean” class=“com.example.TheBean” scope=“request”/>


6. (Single choice question) Among the following options, the correct statement to create and implement writing cookies is ()
A. request.add(new Cookie())
B. request.addCookie(new Cookie(String key,Object value ))
C. response.add(new Cookie())
D. response.addCookie(new Cookie(String key,Object value))


7. (Single choice question) In J2EE, the Servlet API provides the ( ) class for using Cookies
A. Javax.servlet.http.Cookie
B. Javax.servlet.http.HttpCookie
C. Javax.servlet. Cookie
D. Javax.servlet.http. HttpCookie


8. (Single choice question) When using the request method to obtain elements in the Form , which character encoding is used by default?
A. ISO-8859-1
B. GB2312
C. GB3000
D. ISO-8259-1


9. (Single choice question) The method to set the cookie validity period is to call the setMaxAge(int expiry) method of the cookie object. The parameter expiry represents the validity period of the cookie in seconds. When using setMaxAge(int expiry), the following is incorrect ()
A. Normally, the expiry parameter should be an integer greater than 0, indicating the effective survival time of the cookie.
B. If the expiry parameter is set equal to 0, it means that the cookie is deleted.
C. Setting the expiry parameter to a negative number or not setting it means that the cookie will be stored in the current cookie. Invalid after closing window
D. If the expiry parameter is set equal to 0, it means that the cookie is permanently valid.


10. (Single choice question) Cookie was invented by Netscape and is the most commonly used way to track user sessions. It is generated by () and sent to ()
A. Client, browser server
B. Server, client browser
C. Client browser, client browser
D. Server, server


2. True or False Questions


11. (True or False) As long as UTF-8 encoding is used in the web page, there will be no Chinese garbled characters.
wrong


12. (True or False) Cookies are saved on the client side by the browser, usually as a text file
right


13. (True or False) Javabean properties can be read and written, and the set method and get method must be paired when writing.
wrong


14. (True or False) Javabean is also a Java class and must have a main function
wrong


15. (True or False) Javabean properties must be private and methods must be public access types
wrong

Javabean must be a public class, and variables can be defined as private. A standard javabean feature must meet the following three conditions:
1) javabean is a public public class
2) the javabean class must have a zero-parameter constructor, that is, no parameters Constructor
3) When setting and obtaining javabean properties, you must use the getXXX(), setXXX() methods


16. (True or False) If there is a constructor in the Bean class called in JSP, it must be of public type and have parameters.
wrong

If javaBean is an internal class, it can be modified with private, otherwise it must be written as public (you must use the get and set methods in the bean). However, the
bean attributes of the bean class written outside can be private, because the get and set methods are public.


17. (True or False) In Javabeans, for boolean type attributes, you can use is to replace the set and get prefixes in the method name.
right


18. (True or False Question) If a customer modifies the session scope Bean component on a certain page , the properties of the Bean will change in the same way on other pages, and the Beans between different customers will also change.
wrong

Session content is valid within a session scope


19. (True or False) Using the <jsp:setProperty> action tag, you can use expressions or strings to assign values ​​to Bean properties.
right


20. (True or False) Basic type and structural type variables can be declared in JSP, but classes cannot be declared. Classes must be placed in JavaBeans.
wrong



Text8

1. Multiple choice questions

  1. (Single choice question) Which of the following is not a task of JDBC
    ? A. Establish a connection with the database
    . B. Operate the database and process the results returned by the database.
    C. Generate a form in the web page
    D. Send SQL statements to the database management system


2. (Single choice question) Which of the following is not a method of loading drivers?
A. Loading through DriverManager.getConnection method(Get sql connection)
B. Call the method Class.forName
C. By adding the system's jdbc.drivers attribute
D. Register through the registerDriver method


3. (Single choice question) In the getConnection(String url, String user, String password) method of the DriverManager class, the format of the parameter url is jdbc:<sub-protocol>:<sub-name>. Which of the following urls is incorrect ?
A. jdbc:mysql://localhost:80/database name(Port 80: the default port of the http protocol)
B. jdbc:odbc: data source
C. jdbc:oracle:thin@host: port number: database name
D. jdbc:sqlserver://172.0.0.1:1443;DatabaseName=database name


4. (Single choice question) In JDBC, which of the following interfaces cannot be created by Connection
A. Statement
B. PreparedStatement
C. CallableStatement
D. RowsetStatement


5. (Single choice question) The following is the code fragment for loading the JDBC database driver:

try{
    
    
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                       
} catch(ClassNotFoundException e){
    
    
	out.print(e);
}    

Which driver does the program load?
A. JDBC-ODBC bridge connection driver
B. Partial Java written local driver
C. Local protocol pure Java driver
D. Network pure Java driver


6. (Single choice question) The default port of mysql database is
A. 8080
B. 3306
C. 80
D. 3302

– 7. (Single choice question) The following query condition string String condition=“insert book values(?,?,?,?,?)”
is given ; which of the following interfaces is suitable for executing this SQL query? A. Statement



B. PrepareStatement
C. CallableStatement
D. Unsure

– 8. (Single-choice question) Find the person whose name contains
"Mary" from the "Name" field of the "Employee" table . Which of the following select statements is correct A. Select * from employee where Name=' Mary ' B. Select * from employee where name='%Mary_' C. Select * from employee where name like '_Mary%'



D. Select * from employee where name like '%Mary%'


9. (Single choice question) Which of the following is not a commonly used interface when using JDBC to access data?
A. Record
B. ResultSet
C. Statement
D. PreparedStatement


10. (Single choice question) When using JDBC statements to access the database in JSP, the correct statement to import the SQL class library is
A. <%@ page import=“java.sql.*” %>
B. <%@ page import=“sql.*” %>
C. <% page import=“java.sql.*” %>
D. <%@ import=“java.sql.*” %>


2. True or False Questions


11. (True or False) The database service and web server need to be on the same computer
wrong


12. (True or False) JDBC loads drivers for different databases and uses corresponding parameters to establish connections with various databases.
right


13. (True or False) The Statement object provides the int executeUpdate(String sqlStatement) method, which is used to add, delete and update data in the database.
right


14. (True or False) Only one JDBC database driver is needed to connect to all databases
wrong


15. (True or False) The main functions of JDBC are to establish a connection with a database, send SQL statements to the database, and process the results returned by the database (resultset).
right


16. (True or False) The URL in JDBC provides a method to identify the database, allowing the DriverManage class to identify the corresponding driver.
right


17. (True or False) All databases are relational databases
wrong


18. (True or False Question) In the ResultSet result set, rs can see one row each time. To see the next row, you must use the next() method to move to the next row.
right


19. (True or False) The default character encoding of mysql database is utf-8 (latin1)
wrong


20. (True or False) JDBC is built on the basis of ODBC and provides a standard for database application developers and database front-end tool developers, allowing developers to write complete database applications in any language.
wrong

JDBC was designed by SUN with reference to ODBC.



Test9

1. Multiple choice questions


1. (Single choice question) In the Servlet life cycle, the method corresponding to the service phase is
A. inti()
B. destroy()
C. service()
D. initial()


2. (Single choice question) Regarding the getAttribute() method of the ServletRequest interface , which statement is correct ( )
A. Get the attribute value of the specified name
B. Set the value of the specified attribute
C. Delete the value of the specified attribute
D. None of the above is correct


3. (Single choice question) In Java EE, the ( ) method of HttpServletResponse is used for an HTTP requestRedirectTo another resource
A. sendURL()
B. sendRedirect()
C. forward()
D. redirectURL()


4. (Single choice question) Which statement about Servlet is wrong
() A. Servlet is a special Java class
B. Servlet is a server-side programming language
C. Servlet does not have a life cycle
D. JSP files can be converted into Servlets


5. (Single choice question) Using XML configuration, when accessing Servlet, the path entered in the browser address bar is configured in ( )
A. <servlet-name/>
B. <servlet-mapping/ >
C. <uri-pattern/>
D. <url-pattern/>


6. (Single choice question) When writing a filter , what methods need to be completed ( )
A. doFilter()
B. doChain()
C. doPost()
D. doDelete()


7. (Single choice question) In Servlet, which of the following statements can correctly obtain the PrintWriter object ()
A. PrintWriter out = request.getWriter();
B. PrintWriter out = request.getPrintWriter();
C. PrintWriter out= response.getWriter();
D. PrintWriter out = response.getPrintWriter();


8. (Single choice question) In the life cycle method of the Servlet filter , whenever a request or response is passed , the web container will call the () method
A. init
B. service
C. doFilter
D. destroy


9. (Single choice question) When writing the doPost method of Servlet , the exception that needs to be thrown is ()
A. ServletException, IOException
B. ServletException, RemoteException
C. HttpServletException, IOException
D. HttpServletException, RemoteException


10. (Single choice question) In J2EE, the following description of RequestDispatcher is correct ( )
A. There is an implicit object diapatcher in Jsp, and its type is RequestDispatcher
B. ServletConfig has a method: getRequestDispatcher can return the RequestDipatcher object
C. RequestDipatcher has a method: forward, which can continue to pass the request to other Servlets or JSP interfaces
D. There is an implicit default object request in JSP, its type is RequestDipatcher


2. True or False Questions (10 questions in total, 50 points)
11. (True or False Question) Servlet and JSP files can be converted into each other
right


12. (True or False) Servlet can only be implemented through configuration in web.xml
wrong

– 13. (True or False) Servlet receives all requests
through get method
wrong


14. (True or False) Both request forwarding and request redirection can be implemented in Servlet
right


15. (True or False) The servlet we write inherits the Httpservlet class. Generally, we only need to override the doPost method, not the servive() method, because a service() method will call the doPost or doGet method.
right


16. (True or False) Servlet can store data in three different scopes: request, session and context.
right


17. (True or False) The entry point of the Servlet program is main()
wrong

init() method, initializes all objects


18. (True or False) In JSP pages, the built-in object equivalent to HttpServletResponse is response
right


19. (True or False) The listener can monitor session changes
right


20. (True or False) When a Servlet is requested for the first time, the server will first call doinit (init)
wrong



Test10

1. Multiple choice questions

  1. (Single choice question) Regarding the MVC architecture , which of the following statements is incorrect ?
    A. Increases the requirements for developers
    B. Code reuse rate is low (high)
    C. Increases the difficulty of file management
    D. Generates more files


2. (Single choice question) Regarding the JSP Model1 pattern, which of the following statements is incorrect
A. The application is based on process
B. Business logic and presentation logic are mixed
C. Software maintenance and expansion are difficult
D. Generate more files

Two ways for JSP to implement application technology: Model1, Model2

  • Model1 model: mainly processed through JSP pages and business logic,
    suitable for small project development, with simple structure and rapid development. However, JSP pages are relatively complex and not conducive to maintenance.
    Insert image description here
    Insert image description here
  • Model2: MVC application, based on Model1, separates control and business logic processing. It is
    suitable for large-scale project development, has clear responsibilities, adapts to changing needs, and is easy to maintain.
    Insert image description here
    Insert image description here


3. (Single choice question) Regarding the JSP Model2 mode, which of the following statements is incorrect?
A. The model is suitable for small projects
B. Servlet acts as a controller
C. Separates the view layer and business layer
D. There is low coupling between M, V, and C


4. (Single choice question) Which of the following descriptions of Servlet and JSP is wrong ?
A. A program that mixes HTML, Java and scripting languages ​​has poor readability and difficulty in maintenance.
B. JSP technology was produced after Servlet. With Servlet technology as the core, it is a successful application of Servlet technology.
C. When a JSP page is requested, the JSP page will be translated into Servlet bytecode by the JSP engine for execution.
D. Generally, JSP is used to handle business logic, and Servlet is used to implement page display.


5. (Single choice question) Which of the following descriptions of Servlet is incorrect ?
A. Servlet is a special Java class that must directly or indirectly implement the Servlet interface.
B. The Servlet interface defines the life cycle methods of Servlet.
C. When multiple clients request a Servlet, the server will start a process for each client.
D. The Servlet client thread calls the Service method to respond to the client's request.


6. (Single choice question) Which of the following statements is correct
: A. Servlet serves as a model for the MVC pattern
B. Servlet acts as a controller in MVC pattern
C. JavaBean acts as the controller of the MVC pattern
D. JSP acts as the model of the MVC pattern


7. (Single choice question) Which of the following statements is correct?
A. The component forwarded by the forward method can only be in the same WEB application.
B. The URL specified by the RequestDispatcher object is relative to the root directory of the entire WEB site.
C. The URL in the sendRedirect method is relative to the root directory of the current WEB application.
D. The component forwarded by the forward method may not be in the same WEB application.


8. (Single choice question) What interface can Servlet use to implement the request forwarding mechanism
? A. HttpServletRequest interface
B. RequestDispatcher interface
C. HttpServletResponse interface
D. ServletConfig interface


9. (Single choice question) The following description of the HttpServletRequest interface is incorrect
: A. The most commonly used method in the HttpServletRequest interface is to obtain the request parameters.
B. The built-in object request in JSP is an HttpServletRequest instance.
C. HttpServletRequest mainly handles customer responses
D. HttpServletRequest mainly handles obtaining input and output streams

The HttpServletRequest object represents the client's request. When the client accesses the server through the HTTP protocol, all the information in the HTTP request header is encapsulated in this object. Through the methods provided by this object, all the information requested by the client can be obtained.


10. (Single choice question) The following incorrect description of the HttpServletResponse interface is A. HttpServletResponse represents the Http response to the client B. The built-in object response in JSP is an HttpServletResponse instance


C. The setCharacterEncoding(String charset) method sets the MIME type of the response
D. The getWriter() method obtains the PrintWriter object to output character data


2. True or False Questions


11. (True or False) In the MVC model of WEB development, the view corresponds to the “JSP page”, the model corresponds to the “JavaBean”, and the controller corresponds to the “Servlet”
right


12. (True or False) Redirection only directs users to other JSP pages or Servlets , but cannot forward the Request object to the pointed resource.
right

Forwarding and Redirecting

  • Redirect : Direct from the current page to another page, the address changes
    response.sendRedirect("welcome");
  • Forwarding : forward the user's request for the current jsp page or servlet to another jsp, page or servlet, the address remains unchanged
    request.getRequestDispatcher("/welcome").forward(request, response);


13. (True or False) Forwarding only directs users to other JSP pages or Servlets, but cannot forward the Request object to the pointed resource.
wrong


14. (True or False) Generally, JSP is used to display pages and Servlet is used to handle business logic.
right


15. (True or False) The doGet() and doPost() methods in Servlet handle requests sent by the client’s GET and POST methods respectively.
right


16. (True or False) A Servlet can map multiple access paths
right


17. (True or False Question) Using the MVC model makes the hierarchical division more complex, which is not conducive to the division of labor in development.
wrong


18. (True or False) After the redirected access process by calling the sendRedirect method is completed, the URL displayed in the browser address bar will change.
right


19. (True or False) The result of the sendRedirect method response is to tell the browser to reissue an access request to another URL (redirect). The forward method forwards the request to another resource internally on the server side (forward).
right


20. (True or False) In the HTTP protocol, the 404 status code means “Not Found. The resource at the specified location cannot be found.
right



Guess you like

Origin blog.csdn.net/m0_50609545/article/details/122298406