You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yuan Jun <jo...@sunjapan.com.cn> on 2001/03/20 07:45:24 UTC

strange html:form tag

i download jakarta-struts-1.0-b1 today and found next in registration.jsp

<html:form action="/saveRegistration">
<html:hidden property="action"/>
<table border="0" width="100%">

should it be:
<html:form action="/saveRegistration.do">
or i've missed something?

John.


RE: strange html:form tag

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Troy Hart wrote:

> OK, so let me see if I understand what you are saying:
> 
> the tag <html:form action="/someAction"> will trigger FormTag.doStartTag(),
> which will append ".do" if no extension was specified. I guess it looks
> first to see if if extension mapping is being used vs. path (???) mapping?
> 

At startup time, the Struts controller servlet reads the web.xml file and
finds out what <servlet-mapping> entry you have selected.  If you use
extension mapping, <html:form> will append the appropriate suffix
(for example, "/saveCustomer.do")  On the other hand, if you used:

	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>/process/*</url-pattern>
	</servlet-mapping>

The submitted URL will be something like "/process/saveCustomer" instead.

> Maybe I should go review the tag's java source... :)
> 

That's always useful :-).

> Thanks,
> 
> Troy
> 

Craig


RE: strange html:form tag

Posted by Troy Hart <th...@part.net>.
OK, so let me see if I understand what you are saying:

the tag <html:form action="/someAction"> will trigger FormTag.doStartTag(),
which will append ".do" if no extension was specified. I guess it looks
first to see if if extension mapping is being used vs. path (???) mapping?

Maybe I should go review the tag's java source... :)

Thanks,

Troy

-----Original Message-----
From: Rob Leland [mailto:Robert@freetocreate.org]
Sent: Tuesday, March 20, 2001 9:36 AM
To: struts-user@jakarta.apache.org
Subject: Re: strange html:form tag


Then struts html:form tag is processed
if the action name does not have
a .do at the end, one will be appended so when
it is sent out to the browser it will
always see a 'XXX.do' present.

Troy Hart wrote:
>
> What does that mean? How do you set up your servlet mapping in web.xml
then?
>
> -----Original Message-----
> From: Rob Leland [mailto:Robert@freetocreate.org]
> Sent: Tuesday, March 20, 2001 6:39 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: strange html:form tag
>
> Yuan Jun wrote:
> >
> > i download jakarta-struts-1.0-b1 today and found next in
registration.jsp
> >
> > <html:form action="/saveRegistration">
> > <html:hidden property="action"/>
> > <table border="0" width="100%">
> >
> > should it be:
> > <html:form action="/saveRegistration.do">
>
> Either would be correct.
>
> The '.do' has been optional since the last week
> in January, maybe before.
>
> > or i've missed something?
> >
> > John.
>
> -Rob


Re: strange html:form tag

Posted by Rob Leland <Ro...@freetocreate.org>.
Then struts html:form tag is processed
if the action name does not have
a .do at the end, one will be appended so when
it is sent out to the browser it will
always see a 'XXX.do' present.

Troy Hart wrote:
> 
> What does that mean? How do you set up your servlet mapping in web.xml then?
> 
> -----Original Message-----
> From: Rob Leland [mailto:Robert@freetocreate.org]
> Sent: Tuesday, March 20, 2001 6:39 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: strange html:form tag
> 
> Yuan Jun wrote:
> >
> > i download jakarta-struts-1.0-b1 today and found next in registration.jsp
> >
> > <html:form action="/saveRegistration">
> > <html:hidden property="action"/>
> > <table border="0" width="100%">
> >
> > should it be:
> > <html:form action="/saveRegistration.do">
> 
> Either would be correct.
> 
> The '.do' has been optional since the last week
> in January, maybe before.
> 
> > or i've missed something?
> >
> > John.
> 
> -Rob

RE: strange html:form tag

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Troy Hart wrote:

> What does that mean? How do you set up your servlet mapping in web.xml then?
> 

You still need to set up your <servlet-mapping> in web.xml, the same as
you did before.

THe difference is that the Struts controller servlet reads the web.xml
file itself at startup time, and remembers which mapping you have
selected.  If you do the usual extension mapping ("*.do"), it will
generate a hyperlink to "/saveRegistration.do").  Likewise, if you use
path mapping instead (say, "/execute/*"), the same <html:form> tag would
generate a hyperlink to "/execute/saveRegistration".

Craig


> -----Original Message-----
> From: Rob Leland [mailto:Robert@freetocreate.org]
> Sent: Tuesday, March 20, 2001 6:39 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: strange html:form tag
> 
> 
> 
> 
> Yuan Jun wrote:
> > 
> > i download jakarta-struts-1.0-b1 today and found next in registration.jsp
> > 
> > <html:form action="/saveRegistration">
> > <html:hidden property="action"/>
> > <table border="0" width="100%">
> > 
> > should it be:
> > <html:form action="/saveRegistration.do">
> 
> Either would be correct.
> 
> The '.do' has been optional since the last week
> in January, maybe before.
> 
> > or i've missed something?
> > 
> > John.
> 
> -Rob
> 


RE: strange html:form tag

Posted by Troy Hart <th...@part.net>.
What does that mean? How do you set up your servlet mapping in web.xml then?

-----Original Message-----
From: Rob Leland [mailto:Robert@freetocreate.org]
Sent: Tuesday, March 20, 2001 6:39 AM
To: struts-user@jakarta.apache.org
Subject: Re: strange html:form tag




Yuan Jun wrote:
> 
> i download jakarta-struts-1.0-b1 today and found next in registration.jsp
> 
> <html:form action="/saveRegistration">
> <html:hidden property="action"/>
> <table border="0" width="100%">
> 
> should it be:
> <html:form action="/saveRegistration.do">

Either would be correct.

The '.do' has been optional since the last week
in January, maybe before.

> or i've missed something?
> 
> John.

-Rob

Re: strange html:form tag

Posted by Rob Leland <Ro...@freetocreate.org>.

Yuan Jun wrote:
> 
> i download jakarta-struts-1.0-b1 today and found next in registration.jsp
> 
> <html:form action="/saveRegistration">
> <html:hidden property="action"/>
> <table border="0" width="100%">
> 
> should it be:
> <html:form action="/saveRegistration.do">

Either would be correct.

The '.do' has been optional since the last week
in January, maybe before.

> or i've missed something?
> 
> John.

-Rob

RE: strange html:form tag

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 21 Mar 2001, Yuan Jun wrote:

> 
> 
> > On Tue, 20 Mar 2001, Yuan Jun wrote:
> >
> > > i download jakarta-struts-1.0-b1 today and found next in
> > registration.jsp
> > >
> > > <html:form action="/saveRegistration">
> > > <html:hidden property="action"/>
> > > <table border="0" width="100%">
> > >
> > > should it be:
> > > <html:form action="/saveRegistration.do">
> > > or i've missed something?
> > >
> >
> > Although the latter still works, the <html:form> tag has been made smart
> > enough to figure out how an action path is mapped to the controller
> > servlet.  The former will work even if you change from path mapping to
> > extension mapping (or vice versa), for example.
> >
> 
> i see. but when i depoyed struts-example to orion 1.4.5, it did work. i have
> to modify jsp files adding .do to html:form to make it work, is it a bug of
> orion?
> 

It might be.

In order for this to work, Struts has to be able to parse the web
application deployment descriptor (/WEB-INF/web.xml).  To do this, Struts
calls:

	InputStream is =
	  getServletContext().getResourceAsStream("/WEB-INF/web.xml");

At various times Orion has returned null from this call, because the
developers incorrectly believed that a servlet should not be able to
access resources in the /WEB-INF directory.  This has gone back and forth
in various Orion versions.

Are there any interesting log messages during the startup of the
controller servlet?

> John

Craig



RE: strange html:form tag

Posted by Yuan Jun <jo...@sunjapan.com.cn>.

> On Tue, 20 Mar 2001, Yuan Jun wrote:
>
> > i download jakarta-struts-1.0-b1 today and found next in
> registration.jsp
> >
> > <html:form action="/saveRegistration">
> > <html:hidden property="action"/>
> > <table border="0" width="100%">
> >
> > should it be:
> > <html:form action="/saveRegistration.do">
> > or i've missed something?
> >
>
> Although the latter still works, the <html:form> tag has been made smart
> enough to figure out how an action path is mapped to the controller
> servlet.  The former will work even if you change from path mapping to
> extension mapping (or vice versa), for example.
>

i see. but when i depoyed struts-example to orion 1.4.5, it did work. i have
to modify jsp files adding .do to html:form to make it work, is it a bug of
orion?

> > John.
> >
> >
>
> Craig
>
>
John


Re: strange html:form tag

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Yuan Jun wrote:

> i download jakarta-struts-1.0-b1 today and found next in registration.jsp
> 
> <html:form action="/saveRegistration">
> <html:hidden property="action"/>
> <table border="0" width="100%">
> 
> should it be:
> <html:form action="/saveRegistration.do">
> or i've missed something?
> 

Although the latter still works, the <html:form> tag has been made smart
enough to figure out how an action path is mapped to the controller
servlet.  The former will work even if you change from path mapping to
extension mapping (or vice versa), for example.

> John.
> 
> 

Craig