You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jose Correia <jo...@exinet.co.za> on 2001/09/06 16:22:04 UTC

newbie question - confused

Hi all

I'm a bit confused with the Struts example (the one that comes with
struts1.0.jar). I'm trying to determine at which point does the .do come
in to being.

Facts first:
1. index.jsp shows:

<html:link page="/logon.jsp"><bean:message
key="index.logon"/></html:link></li>

i.e calls the file logon.jsp

2. logon.jsp defines an action form:
<html:form action="/logon" focus="username">

3. struts-config.xml defines an action mapping:
<action    path="/logon"
               type="org.apache.struts.webapp.example.LogonAction"
               name="logonForm"
              scope="request"
              input="/logon.jsp">
</action>

Now the tour guide under the heading LogonAction.java says:
"The initial JSP submits its form to logon.do. If you check the servlet
mappings in the example's web.xml you will see that requests for *.do
files are directed to the Struts "action" servlet (an instance of
ActionServlet). In the example, the ActionServlet refers to
struts-config.xml for its own mappings  (among other things), which is
where we find the reference to logon.do:"

To my knowledge the initial jsp (logon.jsp right?) is submitting a form
to the action servlet which matches the action value in <html:form
action="/logon" ...> to the action mapping path <action    path="/logon"
...> correct? i.e. /logon matches /logon.

I am aware that web.xml defines a servlet-mapping for *.do but thats
only if the user or the system makes a request for a .do file right? Now
in the above case a request is being sent first to logon.jsp from
index.jsp. Then the action form in logon.jsp if there are errors it
calls: return (new ActionForward(mapping.getInput()));  where the input
is /logon.jsp as defined above in the action mapping. Otherwise it
forwards it to mainmenu.jsp.

Now where does the .do come in? Is it internal to struts?

Thanks in advance
Jose Correia



Now following the struts example guide tour

--

                \=/,         _-===-_-===-_-===-_-===-_-==-_
                |  @___oo  (                               )_
      /\  /\   / (___,,,}_--=                                )
     ) /^\) ^\/ _)        =_"Positive thinking - a great way  )
     )   /^\/   _)         (_        to face life"             )
     )   _ /  / _)          (        Jose Correia            )
 /\  )/\/ ||  | )_)          (_    jose@exinet.co.za        )
<  >      |(,,) )__)           (   jcorreia@global.co.za    )
 ||      /    \)___)\           (_                        _)
 | \____(      )___) )___          -==-_______-=====-___==
  \______(_______;;; __;;;



Re: newbie question - confused

Posted by Erik Hatcher <er...@earthlink.net>.
Look at the generated HTML of logon.jsp.... you'll see that it submits to
logon.do.  <html:form> looks up the action mapping to determine which form
bean to use and generates the <form> tag with the appropriate action .do
extension automatically.

    Erik


----- Original Message -----
From: "Jose Correia" <jo...@exinet.co.za>
To: <st...@jakarta.apache.org>
Sent: Thursday, September 06, 2001 7:22 AM
Subject: newbie question - confused


> Hi all
>
> I'm a bit confused with the Struts example (the one that comes with
> struts1.0.jar). I'm trying to determine at which point does the .do come
> in to being.
>
> Facts first:
> 1. index.jsp shows:
>
> <html:link page="/logon.jsp"><bean:message
> key="index.logon"/></html:link></li>
>
> i.e calls the file logon.jsp
>
> 2. logon.jsp defines an action form:
> <html:form action="/logon" focus="username">
>
> 3. struts-config.xml defines an action mapping:
> <action    path="/logon"
>                type="org.apache.struts.webapp.example.LogonAction"
>                name="logonForm"
>               scope="request"
>               input="/logon.jsp">
> </action>
>
> Now the tour guide under the heading LogonAction.java says:
> "The initial JSP submits its form to logon.do. If you check the servlet
> mappings in the example's web.xml you will see that requests for *.do
> files are directed to the Struts "action" servlet (an instance of
> ActionServlet). In the example, the ActionServlet refers to
> struts-config.xml for its own mappings  (among other things), which is
> where we find the reference to logon.do:"
>
> To my knowledge the initial jsp (logon.jsp right?) is submitting a form
> to the action servlet which matches the action value in <html:form
> action="/logon" ...> to the action mapping path <action    path="/logon"
> ...> correct? i.e. /logon matches /logon.
>
> I am aware that web.xml defines a servlet-mapping for *.do but thats
> only if the user or the system makes a request for a .do file right? Now
> in the above case a request is being sent first to logon.jsp from
> index.jsp. Then the action form in logon.jsp if there are errors it
> calls: return (new ActionForward(mapping.getInput()));  where the input
> is /logon.jsp as defined above in the action mapping. Otherwise it
> forwards it to mainmenu.jsp.
>
> Now where does the .do come in? Is it internal to struts?
>
> Thanks in advance
> Jose Correia
>
>
>
> Now following the struts example guide tour
>
> --
>
>                 \=/,         _-===-_-===-_-===-_-===-_-==-_
>                 |  @___oo  (                               )_
>       /\  /\   / (___,,,}_--=                                )
>      ) /^\) ^\/ _)        =_"Positive thinking - a great way  )
>      )   /^\/   _)         (_        to face life"             )
>      )   _ /  / _)          (        Jose Correia            )
>  /\  )/\/ ||  | )_)          (_    jose@exinet.co.za        )
> <  >      |(,,) )__)           (   jcorreia@global.co.za    )
>  ||      /    \)___)\           (_                        _)
>  | \____(      )___) )___          -==-_______-=====-___==
>   \______(_______;;; __;;;
>
>