If I understand it correctly, I don't think your modified tag works in all
cases. If, for example, you have a web-application called testApp and a
logon form at;
http://<someHost>/testApp/admin/logon.do
the ActionMapping defined in struts-config.xml must have a path attribute of
"/admin/logon" (I think) for the ActionServlet to find it (assuming you are
using extension mapping). To also find this mapping from your modified
FormTag you would need something like;
<html:form action="admin/logon.do" ...>
so in the output html it would write
<form action="logon.do" ...>
This is ok if your JSP page that contains this form is under the same branch
as the logon page e.g.
http://<someHost>/testApp/admin/changePassword.jsp
but fails if you are under a different branch such as;
http://<someHost>/testApp/cart/checkout.jsp
because it will produce the URL;
http://<someHost>/testApp/cart/logon.do
and not the one you want.
Note: I've not tested this so I may have got it completely wrong :-)
The approach I've taken is slightly different (and may also not work
properly). I do the same thing as you to look up the ActionMapping except I
only add the leading forward-slash if there isn't already one. To build html
form element, however, rather than stripping the path and making the URL
relative I prepend the context path (the name of the web-application) and
make it an absolute URL. In the above example the output html this method
produces would be;
<form action="/testApp/admin/logon.do" ...>
Which always works, I think. This basically copies the way redirecting
ActionForwards are handled in ActionServlet.
> -----Original Message-----
> From: Chris Smith [mailto:[EMAIL PROTECTED]]
> Sent: 25 January 2001 15:53
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: re: FormTag problem
>
>
> The problem is because the action in the jsp form tag is
> being used for
> two purposes - for the generated HTML and for looking up the
> ActionMapping.
>
> If you have the directory path in the form tag and modify
> FormTag.java so
> it doesn't strip it out, struts will generate the HTML page
> for you. But
> when you come to submit the form, it fails because the
> browser submits
> relative to the directory in the URL, i.e. the browser submits to
> /execute/action/execute/action/logon (I think, I'm using *.do).
>
> If you go the other way, without the directory in the form
> tag, you have
> to remove the directory from struts-config.xml. Again, the HTML is
> generated ok, but when you try submitting the form, the
> browser submits
> it relative to the directory in the url, i.e.
> execute/action/logon, which
> isn't found in struts-config.xml.
>
> My fix is to modify FormTag.java so it uses the action with a leading
> "/", all directories, but without ".do" to look up the action
> mapping,
> and uses a different version - one without the leading
> directories in the
> generated HTML.
>
> I'm using *.do mapping, but I think this should work for the /execute
> type mapping too.
>
> I've attached my modified FormTag.java and posted to struts-dev too.
>
> Chris Smith
>