Summary of Javaweb Review notes

Source: Internet
Author: User
Tags java web

1, the HTTP protocol is located in the application layer, based on the TCP/IP protocol, the port is 80

2. HTTP request consists of (1) Request method, Uri and version of HTTP protocol (2) request header (3) Request Body composition

HTTP response by (1) HTTP protocol version, status code and Description (2) response Header (3) Response body

3. Get request parameter after HTTP request first line URI

The POST request parameter is used as the body part of the HTTP request

4, ServletContext and Web applications have the same life cycle

5. REDIRECT Sendredirect: User Request--the server returns 302 status code--the browser receives a response and automatically requests another web

6. JSP life cycle: (1) parsing stage: Servlet parsing jsp (2) Translation phase: Servlet container translates jsp file into servlet source file

(3) Compile stage: Compile servlet source file generation class

(4) Initialization phase: Load the servlet class corresponding to the JSP file, create the instance, call the initialization method (5) Runtime phase (6) Destroy phase

7, Sendredirect redirect forward server internal forwarding

Address has changed the address bar has not changed

Cannot share data that can be shared within request

URLs can jump to other sites only within the same web

Less efficient

Browser Jump Server Jump

HttpServletResponse RequestDispatcher

8. servlet Life cycle

A, if a static page is requested, the server returns directly

b, if it is dynamic, to the Web container, if the servlet is not found (first access not), then read the XML configuration file, put the corresponding servlet into the Web container, and then create the servlet instance,

Call Init ()--judge service ()-->doget (), Dopost (), and then return to the browser-->destory ()

9. Cookies and Session

Cookies: The client does not have a cookie at the beginning, and when it accesses the server it creates

Session:session does not start, the server creates a session, and then returns and saves SessionID on the client

10. Spring can wrap hibernate anomalies and turn them from checkedexception to RuntimeException

11. Spring provides programmatic transactions (embedded in business code) and declarative Transactions (XML)

Sessionfactory only needs to be injected using hibernate, injected into the transaction manager

12, Spring Core Controller, Dispatcherservlet is responsible for receiving HTTP requests, loading configuration files, initializing context ApplicationContext, file upload parsing

13. Difference between spring and struts2

(1) Springmvc is based on method design, STRUTS2 based on class

(2) Struts has its own INTERCEPTOR,SPRINGMVC with an independent AOP approach

(3) The Springmvc method is basically independent and enjoys request,response data. Struts2 all action variables shared by the

(4) The entrance to the SPRINGMVC is Servlet,struts2 is the filter

14. Design patterns used in spring

(1) Factory mode: Beanfactory

(2) Single case mode, relying on injection with double judgment lock

(3) Adapter

(4) Agent

15, spring two agent way: JDK and Cglib

(1) If the target object implements a number of interfaces, then use the proxy agent of the JDK

(2) If no interface is implemented, the subclass is generated with the Cglib library

The JDK proxy is implemented by the reflection mechanism inside Java.

Cglib is implemented with ASM, and third-party libraries are used to introduce Cglib.jar,asm.jar

JDK proxy to be the same interface class for the target class

Cglib proxy needs to generate an enhanced target class

Specific use can be viewed: https://www.2cto.com/kf/201701/590030.html

16, the site load is too large: using cache, cluster, CDN acceleration, distributed

17. Message Queuing: Queue messages in the order in which they are generated. SMS, email, subscription, etc.

18. The difference between Struts1 and struts2

Struts1 is heavily coupled with Servlets, Action->execute

(1) Action must implement the action class of struts, Struts2 can not implement any class or interface

(2) The Struts1 action is a singleton pattern and must be thread safe. Struts2 is an instance of each request

19. The difference between hibernate and MyBatis

(1) Basic no complex statement optional Hibernate,sql package is good, development fast. Be responsible for multi-statement selection MyBatis

(2) MyBatis requires handwritten SQL

(3) HIBERNATW good transplant, MyBatis need different database different SQL

20. The difference between filter filters and Interceptor Interceptor

A, filter is based on the function callback, interceptor based on the Java reflection mechanism

B, filter relies on the servlet container, interceptor does not depend on

C, filter works on almost all requests, interceptor only works on action

D, interceptor can access the action context, the object in the value stack. and the filter cannot

E, interceptor can be called multiple times in action, and filter is only called once when the container is initialized

F, Execution order: filter before and after interception->action-> interception

21. Hibernate level Two cache

The first-level cache is the session level. The second level cache is sessionfactory basic

The first-level cache is a transaction-level cache and must be the same session. A secondary cache is a process-wide cache. The same operation can be done with the cache

The first-level cache does not have concurrency problems. The second-level cache will

Application scenario: Level Two cache: (1) rarely modified data (2) unimportant (3) not be concurrency

22, Maven snapshot representative version is not stable, in development

Release stands for stable version, release version

23. AOP is just a complement to OOP. AOP is a design pattern, and spring provides a way to implement

24, spring, the bean's scope default is singleton

25, A, Java servlet API refers to the session mechanism to track customer status, defines the HttpSession interface, the Servlet container must implement the interface

b, when a session starts, the Servlet container will create a httpsession, assign SessionID, a client browser, and if disabled cookie,servlet can rewrite the URL of the customer request, Put the SessionID into the URL

C, HttpServletResponse interface provides rewrite String.encodeurl (URL)

26. IOC Injection method: attribute injection, construction injection

If there is no value injected, the injection is constructed according to the configuration file, and if so, the construction injection fails

27. How to get the connection pool in the spring framework

A, DBCP data source

B, c3p0 data source

C, Spring's Drivermanagerdatasourse

D. Get Jndi data source

28. Spring can configure bean initialization and extinction functions in the configuration file

29, Doget and Dopost are the methods of HttpServlet

Servlet:init (), service (), Destory ()

Requestdispatcher:forward ()

30. The advantages of Spring

(1) reduced coupling (2) container provides singleton mode support (3) provides AOP technology, rights interception, run-time monitoring (4) low-intrusive design

(5) Spring's di mechanism reduces complexity of business object substitution

IOC Factory mode AOP proxy mode

31. IOC means that control is transferred from the application code to the external container

The servlet interface defines the life cycle of the servlet

The IOC is responsible for controlling the life cycle of objects and the relationships between objects by spring.

ApplicationContext built on Beanfactory to provide system architecture services

32, Beanfactory and ApplicationContext

Same: Load bean,applicationcontext with XML config file is derived by Beanfactory interface

Different: Beanfactory is deferred loading until the first call to Getbean will cause an error. ApplicationContext is tested at initialization time

33. SSH Struts Controller spring manages each layer hibernate persistence layer

SSM SPRINGMVC Spring Mybatis

34, Struts2 and Springmvc principle (self Google or Baidu, two flowchart)

Reference books: Tomcat and Java Web Development Technology (second Edition) Sun Weichen, large Web site Technology architecture: Core Principles and case studies-hae, spring combat, Spring Technology Insider

--------------------------------------------------------------------------------------------------------------

The above for Maplefighting personal note collation, if there is an error, please correct

Summary of Javaweb Review notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.