Why we need web container to Deploy the servlet or jsp ?

I.e Why we can not run the application like simple java program

Questions by 100881

Showing Answers 1 - 48 of 48 Answers

Ramesh Sukka

  • Nov 17th, 2007
 

Servlets and JSP are server side technologies and should be invoked when we receive request from client browser so web container will act as interface between client request and Servlets and jsp in other words Servlets and jsp will reside under web container in order to server client request. hence we required web container in order to invoke Servlets or jsp

Neha

  • Nov 18th, 2007
 

Servlet and JSP are J2EE web components and Servlet is there to handle the request and give response to clients .. web container is the medium for communication between clients and servlet that is recieving it and sending it to servlet and servlet handle the request and send the response to container that's why web container is essential.

Ramesh Sukka

  • Nov 22nd, 2007
 

Hi Neha,

Can't JSP alone handle the web request (without having servlets)? Should only servlet handle web request?

  Was this answer useful?  Yes

Please be carefully while you com to conclusion on other users comment. First try to understand the question, here the question is, why do we require Web container to deploy servlet or jsp...i think you understood that the question is about purpose of servlet container....However, servlet container will pass information to web container and web container will manage the network level services like connection pooling.

Regards,
Ramesh Sukka.

  Was this answer useful?  Yes

sampra

  • Mar 30th, 2008
 

Servlets and JSP are server side technologies and should be invoked when we receive request from client browser so web container will act as interface between client request and Servlets and jsp in other words Servlets and jsp will reside under web container in order to server client request. hence we required web container in order to invoke Servlets or jsp

  Was this answer useful?  Yes

srini235

  • Jul 4th, 2008
 

can you play a cricket match on a road? if you find the answer for this quaestion you well be able to answer the question the one which host.

  Was this answer useful?  Yes

Compulsorily we need to deploy webresources(Servlet/JSP), in order to execute Servlet/JSP because the web/application server implemented Servlet/JSP APIs. They will not execute in command prompt like standalone applications.

  Was this answer useful?  Yes

We cannot run the application like simple java programs and it will not execute in command prompt like standalone applications. Compulsorily we need to deploy the webresources like Servlet/JSP in webcontainer, container is is heart
of the servers .if u send a request to server first container will create a object and assign request .this servlet and JSP were using creation of webapplications this webapplications must deploy the webcontainer.
In order to execute Servlet/JSP because the web/application server implemented Servlet/JSP APIs.

  Was this answer useful?  Yes

vinayroz

  • Aug 5th, 2008
 

Servlet and JSP both reside in web container. Whenever client send a request thro web server, request is passed to container which in turn invokes the required JSP / Servlet page. Beside this web container imposes all security constraints, connection pooling etc to the application.

  Was this answer useful?  Yes

The two (JSP, Servlet) cannot have the main method, running only the lifecyle, so we use running the application via container only. Container like a tomcat server.

  Was this answer useful?  Yes

We need web container because our Servlet just does a part of whole thing (creating response to a request) rest is done by server that is
1. Accepts response from client formatted HTTP protocol
2. Map that request to ServletRequest
3. Calling service()
4. Mapping ServletResponse to response (HTTP) because browser don’t know ServletResponse
5. And much more like implementation of HTTP, providing classes and interfaces required

so we only need to write Servlet if we have a web server because rest is handled by server.

But it must be noted that we can write a J2SE program to implement a server but you need to know much like Socket, low level protocol handling etc.

Containers are like window for Servlet and JSP's to ourside world. As explain by many answers it provides interface to ourside world. Few advantage of deploying JSP and servlet in container is:


1) Communication between webserver and JSP or servlet is handled automatically.
2) Multithreading is automatically handled by container, without container you have to write your own code to hadle multiple requests to the servlet or JSP.
3) Resource management is big one as container will handle the construction or destruction of servlets according to the resource availability.


Many others.

  Was this answer useful?  Yes

Jyotshna Pardhia

  • Nov 16th, 2011
 

The web container is a Java runtime environment which is responsible for managing life cycle of JSP pages and Servlets. A web container is responsible for instantiating, initializing and invoking Servlets and JSP pages. The web container implements Servlet and JSP API and provide infrastructure for deploying and managing web components.

The web container is part of web server or application server that provides the network services over which request and response are sent. A Web container is may be built into the web server or it may be installed as an additional component to a web server. As per the specification, all web containers must support HTTP protocol however it may support addition protocols like HTTPS. Web container is also called servlet container or servlet engine.

  Was this answer useful?  Yes

sankh

  • Sep 7th, 2012
 

Server site application contains web resources such as active web resources and passive web resources. Those resides in server passive web resource execution done at browser and active web resources are executed at server site. When request goes for Active web resources such as servlet or dynamic pages container come into flash.
Passive web resources are HTML, JavaScript those are executed at browser side. That is why there is no need of container.

  Was this answer useful?  Yes

karna poreddy

  • Jan 22nd, 2014
 

Servlet & JSP are heavy weight Technologies because unless we start web server(web container) or application server we cannot activate either servlet container or JSP Container.

Spring is lightweight:
-----------------------------
Mainly spring is used for business logic. The same business logic if we try to develop using
EJB,Servet and JSP then its compulsory to have support of any application server or web server like weblogic or Tomcat . But the
same logic can be executed in Spring without help of any web server or application server.
Because Spring provides its own containers in the form of pre defined classes.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions