struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nelson, Laird" <Laird.Nel...@FMR.COM>
Subject RE: query parameters
Date Mon, 09 Dec 2002 15:15:48 GMT
> -----Original Message-----
> From: Anuj Agrawal [mailto:agrawalanuj@yahoo.com]
> I know (i think) how to do this directly in the JSP (using JSTL's
> db-querying tags), but i thought that only the servlet should 
> access the
> database and obtain the record, so how would my JSP page 
> invoke the servlet
> to get the data from the database?  Am i over-complicating it? :(

Normally the flow in a Struts application is like this:

  browser --(1)--> Action --(2)--> JSP

(1) is where the browser's request is handled by the ActionServlet, and
where the ActionServlet figures out what Action to invoke.  The Action is
responsible for retrieving any data needed (or invoking model-layer
components to produce the data for it).  (2) is where the Action puts this
data in the request or somewhere else from which the JSP (which hasn't
entered the picture yet) can retrieve it.  I've oversimplified the
architecture above, but you should get the idea.

This is much different from the other way of doing things, which, from your
messages, it looks like you're familiar with, viz. where a single JSP page
gets data as it is needed, printing it out as it encounters it.  This way of
doing things is usually not recommended by Those in the Know because it
freely mixes business logic with view logic.

So, to answer your question literally, your JSP never invokes your servlet
to get the data from the database.  And you are correct that only the
servlet (or a Struts Action, or something called by a Struts Action) should
access the data in the database.

Hope this helps, and that I haven't inadvertently patronized you.

Cheers,
Laird

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message