Java Web Knowledge Grooming

Source: Internet
Author: User

Today to do a training in-house, seemingly wrong object, should not talk to the new people so the original rational things.

Anyway, or put it up, do not know if anyone can clarify the logic ^ _ ^

Question: Why use Tomcat
Tomcat:servlet container
Servlet + Container

What is the basis of the Web?
Network programming: Links, data
Links: Socket/serversocket
Data: Inputstream/outputstream Stream
What is the data? Bits! Transmission in the network
However, BITS is not what we want, we want information information!
What is information? Bits + context! Csapp
What is the context of Web programming?
TCP, UDP ...
However, this is only the bottom of the surface!
Protocols such as TCP and UDP are themselves for data transfer
How to interpret? or context!?
http!

So,Java Web Network programming is: Create links, and then according to the HTTP protocol format to resolve those transmitted by the TCP protocol data! Be sure to understand this.
Therefore, you must be familiar with the format of the HTTP protocol!

Is it
No!
This is just the body part of the HTTP protocol ! Be sure to understand this.

The problem comes: every time you have to be responsible for the link, tired not tired? It is also necessary to consider optimizations such as concurrent workloads, which require sufficient professional knowledge.
What are the characteristics of Java programming? Let the professional people responsible for professional things!
So the Java EE Community put forward the concept of servlet + servlet container.
The servlet is responsible for the business logic, while the servlet container is responsible for the application, release, and routing of the request! A clear division of labor can be more focused on their own part.

In addition, there is the concept of filter, listener, which occurs because of the characteristics of the container!

Container server, app server, Web server APACHE CGI

Servletcontextloaderlistener, Requestattributelistener

Since the container is responsible for functions such as linking, routing, and so on, it can be handled differently at different stages of the life cycle, before or after the project is loaded, before or after the servlet loads, after the link is created, before or after the route. This is useful to implement some of the requirements more succinctly-similar to the construction method, static code block, dynamic code block, etc. that are executed when the object is created. In addition, spring beans have a similar life cycle.

Yes, and JSP, why do you need this?
Because it is cumbersome to return pages in a servlet, use strings to stitch up HTML statements.
The JSP is much simpler, but in fact, it is turned into a servlet's class file, except that the contents of the output have been converted into strings by the container.
That is, this is a technique that simplifies the servlet's return of HTML content.


The question comes again: since there is a servlet, servlet Container, why are struts, Spring MVC and other frameworks?
This is because the servlet has only the most basic functions, the deeper requirements need to be implemented by users themselves, including synchronous asynchronous processing, codec, parameter/entity class object conversion, internationalization and other functions.

What is the core class of struts? Web. XML Preparexxxxfilter Action Multiple cases
What are the core classes of Spring MVC? Web. XML dispatcherservlet url-mapping/** single case


Why should you have your own core class?
Why are the two different? -Can the core class of struts be replaced by similar SPRINGMVC?


Java Web Knowledge Grooming

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.