tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: HelloWorld servlet, or just about
Date Mon, 29 Dec 2008 20:34:17 GMT
Hash: SHA1


André Warnier wrote:
> From a front-end Apache, I am issuing a request to Tomcat, with the only
> purpose of getting back a small string (a user-id).
> I would imagine that for Tomcat generating a whole response (headers +
> body) is heavier than generating just a set of headers.

A filter is not much lighter than a servlet, depending on what you have
it actually do: there's no performance gain from using a filter instead
of a servlet.

Tomcat's connectors are (almost) all HTTP connectors, so you're going to
get a set of headers and a (possibly empty) body anyway. I find that
it's more architecturally pretty to use filters for pre- and
post-processing or requests and servlets for "real" work. Note that the
Struts2 developers disagree ;)

> So can I, from the filter as before, generate a response consisting
> *only* of headers, among which one "propietary" one that would contain
> the string I want.
> I would basically need only a response with
> HTTP status line
> MyHeader: johnsmith
> (and no body)

You can do this with a servlet, too. Just don't ever call
response.getWriter or response.getOutputStream.

> At the limit, it could even be just the status line, with my return
> string in the message part.

Yeah, but this might be a bit confusing as an HTTP response. I'd stick
with either a header (which makes it a bit easier to identify a null
string) or a single line of the response body.

If you don't need HTTP, why not use a separate protocol? Obviously, SOAP
is way heavier, but you could create something super simple. Then again,
integrating it with Tomcat's session management, etc. would be a giant
headache. On second thought, you should stuck to Tomcat's built-in HTTP

- -chris

Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message