1. Overview of the MVC architecture, what are the technologies that are implemented in each section?
The M-mode (model, bean (domain) layer) is implemented by JavaBean or EJB, V is the view, the display layer is implemented by the JSP, and C is the controller (Controller) implemented by the servlet.
2. Describe the difference between session and cookie?
Session is to save the user information on the server side, the cookie is to save the information on the client;
The object is saved in the session, and the cookie holds the string;
Session objects end With the end of the conversation, the maximum survival time of 30 minutes, it is not easy to achieve long-term survival operation is meaningless; cookies can be set up for long-term preservation at the client;
Session because no one on the server side to change the solid more secure; cookies on the local hard drive, others can analyze the information in your cookie is not secure, so cookies are usually used to save unimportant user information, session save important.
The session technology writes the user's data to the user's exclusive session; Cookies are the browsers that write the user's data to the user.
3. What are the built-in objects for JSP? What are the roles?
JSP has the following 9 basic built-in objects (RRPPASOCE):
Request: Client requests, this request contains parameters from the Get/post request
Response: Web page Returns the response of the client
PageContext: The properties of a Web page are managed here, providing access to all of the objects and namespaces within the JSP page, and are the epitome of all the features in the page.
Sessions: Session duration associated with the request
Application: Is the ServletContext class instance, the Application object realizes the data sharing between the user, may hold the global variable.
Out: Output used to transmit a response
A config:servlet frame part; When a servlet initializes, the JSP engine sends it a message, This information includes the parameters to use for servlet initialization (consisting of property names and property values) and information about the server (by passing a ServletContext object)
page:jsp the Web page itself, like this pointer in a class, is an instance of the Java.lang.Object class
Exception: An exception that was not caught for the error page.
4. PreparedStatement in JDBC compared to the benefits of statement
1), relatively safe, can prevent SQL injection
2, have precompiled function, the same operation batch data efficiency is high
5. The difference between dynamic include and static include in JSP.
Dynamic include: Use Jsp:include action to implement <jsp:include page= "included.jsp" flush= "true"/> It always checks for changes in contained files, suitable for inclusion of dynamic pages, and can be used with parameter ; The dynamic include structure is independent, until the output is merged (see JSP generated Java file (servlet) can be known), so dynamic include JSP file independence is very strong, is a separate JSP file, need to use the object, page settings, All must have their own creation, of course, fortunately it is consistent with the request scope of the pages that include it.
Static include: Implemented with include pseudo code, will not check the change of the contained file, apply to contain static page <%@ include file= "included.htm"%>; static include the result is to bring other JSP into the current JSP, The two are integrated, so the static include is a shared method that writes the code outside, all variables can be shared with the main file that contains it, which is highly cohesive and cannot have conflicting names of variables. Page settings can also be borrowed from the master file.
6. What about the lifecycle of the servlet?
The servlet lifecycle is divided into three phases:
1). Initialize the phase, invoke the Init () method.
2). In response to the customer request phase, the service () method is invoked.
3). terminate phase; Call the Destroy () method.
7. There are several ways to implement a thread in Java. What keyword modifies the synchronization method?
There are two ways to do this:
1. Implement it by inheriting a thread class and inheriting its run () method;
2. Implement its run () method by implementing a runnable interface.
Use the Synchronized keyword to modify the synchronization method.
8. What is the difference between forward and redirect?
The biggest difference between forward forwarding and redirect is that the address of the former is the same, because forward sends only one request.
By contrast, forward performance is higher; forward can store the attributes of the request scope (request field) and redirect not. ;. Forward need to be implemented in a servlet through a dispatcher (allocator), and redirect can invoke the appropriate method directly with request, redirect to prevent some unknown consequences of client refresh in some cases ( For example, continuous deletion).
Forward and include the objects within the scope of the request, and redirect is not, that is, if a javabean is declared as the request scope, then the resources that are forward to can also access this JavaBean, and Redriect is not; forward and include are basically the resources that are forwarded to the context, and redirect can redirect to external resources such as: Req.sendredriect ("http://www.mocuai.com");
9. What are the characteristics of the transaction?
There are four characteristics (ACID): atomicity (atomicity), consistency (consistency), isolation (isolation), and persistence (durability)
What is the difference between request.getattribute () and Request.getparameter ()?
(1) The HttpServletRequest class has a setattribute () method, but no Setparameter () method
(2) The data passed by the Request.getparameter () method is uploaded from the Web client to the Web server, representing the HTTP request data (obtaining the form information submitted by the user after it is completed), Request.getparameter () method returns a string of data that the GetAttribute () client submits (the customer is not directly involved in filling out); The data passed by the Request.setattribute () and GetAttribute () methods only exist inside the Web container. Shared among Web components that have forwarding relationships. These two methods can set the shared data of type object.
What are the similarities and differences between 11.JSP and servlet, and what are their connections?
JSP is an extension of the servlet technology, which is essentially a simple way for the servlet to emphasize the outward expression of the application. JSP is compiled "class servlet". The main difference between servlet and JSP is that the application logic of the servlet is in the Java file and is completely detached from the HTML in the presentation layer. In the case of JSP, Java and HTML can be combined into a file with a. jsp extension, which is an HTML with nested Java code. The JSP focuses on the view, and the servlet is used primarily for control logic.
12. What is the working mechanism of the data connection pool?
The Java EE server starts up with a certain number of pool connections and maintains no less than this number of pool connections.
Call: When a client program requires a connection, the pool driver returns an unused pool connection and makes it busy. If there are currently no idle connections, the pool driver creates a new number of connections, and the number of new connections is determined by the configuration parameters.
Release: When the pool connection call is complete, the pool driver makes this connection idle and other calls can use this connection
Role: Data connection pool is the database connection to the intermediary server, such as Tomcat, then the equivalent of each time you operate the database does not need to "connect" to the database and then related operations, but directly operate the server "connection pool."
What is the difference between 13.abstract class and interface?
1. An abstract class can have a construction method, and an interface cannot have a construction method.
2. There can be ordinary member variables in an abstract class, and there are no ordinary member variables in the interface
3.) Abstract classes can contain generic methods that are not abstract, and all methods in an interface must be abstract and not have a generic method that is not abstract.
4. The access type of an abstract method in an abstract class can be public,protected and (the default type, although not an error in eclipse, but it should not), the abstract method in the interface can only be of public type, and the default is the public abstract type.
5. A static method can be included in an abstract class and cannot contain static methods in an interface
6. Both abstract classes and interfaces can contain static member variables, and the access type of static member variables in an abstract class can be arbitrary, but the variables defined in the interface can only be public static final types, and the default is the public static final type.
7. A class can implement multiple interfaces, but can inherit only one abstract class.
14.Jsp How to let the client not cache the page.
1. Using Java-provided methods, either in a JSP or in a servlet
<%
Response.setheader ("Pragma", "No-cache");
Response.setheader ("Cache-control", "No-cache");
Response.setdateheader ("Expires", 0);
%>
2. Use HTML tags on the JSP, such as the following:
<HEAD>
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
</HEAD>
15. What are the three ways to get class?
Class name. class; instance. GetClass; Class.forName (full class name);