Thanks for your input. My comments below. > -----Original Message----- > From: Craig R. McClanahan [mailto:craigmcc@;apache.org] > Sent: Monday, October 28, 2002 2:23 PM > To: Struts Developers List > Subject: RE: [SURVEY] HREF attribute for FormTag > > > > > On Mon, 28 Oct 2002, Taylor, Jason wrote: > > > Date: Mon, 28 Oct 2002 13:54:29 -0800 > > From: "Taylor, Jason" <[EMAIL PROTECTED]> > > Reply-To: Struts Developers List <[EMAIL PROTECTED]> > > To: 'Struts Developers List' <[EMAIL PROTECTED]> > > Subject: RE: [SURVEY] HREF attribute for FormTag > > > > I thought I addressed the form bean instance issue in my > response to Craig's > > post. The 'action' attribute would still work for finding > the form bean > > since getActionMappingName would return the same thing it > always has. What > > I'm talking about would *absolutely* support the form-bean > identification > > behavior of the existing FormTag. > > > > Early in the development of Struts, it became clear that relative URLs > often failed to work the way people thought they would when a > RequestDisaptcher.forward() is used (as Struts typically does > to forward > control to the view). In particular, developers expected them to be > resolved against the URL of the JSP page (or whatever) itself > -- instead, > the browser would resolve them against the originally > submitted-to URL.
This submitted-to-URL relativity is precisely the behavior I'm trying to get! Why should I have to stop using FormTag or be forced to hack it to do this? It seems I'm paying for others' erroneous 'expectations'. > > > Moreover, I believe the current prepending behavior is not > a best practice > > for JSPs, and I don't think I'm the only one who would see > it this way. As > > an article cited on the JSTL specification home page > > > (http://www.onjava.com/pub/a/onjava/2002/08/14/jstl1.html?page > =3) by Hans > > Bergsten states while describing the <c:url> tag: > > "relative URLs in HTML elements must either be relative > to the page > > that contains them or to the root directory of the server > (if they start > > with a slash). The first part of a URL path for a JSP page > is called the > > context path, and it may vary from installation to > installation. You should > > therefore avoid hard-coding the context path in the JSP pages." > > > > The action attribute of an <html:form> tag is not a URL -- it > is a lookup > key into a table of valid actions. Therefore, this rationale is not > relevant. What I'm talking about here is the URL referred to in the HTML form tag as the 'action', not necessarily the 'action' attribute of the FormTag. My point is that FormTag should allow for the creation of action URLs that do not begin with a slash. How this is achieved is not as important to me as being able to do it if I need to. If a 'prependContext' attribute that defaults to true is better than an 'href', that's fine. > > In turn, Struts promises to compute a valid URL for you, no > matter what > the context path is, no matter which sub-app module prefix > you are in (if > any), and no matter what kind of controller servlet mapping > you are using. > Relative paths would be very brittle on at least the latter > two issues. The actionMappingURL is obtained by prepending request.getContext() and config.getPrefix() to the 'action' attribute. The 'action' attribute is also used by getActionMappingName(), which in turn is used by lookup() to identify the right form bean. In my experience, "/login" and "login.do" both work fine at identifying form beans, and "login.do" is correctly resolved by the browser to the right module without specifying the context and module name when I use a regular HTML form tag. Since the browser could just as easily get you back to the same point whether you specify 'ACTION="login.do"' or 'ACTION="/myApp/module/login.do' in your HTML form tag, I don't see why we need request.getContext() and config.getPrefix(). From my perspective, the current behavior is quite 'brittle' because it makes assumptions about where the application lives rather than letting the browser find the right spot automatically. I don't think the existing behavior has to change-- I just want to be able to 'opt out'. > > It seems unlikely that any change to the interpretation of > the "action" > attribute itself can be made that won't break backwards > compatibility for > some existing Struts apps (and therefore earn my immediate -1). > That's fair. Is there any problem with a boolean that can be used to get around the prepended context? I've been able to use the rest of the framework without customizing any of the tags or the controller-- it would be nice to keep it that way. > > > > -JT > > > > Craig -JT