61. servlet Lifecycle
The web container loads the servlet and starts its lifecycle. Call the servlet init () method to initialize the servlet. You can call the service () method to call different do *** () methods based on different requests. End the service. The web Container calls the servlet's destroy () method.
62. How to Implement servlet single-thread mode
<% @ Page isThreadSafe = "false" %>
63. Methods for transferring objects between pages
Request, session, application, cookie, etc.
64. What are the similarities and differences between JSP and Servlet, and what are their relationships?
JSP is an extension of Servlet technology. It is essentially a simple Servlet method, with more emphasis on the external expression of the application. After JSP compilation, it is "servlet-like ". The main difference between Servlet and JSP is that the application logic of Servlet is in the Java file and is completely separated from the HTML in the presentation layer. In JSP, Java and HTML can be combined into a file with the extension. jsp. JSP focuses on views. Servlet is mainly used for control logic.
65. Four session tracking technologies
Description of the session scope ServletsJSP page
Page No indicates the objects and attributes related to a page. A page is represented by a compiled Java servlet class (which can contain any include command but has no include action. This includes both servlet and JSP pages compiled into servlet.
A request is an object and attribute related to a request sent by a Web Client. A request may span multiple pages and involves multiple Web Components (due to the relationship between the forward instruction and the include action)
A session is an object and attribute associated with a user experience for a Web Client. A Web session can also frequently span requests from multiple clients.
Application represents the objects and attributes related to the entire Web application. This is essentially a global scope that spans the entire Web application, including multiple pages, requests, and sessions
66. Main Methods of the Request object:
SetAttribute (String name, Object): Set the parameter value of the request whose name is name.
GetAttribute (String name): returns the property value specified by name.
GetAttributeNames (): returns the name set of all attributes of the request object. The result is an enumerated instance.
GetCookies (): return all Cookie objects on the client. The result is a Cookie array.
GetCharacterEncoding (): returns the character encoding method in the request.
GetContentLength (): returns the length of the Request Body.
GetHeader (String name): Get the file header defined by HTTP
GetHeaders (String name): returns all the values of the request Header with the specified name. The result is an enumerated instance.
GetHeaderNames (): returns the name of the request Header. The result is an enumerated instance.
GetInputStream (): returns the input stream of the request to obtain data in the request.
GetMethod (): method for obtaining data transmitted from the client to the server
GetParameter (String name): Get the parameter value specified by name sent from the client to the server.
GetParameterNames (): obtains the names of all parameters sent from the client to the server. The result is an enumerated instance.
GetParameterValues (String name): obtains all values of the parameter specified by name.
GetProtocol (): gets the protocol name on which the client transmits data to the server.
GetQueryString (): Get the query string
GetRequestURI (): obtains the client address of the request string.
GetRemoteAddr (): obtains the IP address of the client.
GetRemoteHost (): Get the client name
GetSession ([Boolean create]): returns the Session associated with the request.
GetServerName (): Get the server name
GetServletPath (): Get the path of the script file requested by the client
GetServerPort (): Get the server port number
RemoveAttribute (String name): deletes an attribute in a request.
67. Is J2EE a technology, a platform, or a framework?
J2EE is a standard, a standard platform for enterprise distributed application development.
J2EE is also a framework, including JDBC, JNDI, RMI, JMS, EJB, JTA and other technologies.
68, we often encounter the output of some encoding characters in the web application development process, such as iso8859-1, how to output a certain encoding string?
Public String translate (String str ){
String tempStr = "";
Try {
TempStr = new String (str. getBytes ("ISO-8859-1"), "GBK ");
TempStr = tempStr. trim ();
}
Catch (Exception e ){
System. err. println (e. getMessage ());
}
Return tempStr;
}
69. Briefly describe the differences between logical operations (&, |, ^) and conditional operations (&, |.
There are two main differences: a. Conditional operations can only operate on the boolean type, while logical operations can operate not only on the boolean type, but also on the numeric type.
B. logical operations will not generate short circuits
70. How many forms are defined in XML documents? What are the essential differences between them? How can I Parse XML documents?
A: Two forms of dtd schema. B: essential difference: the schema itself is xml and can be parsed by the XML Parser (this is also the fundamental purpose of developing the schema from the DTD). c: DOM, SAX, STAX, etc.
DOM: when processing large files, its performance drops sharply. This problem is caused by the DOM tree structure. This structure occupies a large amount of memory and the DOM must load the entire file into the memory before parsing the file, which is suitable for Random Access to XML.
SAX: it does not exist in DOM. SAX is an event-driven XML parsing method. It reads XML files sequentially without loading the entire file at a time. When a file starts with a file, the document ends, or the tag starts with a tag, it triggers an event. You can write the processing code in the callback event to process the XML file, suitable for sequential access to XML
STAX: Streaming API for XML (StAX)
71. What are the similarities and differences between synchronized and java. util. concurrent. locks. Lock?
The main point is that Lock can complete all functions implemented by synchronized.
Major difference: Lock has more precise thread semantics and better performance than synchronized. Synchronized Automatically releases the Lock, which must be manually released by the programmer and must be released in the finally clause.
72. EJB roles and three objects
A complete EJB-based Distributed Computing structure consists of six roles, which can be provided by different developers. Each role must follow the EJB specifications provided by Sun, to ensure compatibility between them. These six roles are EJB component developer (Enterprise Bean Provider), Application aggreger (Application aggreger), Deployer (Deployer), and EJB Server Provider (EJB Server Provider), EJB Container Provider, System Administrator)
The three objects are Remote (Local) interface, Home (LocalHome) interface, and Bean class.
73. Services provided by the EJB container
It mainly provides declarative cycle management, code generation, continuity management, security, transaction management, lock and release management services.
74. What operations are prohibited in ejbs In the EJB specification?
1. the thread and thread APIs cannot be operated (the thread API refers to methods of non-thread objects, such as notify and wait. awt cannot be operated, 3. cannot implement server functions. 4. cannot survive the static genus. you cannot use IO operations to directly access the file system. 6. the local database cannot be loaded ., 7. you cannot use this as a variable or return value. it cannot be called cyclically.
75. Main Functions of the remote interface and home interface
The remote interface defines the business method used by the EJB client to call the business method.
The home interface is used by the EJB factory to create and remove EJB instances.
76. bean instance Lifecycle
Stateless Session Bean, Entity Bean, and Message Driven Bean are generally managed by the buffer pool, while Entity Bean and Statefull Session Bean are managed by Cache, which usually includes instance creation, set the context, create an EJB Object (create), call a business method, and remove. For beans with buffer pool management, the instance is not cleared from the memory after create, instead, the buffer pool scheduling mechanism is used to repeatedly reuse instances. For beans with Cache Management, the activation and deactivation mechanisms are used to maintain the Bean status and limit the number of instances in the memory.
77. EJB activation mechanism
Taking Stateful Session Bean as an example: the Cache size determines the number of Bean instances that can coexist in the memory. According to the MRU or NRU algorithm, instances are migrated between the activation and deactivation statuses, the activation mechanism is that when the client calls a business method of an EJB instance, if the corresponding EJB Object finds that it is not bound to the corresponding Bean instance, it will activate Bean storage from it (storage instance through serialization mechanism) reply (activate) this instance. The corresponding ejbActive and ejbPassivate methods are called before the status changes.
78. EJB types
Session Bean, Entity Bean Message-Driven Bean
Session beans can be divided into Stateful and Stateless.
Entity beans can be divided into two types: Bean management continuity (BMP) and container management continuity (CMP ).
79. Basic Steps for client to call an EJB object
Set the properties of the JNDI service factory and the JNDI service address system, find the Home interface, call the Create method from the Home interface to Create the Remote interface, and use the Remote