I have an web application that displays the results of a database query.
I think the way to set it up is to have a JSP that utilizes a servlet to
do the query, then displays the results using custom tags. Does this
sound right?
Thanks,
Amy
> I have an web application that displays the results of a database query.
> I think the way to set it up is to have a JSP that utilizes a servlet to
> do the query, then displays the results using custom tags. Does this
> sound right?
It sounds as if you are thinking of invocation of the servlet as similar
to a method call. This is not correct. Also, how or whether you use
custom tags is a function of the tag libraries you have or are prepared
to write.
There are two different, fairly common paradigms that sound like they
might be applicable:
1) A servlet performs the database lookup and displays the results via a
JSP (with or without presentation-oriented custom tags). The servlet,
not the JSP, is the principal actor here, and JSP is best invoked by
forwarding the request to it (as opposed to via an HTTP redirect).
2) A JSP uses data retrieval custom tags to perform the database lookup,
and presents the results either directly or with the aid of
presentation-oriented custom tags. The JSP is the principal actor here,
and there is no pure servlet involved.
Those are mutually exclusive alternatives, either one of which might
suit you (but not both together). They are by no means the only
alternatives, but in my opinion they are the best options for most
situations.
John Bollinger
jobollin@indiana.edu
Amy Johnson - 11 May 2004 00:23 GMT
I had sort of figured that out after I posted the question. So good. I'm
on the right track. Are there any differences in terms of why one would
use one option over the other? It seems that it's just a matter of
personal preference. Is that the case?
thanks very much -
Amy
>> I have an web application that displays the results of a database
>> query. I think the way to set it up is to have a JSP that utilizes a
[quoted text clipped - 26 lines]
> John Bollinger
> jobollin@indiana.edu
John C. Bollinger - 11 May 2004 14:35 GMT
> I had sort of figured that out after I posted the question. So good. I'm
> on the right track. Are there any differences in terms of why one would
> use one option over the other? It seems that it's just a matter of
> personal preference. Is that the case?
There is some degree of personal preferrence involved. On the other
hand, the servlet solution is often preferrable when there are data
processing requirements above and beyond simple data retrieval. You'll
get more out of custom tags if they're reusable in multiple JSPs -- if
you are planning them to support just one, in just one project, then you
would probably end up doing a lot more work than is really necessary.
Either way can be made to work; after all, JSP is just a convenient way
to write a presentation-heavy servlet.
John Bollinger
jobollin@indiana.edu
>>> I have an web application that displays the results of a database
>>> query. I think the way to set it up is to have a JSP that utilizes a
[quoted text clipped - 27 lines]
>> John Bollinger
>> jobollin@indiana.edu
Amy Johnson - 11 May 2004 16:40 GMT
Well, that's what I have - a presentation heavy servlet. Thanks for the
info.
Amy
>> I had sort of figured that out after I posted the question. So good.
>> I'm on the right track. Are there any differences in terms of why one
[quoted text clipped - 44 lines]
>>> John Bollinger
>>> jobollin@indiana.edu