J2EE Web development overview [Reproduced]

Source: Internet
Author: User
J2EE Web development overview

Java was originally designed for consumer electronic products at the beginning and has never been applied. Later, with the rise of the Internet, an Applet technology allows users to run Java in the browser so that the web page can present dynamic content, but soon it was replaced by DHTML and Flash. Until the emergence of Java Servlet, Java began to show its vitality on the server. With the emergence of the J2EE standard, Java has been widely used on the server, and finally established the de facto industrial standards.
Servlet is a small Java service launched by SUN. It is written in Java and runs in the Servlet container to dynamically output HTML. Compared with traditional CGI, Servlet is more stable, faster, and more efficient in development. It is the basis for Java Web development.
Because Servlet outputs HTML in Java code, you cannot visually design pages. Java developers generally do not have the ability to design beautiful and generous pages, so another JSP technology emerged. JSP is still Serlvet in essenceThe JSP page is embedded with Java code in an HTML page, which is first compiled into a Servlet before execution. Therefore, HTML developers can create JSP pages without learning Java.
   Servlet embeds HTML in Java code, while JSP embeds Java code in HTML.The two methods determine that the Servlet is suitable for processing the background logic, and JSP is used to send the processed result page to the user. In a complex large site, Java developers usually adopt the MVC Architecture with Servlet as the controller and JSP as the view, so that they can focus on the background business logic, HTML developers can focus on page design. We will discuss in detail how to apply the MVC Framework in Java Web development.
JSF is a technology similar to ASP. Net. It allows you to use Web components running on the server side and supports event-driven, which is actually an enhancement to JSP.
With the increasing complexity of enterprise applications, the new Web technology-Portal (Portal) emerged. The Portal can dynamically assemble Web component Portlet to provide user-centric custom services, if you are interested in Portal technology, refer to J2EE Portal technology.

Basic Web tutorial

Servlet is a small service written in Java. You must be familiar with Java and understand HTML. Before learning Servlet, you must install J2SDK and a server that supports Servlet. We recommend that you use Tomcat or Resin.
We recommend that you use the Building Java HTTP servlets (Chinese) Tutorial to learn Servlet. In addition, Building servlets with session tracking (Chinese) explains how to use sessions in Servlet to track users.

The development of JSP requires J2SDK and a server supporting JSP, just like Servlet. Because JSP will eventually be compiled into Servlet, the Servlet server generally supports JSP. Tomcat or Resin is recommended.
JSP technology entry is a good JSP tutorial. If you want to know more about the JSP tag technology, you can refer to Mastering JSP custom tags (Chinese ).

JSF is currently in development. If you want to learn more about this, see Introduction to JavaServer Pages technology and UI development with JavaServer Faces (Chinese ).

Advanced Web development

Generally, Servlet is used as Controller)To receive user requests and then call Model (Model: JavaBean, EJB and other business logic components)Obtain the result and select View (View, usually a JSP page)To pass the results to the View, and finally render the HTML page and return it to the user to complete a complete HTTP request. This is the Web layer's MVC Architecture(Called MVC2 or MVC passive mode ).
Why is it necessary to use such a complex MVC Architecture instead of completing all the functions on a JSP page? This is because as the site functions grow, the background business logic becomes more and more complex. It is necessary to independently make business logic components (such as JavaBean and EJB) for calling in multiple pages. In addition, as the number of pages increases, the link coupling between JSP pages is increasingly enhanced and the maintainability is getting worse. Modifications to a page often affect many pages associated with it, therefore, it is necessary to decouple the links of each JSP page. The MVC mode reduces the complexity of the functions of each module by increasing the design complexity, thus greatly enhancing the scalability and maintainability of a Web application.
The Model-View-Controller (Chinese) Document of MSDN explains the MVC Architecture in detail and recommends reading it.

Generally, we do not have to implement an MVC framework by ourselves. There are already many ready-made and ready-to-use MVC frameworks:
  Struts: The first one was also the most widely used MVC Framework. Although there are many better frameworks than Struts, Struts, as the most typical MVC implementation mode, has a far-reaching impact on its design philosophy. Details>
  Maverick: A mvc framework similar to Struts, but does not require Action Form, and supports other View technologies such as Velocity. Details>
  Spring MVC: To be exact, Spring itself is a complete J2EE framework, and the MVC module is only a function provided by the Web layer. If you plan to use Spring to develop J2EE applications, you can use the MVC framework provided by Spring on the Web layer to make full use of Spring's IoC power. Details>
  JPF: JavaPage Flow is a Struts-based MVC framework developed by BEA. It provides many enhanced functions. JPF is easy to use because it encapsulates the underlying complexity of Struts and works with the powerful visual development functions of Workshop IDE. The disadvantage is that it can only run on WebLogic Server, although BEA is trying to promote JPF technology as a standard to other Web servers such as Tomcat. Details>

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.