Today in See Li Xinghua "Javaweb Combat classic" time, saw the integration with Jsp+dao to do a database of additions and deletions to change the operation. The program is not difficult, but it has reference significance. Generally speaking, the main operation of Javaweb project is to operate the database, its essence is operation database. What Mvc,javabean from a certain point of view is redundant, if the user will write SQL, what to view what to do, direct database lookup is not good?
In general, you can implement one of the simplest BS projects, which can have several patterns:
1 jsp + JDBC This write JSP is all Java code, very unfavorable to maintenance and expansion.
2 JSP + DAO This business logic is still written in the JSP.
The advantage of 3 JSP + Servlet + JDBC (MVC) is that the lower-level service, the business logic, can be invoked at the time of the jump servlet. (JSP page aesthetics can use EL,JSTL)
4 various frame combinations. Spring,struts,hibernate. Spring is the framework that takes over all layers. Struts is the framework of the Web layer, and hibernate is the persistence layer framework. As far as I know, durable layer of mature products, single on the data connection pool here C3p0,apache Dbcp,alibaba Druid (known as the world's fastest connection pool), in short, in the Java world, as long as the unexpected, there is no implementation.
More than 5 is a single-machine framework, and the complexity of the design will span an order of magnitude if distributed environments and high concurrency environments. How to put session,cookies in distributed environment? How to design a distributed session framework? How does the JVM tune? I/o read? ..... No research for the time being.
Draw a chapter Li Xinghua the call graph of the case in the teacher's book:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7E/8A/wKioL1cEC9eSqcm4AAGwh9_zSRo740.jpg "title=" Gotohibor23875500.jpg "alt=" Wkiol1cec9esqcm4aagwh9_zsro740.jpg "/>
The example is not difficult, but the use of two Java design mode and interface decoupling, but also the use of the design pattern: DAO mode, and VO mode (in fact, is JavaBean, the object can reduce network overhead). Think the case is very good. Also understand why the next JSP jump must pass through a servlet, and this is the servlet called the lower service. is much more convenient and modular than the JSP call.
The following changes the diagram:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/8E/wKiom1cEFADCVJw8AANbVw9RCnk339.jpg "title=" Mvc.jpg "alt=" Wkiom1cefadcvjw8aanbvw9rcnk339.jpg "/>
It can be seen that layered thinking plays a central role in it. Each layer to do its own duties within the matter, meddling in the complexity of the program to improve. Business is a complex interface feeling very messy. In fact, layering is an abstraction, a logical layering, in fact, more than a few JSP and Java files are written.
This program is not difficult, but the design ideas and design patterns in such a program are well worth thinking about. There are GOF23 design patterns in Java, there are 21 design patterns in the EE, two design pattern factions.
There is a picture for proof:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/8A/wKioL1cED9aCCjaPAAN6YlGDR-Y881.jpg "title=" Gotohibor25538705.jpg "alt=" Wkiol1ced9accjapaan6ylgdr-y881.jpg "/>
I guess I'll have to recommend a book again:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/8E/wKiom1cED5SwwHtrAADuxLdUzro463.jpg "title=" J2ee.jpg "alt=" Wkiom1ced5swwhtraaduxlduzro463.jpg "/>
And see a few good pictures:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7E/8A/wKioL1cEEGiSG1jwAADhksqb7aU534.jpg "title=" Gotohibor25804468.jpg "alt=" Wkiol1ceegisg1jwaadhksqb7au534.jpg "/>
Sleep, good tired!
Wrote for so long, only 1000 words, dizzy!
Jsp+dao Implementing a Database Crud