tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robbert <>
Subject Re: CSS not being used when a Servlet is involved
Date Thu, 16 Nov 2006 01:12:46 GMT

Apologies for the late reply. I've had some more pressing to attend to.

Christopher Schultz-2 wrote:
> Robbert,
>> Christopher Schultz-2 wrote:
>>> You have your process turned upside down, here.
>> Why is the process turned upside down, exactly? Or rather, is there any
>> benefit in mapping /index to a Servlet and then forwarding to a JSP
>> instead
>> of going to JSP pages which invoke my Servlet?
>> This probably boils down to the following question: When do you use a JSP
>> and when do you use a Servlet?
> Well, that's a somewhat philosophical and often religious argument. I
> think that one ought to use JSPs for quick-and-dirty hacked logic, /or/
> for display purposes only. Your "real work" ought to be done in
> servlets. I find the error handling more straightforward and less messy
> than in JSPs (although a JSP does get translated into a servlet before
> execution, so really they are exactly the same thing).

I have to agree totally with that. It's the more logical thing to do.

Christopher Schultz-2 wrote:
> At any rate, what you are trying to do is:
> 1) Perform some logic in your servlet.
> 2) Emit some output to the client.
> Since you want to do those 2 things, in that order, why invoke #2 first,
> which calls-back to #1, and then emits the output? It's far more natural
> to invoke the servlet and then have it forward to the JSP. Note that
> this is an internal forward, so the browser has no idea that control has
> been transferred from the servlet to the JSP. Of course, you could also
> use an HTTP FORWARD if that's what you really wanted to do.

True... I hadn't thought it about it like that. Still, no one knows that the
servlet is being executed because it happens while the page is being loaded.

If I do it that way (let my Servlet catch all the requests, do some logic
and forward to the JSP), then I won't have any problems with CSS or images,
right? Since the Servlet is no longer invoked via the JSP, it shouldn't be a
Because right now, I can get the CSS to work, but the images aren't being
shown for some reason or another (even though the links in the CSS file are

Christopher Schultz-2 wrote:
> > Struts sounds like a good framework. I'm not too experienced with those
> but
>> I take it that won't be hard to use. It's just how we were learned to
>> code.
>> So it never seemed to me as if the process was reversed.
> Whether or not you use struts, I highly recommend that you avoid tricks
> like calling a servlet from a JSP in order to execute your business
> logic. If you have a waterfall-style logical flow (i.e. execute servlet
> first, then JSP), it's only natural to have the flow actually do that.
> It's okay if you application isn't 100% "pull-based" ;)
> -chris

It seemed like a good way of doing things at the time, since the Servlet's
output is not needed for the page itself. :p But I am doing more things than
necessary, yeah.
View this message in context:
Sent from the Tomcat - User mailing list archive at

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message