J2EE Web Development Overview
Java was originally designed for consumer electronics, and the result has not been applied. Later, as the Internet raised, an applet technology allows users to run Java in the browser to make the web page to present dynamic content, but will soon be replaced by DHTML and Flash. Until the appearance of Java Servlet, Java started to show a vitality in the server side, as J2EE standards appeared, Java has received more and more wide applications in the server side and eventually established facts.
Servlet is a Java small service launched by Sun, which is written in Java, run in the servlet container, can dynamically output HTML. Compared with traditional CGI, servlet is more stable, faster, and has higher development efficiency, which is the basis for the entire Java Web development.
Since servlet is output HTML in the Java code, it is not visualized to design the page, and Java developers generally do not have the ability to design a beautiful and generous page, and another JSP technology has appeared.
JSP is still a servervet. The JSP page is embedded in a HTML page. It will be compiled into a servlet before execution, so HTML developers do not need Java to create a JSP page.
Servlet is embedded in the Java code, and JSP is embedded in the Java code in HTML. The two ways determine that servlet is suitable for processing background logic, while JSP is used to send the user to send the processing result page. In a complex large site, it is usually used by servlet as a controller, JSP view, so that Java developers can focus on background business logic, while HTML developers can focus on page design. We will discuss how to apply the MVC framework in Java Web development later.
JSF (JavaServer Faces) is similar to ASP.NET technology that allows Web components running on the server and supports event drivers, which is actually an enhancement of JSP.
With the increasing complexity of enterprise applications, the updated web technology --portal (portal) appears, Portal can dynamically assemble the web component portlet, provide users-centered custom services, if you are interested in Portal, please refer to
J2EE Portal technology.
Web basic tutorial
Servlet is a small service written in a Java language, you must be familiar with the Java language and understand a certain HTML. You must install before learning servlet
J2DK and a server that support servlet, recommended
Tomcat or
RESIN.
Recommend you can pass the tutorial
Building Java Http Servlets
Chinese) to learn the servlet. In addition,
Building Servlets with session tracking
Chinese) also explains how to use sessions in servlets to track users.
Develop JSP and servlet
J2DK and a server that support JSP. Because JSP will eventually be compiled into a servlet, servlet servers generally support JSP, recommended
Tomcat or
RESIN.
Getting started with JSP technology is a good JSP tutorial. If you still want to know the JSP tag technology, please take a look
Mastering JSP Custom Tags (
Chinese).
JSF is currently in development, if you want to know more about this, please see
Introduction to JavaServer Pages Technology and
UI Development with JavaServer Faces (Chinese).
Web senior development
Typically, servlet is used as a Controller (controller), which is responsible for receiving user requests, then calling MODEL (model: javabean, ejb and other business logic components) to get results, select a view (view, usually a JSP page), will The result is passed to the View, and finally the View renders the HTML page and returns to the user to complete a complete HTTP request, which is the MVC architecture of the Web layer (called MVC2 or MVC passive mode). Why use such a complex MVC architecture instead of completing all the features in a JSP page? This is because with the growth of site features, background business logic is increasing, and it is necessary to make business logic components (such as JavaBean, EJB) to call in multiple pages. In addition, with the increase of the number of pages, the link coupling between each JSP page is increasing, and the maintenance is getting worse, and the modification of a page often affects many pages associated with it, so the link to each JSP page will be affected. Coupling is very necessary.
The MVC mode is to reduce the complexity of the design to reduce the complexity of each module function, so that the scalability and maintainability of a web application are greatly enhanced.
MSDN
Model-View-Controller
Chinese) One article explains the MVC architecture in detail, recommend reading.
Often, we don't have to realize a MVC framework, there are many ready-to-use MVC frameworks:
Struts: The first one earliest is also the most widely used MVC framework, although there are a lot more excellent than Struts, but Struts is the most typical MVC implementation mode, and its design idea has far-reaching effect.
Details >>
MAVERICK: A MVC framework similar to Struts, but does not require Action Form, and supports other View technology such as Velocity.
Details >>
Spring MVC: Since otherwise, Spring itself is a complete J2EE framework, and the MVC module is only the functionality provided by the web layer. If you plan to use Spring to develop J2EE applications, the MVC framework provided directly in the Web layer can play Spring's IOC power.
Details >>
JPF: JavaPage Flow is a complete Struts-based MVC framework developed by BEA, providing many enhanced features. Due to the complexity of the Struts underlying, with the powerful visual development feature of Workshop IDE, it is easy to use JPF. Disadvantages are currently only running on WebLogic Server, although BEA is working hard to use JPF technology as a standard to other web servers such as Tomcat.
Details >>