Concepts in Java Web Application Development

Source: Internet
Author: User

[51cto exclusive Article] The concept has always been a common problem in computer software development, and is also the most favorite thing in the software industry. In many cases, the difficulty of learning computer software development is due to lack of understanding of some concepts, rather than the complexity of technology. Java Web, as part of the Java EE technical system, should be the most complex of all current web development technologies. Many beginners, or developers transferred from ASP and PHP will encounter conceptual difficulties.

In fact, many concepts are non-productive and simple, just because manufacturers complicate and academic concepts for the purpose of propaganda, which makes learners feel that these concepts are very esoteric and hard to understand. Here, we will first clarify several common basic concepts in Java Web development. Of course, the premise for understanding these concepts is that you must have basic knowledge in computer systems, object-oriented, and other aspects.

1. Web Container

All programs must have a necessary runtime environment. This environment can be software, hardware, or a combination of software and hardware. For example, the Windows operating system needs to run on the basis of hardware, and the office software needs to run on the operating system. In addition, there will be a certain amount of data exchange between the program and the running environment. For example, the operating system will pass the running command to the hardware, and the hardware will also pass the command running result to the operating system. Java Web programs also need a runtime environment for execution. This environment for running Java Web programs is called Web containers. Data exchange exists between Java Web programs and web containers. Currently, there are two types of Java Web containers: one is an independent Java
Web containers can only run web programs in such containers. Such containers are also called Web servers, such as Tomcat. The other is Web containers mixed with other Java EE containers, web containers are responsible for running web programs, while other containers are responsible for running EJB and other programs, such as weblogic.

When a user sends a request to the server through a browser or other Web client software, the Web Container receives the request first, the Web Container encapsulates the request information in a Java object of the httpservletrequest type and passes the object to the Java Web program. For each request, the Web Container will also create an httpservletresponse type object, which is used to save the content that needs to be returned to the browser and other clients. Java Web programs can extract user-sent request information from httpservletrequest and place the processing result to httpservletresponse after proper processing. However, the Web Container can parse the content of the httpservletresponse object, the resolution result is returned to the browser and other clients in HTML format that can be recognized by the browser. In this process, httpservletrequest and httpservletresponse are like two ferries, responsible
Transfer information between web programs. Note that these two objects exist only in Web containers and Java Web programs, and have nothing to do with browsers. It is in this process:

2. Web Applications

A Web application can be considered another name of a Web application. The missing definition is an application running in a Web container that can complete the entire function. A Java Web application consists of a series of compiled Java classes, static images, static html files, and configuration files. The Java Web application can receive user input and requests, process request information, access the database, and respond to user requests. Development of Java Web application processing needs to comply with some special requirements of Web applications, there is no essential difference with the development of other types of applications. Currently, there are two main types of Web applications: one is to display for the purpose of Web applications, such applications will be most requested to return content in HTML and other marked text or media formats recognized by the browser, users can operate such applications through browsers and other clients. The other type is service-oriented web applications. Such applications do not provide graphic operation interfaces, but only provide method call structures, such as web services. Such applications can only be called and accessed by other applications.

3. Web Components

A Web component is a basic unit for a Web application to respond to client requests such as browsers. In Java Web applications, the Web components provided include servlet, JavaServer Pages (JSP), and JavaServer faces (JSF. You can also use other types of Web applications, such as HTML files and static images. In fact, Java Web only provides a Web component, that is, Servlet, JSP, and JSF are servlet-based derivative technologies. Servlet is essentially a Java class with special inheritance requirements.
Web technology.

4. Web module

In addition to Java Web, Java ee also includes other technologies such as EJB. Each technology system runs in its own containers. Different parts are combined to form a complete Java EE application. Each part is called a Java Web module or an EJB module based on its own characteristics. They are called modules because different parts of Java EE applications can be combined into larger and more complex applications like building blocks, and each part ensures its independence. Different modules have their own specific directory structure requirements. The directory structure requirements of the Java Web module are as follows:

◆ Application document root directory. The directory is the top directory of the Java Web module. All Web Components and configuration files that constitute the web module are included in this directory or subdirectory. You can directly store HTML files and image files in the modified directory.

◆ WEB-INF directory. The Change directory is located in the root directory of the application documentation, which is used to save files that do not want to be accessed by browsers and other clients, such as release description files and compiled class files. Because these files are interpreted or executed by web containers. The browser cannot directly view these files, but can only view the execution results of these files.

◆ Web. xml file. This file is located in the WEB-INF directory, is the Web Application Deployment description file, used to define the web application running information, such as the execution logic, Servlet and other Web Components access path. The file format must meet the specifications of the used servlet version.

◆ Classes directory. This directory is located in the WEB-INF directory, used to save compiled Java class files, such as servlet, helper class, other business processing class.

◆ Tags directory. The directory is located under the WEB-INF directory to save the label description files for those tag libraries.

◆ Lib directory. This directory is located in the WEB-INF directory, used to save the web application running dependent, After packaging Java class files. The packaging format is generally. jar.

For Web-INF and web. in addition to XML, classes, tags, and Lib, you can create other directories under the root directory of the Web application documentation as needed, for example, you can create a directory for an image, HTML for different purposes, or JSP, or create a package directory under classes for unused Java classes. If Java Web components, such as Servlets, filters, and listeners, are not used in your web application, there is no web. xml file. If tags are not used, no tags directory is available.

You can publish a web module directly in a directory or package it into a jar file. Because of its usage and content, the extension of the packaged file uses. War instead of. jar. In addition, if it is not released to an independent web server, but to an enterprise application server used together with other Java EE, you also need to compile a configuration file related to the enterprise application server, this file is also different for different enterprise application servers, such as publishing to the glassfish server, the need to compile the file when sun-web.xml.

 

Related Article

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.