On Mon, 6 Aug 2001, Rodney Smith wrote:

> Hallo,
> 
> Firstly I would like to thank Ted Husted for all his help with me
> getting a better understanding of Struts, as I am a new to this area a
> lot of the information that I have found is great but not detailed
> enough to understand some of the process as what Ted has mentioned is
> perfect, thanks again Ted.
> 
> OK the questions are still coming as follows.
> I am using Tomcate3.2.2 and runing of a localhost:
> In the example I am using

I am assuming you are talking about the "struts-example.war" example that
is shipped with Struts, right?

> I have the index.jsp page and in that I have two html links, one goes
> to get registered with the web application and the other is logon to
> the web application. If I click on logon this takes me to the
> logon.jsp page. When I client clicks on this as this is a .jsp this
> does not go to the actionservlet as that is not a .do action 'is that
> correct'? instead that just calls the viewer of logon.jsp??? or does
> this go direct to the JAVABEAN by passing the ActionServlet to get the
> logonform.java???
> 

You can see when you run the app that the "log on" link does indeed link
directly to logon.jsp.  It works in this case because there is no setup
necessary to prepopulate the LogonForm bean.  When the <html:form> tag in
"logon.jsp" is executed, it will see that the form bean does not exist,
and will create one automatically with default values.

In general, I do recommend going through an action for things like this --
you'll see this technique used later.

> Now if the client clicks on the registation URL link on the index.jsp
> it comes back with a editregistration.do on the browser bar, in this
> case, as this is displaying the .do,

Actually, it is *not* displaying the ".do".  Here's what really happens:

* The form submit is dispatched to the LogonAction action.

* Based on whether or not you typed the correct username and password,
  LogonAction selects whether to send you forwards to the main menu,
  or backwards to the logon page again (with an error message).

* This choice is made by selecting which ActionForward instance is
  returned from the perform() method.

* Struts uses the path inside that ActionForward to execute a
  RequestDispatcher.forward() call to the selected page.

* The forward() all happens on the server side, so the browser's location
  bar is not updated.

The bottom line is this - there is almost no relationship between what
shows in the location bar and what page really created the response.


> does that mean that actually has
> been to the ActionServlet to JAVABEAN and comes back with the
> registration form display or does this just go to the viewer and
> retreives the registration.jsp form, with out going to the
> ActionServlet?? I understand that if the person sends a request 'A' to
> logon to the web application it needs to be a .do and needs to go to
> the ActionServlet 'B' I think that it goes the same with the
> registration as well. It is when they are asking for the forms to
> submit is where I don't know where they are stored or if they need to
> be retreived from the JSP viewer etc.
> 
> Thanks for your time and I hope that can get another good response.
> Many thanks Ted and have a great day.
> 

See above for the details, but you should totally ignore the location bar
when running any web app that uses RequestDispatcher.forward(), not just a
Struts based app.  The location bar only tells you where you *submitted
to*, not where the response came from.

> Kind Regards
> Rodney Smith
> 
> -- 
> Sent through GMX FreeMail - http://www.gmx.net
> 
> 
Craig


Reply via email to