Original: http://blog.csdn.net/liuxiaogangqq/article/details/8124793
1, the difference between JSP and servlet, common ground, the scope of their respective applications??
JSP is the extension of servlet technology, which is essentially a simple way of servlet. The JSP is compiled with a "class servlet". The main difference between Servlets and JSPs is that the application logic of the servlet is in the Java file and is completely detached from the HTML in the presentation layer. The case for JSP is that Java and HTML can be combined into a file with a. jsp extension. JSPs focus on Views, and Servlets are used primarily for control logic. In the struts framework, the JSP is in the view layer of the MVC design pattern, and the servlet is in the control layer.
2, the role of the cookie and the session, the difference, the scope of application, the working principle of the session???
Cookies: Mainly used in the preservation of the client, whose value is transmitted between the client and the server, insecure, the amount of data stored is limited.
Session: Saved on the server, each session has a sessionid on the server to make an identity. The amount of data stored is large and security is high. Consumes memory resources on the server side.
3. What is JSTL? What are the advantages??
JSTL (JSP standard tag Library, JSP standards tag libraries) is an evolving, open-source JSP tag library consisting of four custom tag libraries (core, format, XML, and SQL) and a pair of common tag library validators (SCRIPTFREETLV and PERMITTEDTAGLIBSTLV). The advantages are:
1, the application server provides a consistent interface between the maximum program to improve the application of the Web application server between the porting.
2. Simplifies the development of JSP and Web applications.
3, in a unified way to reduce the number of scriptlet code in the JSP, can be achieved without any scriptlet code of the program. In our company's project, no scriptlet code is allowed to appear in the JSP.
4. Allow for further integration of JSP design tools with Web application development. It is believed that the IDE development tools that support JSTL will soon appear.
4. What are the advantages of the Java EE? MVC pattern
A, the Java EE Technology, platform-Independent
b, the Java EE has open standards, many large companies have implemented the application server for the specification support. such as Bea, Ibm,oracle and so on.
C, Java EE to provide a fairly professional general software services.
D. Java EE provides an excellent enterprise application framework that lays the foundation for fast, high-quality development systems.
Model models: The body part of the application that represents the business logic.
View view: The part of the user interface in an application that is the interface that the user sees and interacts with.
Controller controllers: Used to control user interface data display according to user's input, update model object state.
The emergence of MVC pattern not only realizes the separation of function module and display module, but also provides the maintainability, expansibility, portability, and reusability of the application system.
5, the advantages of struts
A, the implementation of the MVC pattern, the structure is clear, so that developers only need to focus on the implementation of business logic.
b, there is a rich tag can be used, can greatly raise enough development efficiency, shorten the development time.
C, page navigation. Through a configuration file, you can grasp the connection between the parts of the whole system, which is of great benefit to the later maintenance.
D, provide exception processing mechanism
E, Support l18n
6. Why use struts?
The advent of JSP, Servlet, and JavaBean technology gives us the possibility to build powerful enterprise application systems. But the systems built with these techniques are very fanluan, so on top of that, we need a rule, a rule that organizes these technologies, and that is the framework in which struts emerges.
Struts-based applications consist of 3 types of components: Controller components, model components, view components
7, Sturt1 core class, core tag library?
Actionservlet Controller, actionmapping State Change event, part of action Controller, Actionforward user point, actionform State change data
HTML tags, bean tags, logic tags, tiles tags, nested tags
8, the difference between Struts1 and Sturts2 (Struts2 is the combination of struts1 and webwork)
1. STRUTS1 requires the action class to inherit an abstract base class, not an interface.
The action class of struts2 can implement an action interface, or it can implement other interfaces.
2, Sturts1 action is a singleton mode, thread is safe.
The Struts2 action thread is not secure, and the action generates an instance for each request.
3, Sturts1 used to rely on Serlet API, not easy to test.
The struts2 does not depend on the container, allowing the action to be tested separately from the container.
4. STRUTS1 uses Actionform object to capture input. All Actionform must inherit a base class.
Struts 2 uses the Action property directly as an input property, eliminating the need for a second input object.
5, Struts1 integrated Jstl, so the use of Jstl EL. This El has a basic object graph traversal, but support for collections and indexed properties is weak.
Struts2 can use Jstl, but it also supports a more powerful and flexible expression language-"Object Graph Notation Language" (OGNL).
6, Struts 1 uses the standard JSP mechanism to bind objects to the page to access.
Struts 2 uses "Valuestack" technology to enable taglib to access the values without having to bind your page (view) and objects together.
7. The Struts 1 Actionform property is usually of type string. Struts1 uses commons-beanutils for type conversion.
STRUTS2 uses OGNL for type conversion. A converter that provides basic and common objects.
8. Struts 1 supports Manual Check in the Validate method of the Actionform, or is verified by Commons Validator extension.
STRUTS2 supports validation through the Validate method and the Xwork check framework.
9, STRUTS1 support each module has a separate request processors (life cycle), but all the actions in the module must share the same life cycle.
STRUTS2 supports creating different lifecycles for each action through the Interceptor Stack (Interceptor Stacks). Stacks can be used in conjunction with different actions as needed.
9. The difference between filters and interceptors
1, interceptors are based on the reflection mechanism of Java, and filter is based on function callback
2. The filter relies on the servlet container, and the interceptor does not depend on the servlet container
3. Interceptors only work on action requests, while filters can work on almost all requests
4. The interceptor can access the action context, the object in the value stack, and the filter cannot
5, in the life cycle of the action, the interceptor can be called multiple times, and the filter is only called once when the container is initialized
Interceptors: Is programming in the face of the plane is in your service or a method, before calling a method, or call a method after a method such as a dynamic proxy is a simple implementation of the Interceptor, before you call the method to print out the string (or other business logic operation), You can also print out a string after you invoke the method, even if you do business logic when you throw an exception.
Filters: In the Java Web, your incoming request,response filters out some of the information ahead of time, or sets some parameters ahead of time, and then passes in the servlet or struts action for business logic. For example, filter out illegal URLs (not login.do address requests, if the user does not log on to filter out), or in the servlet or struts before the action of the uniform set of character sets, or to remove some illegal characters.
10. Hibernate is an open source object-relational mapping framework that provides JDBC with a very lightweight object encapsulation that allows Java programmers to manipulate the database at will using object programming thinking.
Working principle:
1. Read and parse the configuration file 2. Read and parse the mapping information, create Sessionfactory 3. Open sesssion 4. Create transaction transation 5. Persist Operation 6. COMMIT TRANSACTION 7. Close Session 8. Close Sesstionfactory
The advantages are:
1. The code for JDBC access to the database is encapsulated, which greatly simplifies the tedious repetitive code of the data access layer.
2. Hibernate is a JDBC-based, mainstream persistence framework that is an excellent ORM implementation. He simplifies the coding of the DAO layer to a great extent
3. Hibernate uses the Java reflection mechanism instead of the bytecode enhancer to achieve transparency.
4, Hibernate performance is good, the flexibility of mapping is better. It supports a variety of relational databases, from one-to-one to many-to-many complex relationships.
11. What is the core class of Hibernate? What is the important method??
Configuration, Sessionfactory
Session the following methods Save, load, Update, Delete
Query q=createquery ("from Customer where Customername=:customername")
BeginTransaction, Close, Transaction, Commit ()
12. The difference between session.load () and Session.get ()
The Session.load/get method can read records from the database based on the specified entity class and ID, and returns the corresponding entity object. The difference is:
If a record that matches the condition is not found, the Get method returns NULL, and the load method throws a objectnotfoundexception.
13, HQL and SQL "You can say that Hibernate is the bridge between the object-oriented language and the relational database, which allows programmers to concentrate on writing business logic without having to worry about the underlying database connection code." 】
SQL is a database-oriented table query
HQL is an object-oriented query whose form clause returns an instance of an object.
14. Hibernate and JDBC The difference between "hibernate" can be said to be a bridge between object-oriented languages and relational databases, allowing programmers to concentrate on writing business logic without having to worry about the underlying database connection code. 】
Hibernate, as an O/R Mapping, has the advantage over JDBC:
1. Programming ideology, more in line with the human logic thinking habits, object-oriented than process-oriented easier to understand, testing and maintenance
2. Hibernate significantly faster in development and maintenance speed, with significantly smaller code volume
3. Field encryption of the database via annotation
4. For beginners who are not familiar with SQL, can be automatically tuned
5. In conjunction with spring, transaction control can be omitted through declarative transactions, and transactions appear in cross-sectional form
The advantages of JDBC over hibernate are:
1. JDBC is significantly more efficient when accessing large data volumes
2. Direct operation of the database is more flexible
15. How does hibernate delay loading?
When hibernate is querying the data, the data does not exist in memory, and when the program actually operates on the data, the object exists in memory, and the delay is loaded, which saves the server's memory overhead and improves the performance of the server.
16. Hibernate caching mechanism
1. Internal cache exists Hibernate is also called a first-level cache, belongs to the application of the thing-level cache
2. Level Two cache:
A) application and caching
b) Distributed cache
c) Implementation of third-party caches
17. Spring working mechanism and why should it be used? Spring is a lightweight control reversal and aspect-oriented container frame.
1.SPRINGMVC submits all requests to dispatcherservlet, and it delegates the other modules of the application system responsible for the actual processing of the request.
2.DispatcherServlet queries one or more handlermapping to find the controller that handles the request.
3.DispatcherServlet submit the request to the target controller
4.Controller after the business logic is processed, it returns a Modelandview
5.Dispathcher querying one or more viewresolver view resolvers, locating the View object specified by the Modelandview object
6. The View object is responsible for rendering back to the client.
The IOC is the container that controls the dependencies between business objects. The essence of control inversion is that control is transferred from the application code to the external container, and the transfer of the controller is the so-called reversal. The benefit of the transfer of control is to reduce the degree of dependence between business objects, that is, to realize decoupling.
DI/IOC, the control and distribution of the persistence layer and the presentation layer increases the flexibility and stability of the system. AOP, facing the aspect, uses the agent to manage the program effectively.
Spring is a lightweight IOC and AOP framework that is loosely coupled through the Spring IOC, and as an AOP framework he can separate system services, and the best place to achieve cohesive development in spring is that it helps you replace objects. With Spring, you simply add dependencies (collaboration objects) with the JavaBean property and configuration file. You can then easily replace collaboration objects with similar interfaces when you need them. }
Spring provides excellent support for a wide range of ORM frameworks
Go JAVA WEB Face question