struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Communication/Relation between Struts controller and HTTP server/ Servlet engine
Date Mon, 01 Jul 2002 17:21:59 GMT

On Mon, 1 Jul 2002, Heligon Sandra wrote:

> Date: Mon, 1 Jul 2002 15:12:59 +0200
> From: Heligon Sandra <>
> Reply-To: Struts Users Mailing List <>
> To: "''" <>
> Subject: Communication/Relation between Struts controller and HTTP
>     server/ Servlet engine
> 	Hi,
> 	I have to write a document about Struts implementation in my
> project.
> 	Now I understand the Struts components well but I have
> 	problems in explaining the request flow between the web browser
> 	and Struts. More precisely the relation between the HTTP Server
> 	(Apache) with the servlet extension (Tomcat) and the Struts
> application.
> 	I am not sure but I believe that the HTTP server and the Servlet
> engine
> 	communicate through TCP-IP, are they ?

If you look at the usual Struts diagram (like the one in the User's
Guide), the incoming (to Struts) arrow comes from the servlet container
(i.e. via the Servlet API).  What happens before that is up to what
container you are using and how it's configured.  For example, just with
Tomcat you have at least the following choice:

* Tomcat Standalone -- Tomcat itself implements HTTP/1.1 and can be
  used directly as the "web server" in addition to its ability to run
  servlet and JSP based applications.

* Tomcat via Web Connector -- You can use a web connector like mod_jk
  to configure Apache (or IIS) as the module that performs the HTTP
  protocol, and then uses a TCP/IP connection to forward requests to
  Tomcat for servlets and JSP pages.  The Tomcat instance can be on a
  different server, and there is primitive support for having multiple
  back-end Tomcat instances (poor man's load balancing).

* Tomcat Embedded -- In some configurations, you embed Tomcat inside the
  same process as the web server (doesn't work on Apache 1.3 on Unix,
  because there are multiple processes), and the connection between
  the web server and Tomcat is JNI calls.

Fortunately, you don't have to care about how this all works when you
write your Struts app (or any other servlet/JSP based app; it is not at
all specific to Struts).

> 	In the Struts diagrams the request arrives to the ActionServlet, but
> they are
> 	some steps between the browser and the Struts controller how the
> 	ActionServlet is instantiated for instance?

The controller is instantiated once for the entire webapp, by the servlet
container.  The details are in the Servlet Specification which you can
download at:

> 	This component is created when Apache-Tomcat starts up and
> 	is destroyed when Apache-Tomcat is closed, isn't it ?

Depends on your web.xml settings.  If you include a <load-on-startup>
configuration value, the controller servlet will be initialized when the
webapp starts up (the usual case).  Otherwise, it will be initialized on
the first request to this webapp.

> 	A lot of people only know the HTTP Server concept, it isn't easy to
> introduce
> 	the concepts of Servlet engine and Struts framework.
> 	Can someone send me a diagram or explain me the communication
> between the
> 	Struts controller components (like Actionservlet, RequestProcessor,
> ContextServletListener)
> 	and the HTTP Server - Servlet engine ?

Since this actually has nothing to do with Struts specifically, you really
want to go look at the documentation for your particular container to
understand how that part is put together.

The important thing to remember is that the overall architecture is *not*
monolithic -- you can switch between any of the Tomcat+Apache
configurations described earlier, for example, with zero changes to your
servlet/JSP based application.

> 	Tanks a lot in advance.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message