| From | Sent On | Attachments |
|---|---|---|
| Erik Horstkotte | Dec 6, 2000 11:47 am | |
| Colin Sampaleanu | Dec 6, 2000 2:21 pm | |
| Michael Westbay | Dec 6, 2000 3:24 pm | |
| Michael Westbay | Dec 6, 2000 6:38 pm | |
| Craig R. McClanahan | Dec 7, 2000 11:36 am | |
| Craig R. McClanahan | Dec 7, 2000 11:36 am | |
| Erik Horstkotte | Dec 7, 2000 11:41 am | |
| Michael Westbay | Dec 7, 2000 3:54 pm | |
| Erik Horstkotte | Dec 7, 2000 6:15 pm |
| Subject: | Re: Rewriting the URL in a form:form action | |
|---|---|---|
| From: | Craig R. McClanahan (Crai...@eng.sun.com) | |
| Date: | Dec 7, 2000 11:36:30 am | |
| List: | org.apache.struts.user | |
Michael Westbay wrote:
Horstkotte-san wrote:
There doesn't appear to be any way to cause the URL in a <form:form> tag's "action" parameter to be rewritten using the webapp's context path. As a result, if I use an action="x", it directs the action to x in the current directory, which in my case isn't what I want. If I use an action="/x", it directs the action to the x in the web server's root directory - not the root of my webapp context, which is what I want.
Please try something like:
<form:form action="<%= request.getContextPath() %>/x">
This won't work (invalid tag attribute syntax), but the following will:
<form:form action='<%= request.getContextPath() + "/x" %>'>
Note the use of single quotes on the attribute, to avoid problems with the double quotes used by Java.
While I'm still learning the Struts' tag libraries, I believe that this is the way to do it. I belive that scriplets parse before taglibs, so the result of <%= request.getContextPath() %> will be put into the action attribute before the form:form is parsed. (Please, somebody correct me if I'm wrong on that point.)
I generally use this for things like:
<img src="<%= request.getContextPath() %>/images/logo.gif">
This works because <img> is not a JSP tag, but you might want to recast it in the form that computes the entire expression, so that you can train your fingers to type expressions like this one way in all circumstances.
Hope this helps.
-- Michael Westbay Work: Beacon-IT http://www.beacon-it.co.jp/ Home: http://www.seaple.icc.ne.jp/~westbay Commentary: http://www.japanesebaseball.com/
Craig McClanahan





