struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anuj Agrawal <agrawala...@yahoo.com>
Subject RE: query parameters
Date Mon, 09 Dec 2002 16:07:24 GMT
Laird -

Yeap!  Thanks for your patience in helping me.  I understand your (pure)
JSP+Servlet example.  However, even in that example, when the
requestDispatcher.forward(...) is executed, doesn't the browser display the
URL that the requestDispatcher forwarded to (which would be the JSP page)?
So when the user views the page, they don't know that they had used
http://your.host/yourServletContext/yourServlet/showRecord?recordid=5 to
access this page, all they see is the *final* URL which is the JSP page that
the servlet (showRecord) forwarded to.

For example, in any forums, you can view a particular message using
http://your.host/viewthread.jsp?messageid=123124 - does this mean that that
forums application is *not* using MVC? and is using only JSP (with all logic
embedded)?

Thanks.
Anuj.

> -----Original Message-----
> From: Nelson, Laird [mailto:Laird.Nelson@FMR.COM]
> Sent: Monday, December 09, 2002 10:46 AM
> To: 'Struts Users Mailing List'
> Subject: RE: query parameters
>
>
> > -----Original Message-----
> > From: Anuj Agrawal [mailto:agrawalanuj@yahoo.com]
> >
> > Thanks for the response Laird.  That's exactly the way i
> > understood it so
> > your response helped validate my understanding (and yes,
> > that's precisely
> > why i'm trying to use Struts - to separate business logic
> > from presentation
> > logic).  However, after (2) takes place, i would have arrived
> > at the JSP
> > page displaying the particular database record.  So how can a user
> > "bookmark" the page to come back directly to this particular
> > record?  I
> > guess if the URL had the servlet (+ query parameters), the user could
> > bookmark that.  But since there is a forward involved,
> > wouldn't the URL
> > (with the servlet+query parameters) be lost?
> >
> > What am i missing here? :(
>
> Well, forget Struts for the moment.  Let's just work with JSPs
> and servlets
> for a moment.
>
> I'd imagine that you'd probably want a URL scheme as you suggest, i.e.
> something like
> http://your.host/yourServletContext/yourServlet/showRecord?recordid=5.
>
> Then you'd have a servlet set up in your web application (rooted at the
> "yourServletContext" servlet context path) to receive URLs ending, let's
> say, in "/yourServlet/*".  When that servlet received any
> request, it would
> then do something like this:
>
>   final String parameterValue = request.getParameter("recordid");
>   if (parameterValue != null) {
>
>     // ...try to parse it as an integer...
>
>     // ...load up the database content based off of the record id...
>
>     request.setAttribute("dbContent", databaseContent);
>
>     // ...get a RequestDispatcher...
>
>     // Forward to the appropriate JSP page.
>     requestDispatcher.forward(...);
>   }
>
> Your JSP would then reach into its request, either in a scriptlet
> or via the
> standard bean mechanisms, and would show the record data using expression
> tags.
>
> Once you get it working (or at least once you go through the thought
> exercise of how this would work) without Struts components, then
> it's easier
> to see how Struts fits into the big picture.


--
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