Web Web container vs. servlet

Source: Internet
Author: User
Tags jboss

first of all, let's talk about servers we know.,likeIIS, Tomcat, Jbosswait.They all have to do withWebApply the, IISis aWebService Components,includeWebServer, the FTPServer, NNTPservers, andSMTPServer; Tomcatbelongs to the lightweightWebServer,in small to medium-sized projects we often use; JbossIt 's a heavyweight.WebApplication Server,includeEJBContainers andWebServer,of ourItoothe project used to beJboss.

let's see. Web servers, and Web the relationship of the application .



Web Server and Web applications fall into different categories , they need to collaborate with a standard interface . , Servlet is one of the main interfaces .

Servlet Container :

It isJavawebthe core of the application,most commonly used components.we still remember inWeb. XMLis configured in the file.ServletElements,This is because a customer requests access to a specificServletbefore, Servletcontainers need to create a series ofServletabout the object.Let's take a look at the process..

The client makes a request,there 's a need.,soServletThe container just stands out and it says to receive,You 're going to have to work after receiving the request,so it has to parse the request.,then left to create aServletRequestObject,(contains information such as customer requests).right Creates aServletresponseObject.whenServletcontainer calls a specificServletof theServicemethod of the time, ServletRequestand theServletresponsewas quietly sent in to do the argument..of specificServletthat's a pleasure.,fromServletRequestget customer request information in an object,UseServletresponseobject produces the corresponding result. Servleta look at the container,Whoa, shove .,the results come out.,we'll send it to the client..

Servletthe container is a god horse thing.?like it didn't do much work .,is to have the needs of customers,built two creeps.,let the creeps carry the demand .,It also tells Creeps toServicewhen the method is called,it needs to recite the demand .,let another creep bring the results back ..containers Create objects and make objects work in harmony,and able to communicate well with the outside.Tut -tut,It's bull ..

that's better than a good picture. , there 's a picture of the truth .



Servlet Interface :


all the Servlet has been implemented Servlet Interface , There are five methods in an interface . respectively is :

Init () ;

Service ();

destory () ;

Getservletconfig ();

Getservletinfo ();

which, Init (), Service ()and thedestory ()is called by the container.,in a differentServletThe life cycle phase is called separately.container Initializes aServletObject when,Create aServletConfigObject,include thisServletthe initialization parameter information. ServletConfigobject is only for oneServleteffective,cannot be anotherServletaccess to.

in theServletthe related object also has aServletContextObject, ServletContextand theServletConfigthe difference is: ServletContextto anyServletare valid,is a global object.We'll learn more about both of them in our next blog post..



Web Web container vs. servlet

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.