Arun Thomas wrote:

> There were some problems with the local mail server this weekend, and I
> didn't see this
> post I sent last Friday, so I'm reposting.  Any suggestions are still
> welcome.... :)
>
> Hello all,
>
> I'm asking hoping that someone will have a suggestion....
> Following some of the architecture guidelines I've seen here and elsewhere,
> I've set up a system with a controller servlet forwarding for presentation
> to
> a JSP.  I have several forms in the JSP which I would like to submit back to
> the URL of the original servlet.  As per the HTML 4 specs, the ACTION
> parameter
> of the form tag is now a required element.  In order to provide this
> element,
> I would like to avoid hardcoding a particular URI, as this will force
> deployers
> to have very specific mappings of servlets to aliases.  If I create the
> entire presentation in a servlet, I can user request.getRequestURI() to
> generate the
> appropriate path.  Once I forward to the JSP, however, using the same method
> provides the URI of the jsp, as used in obtaining a request dispatcher.
>
> Is there any way to obtain the original RequestURI?
>

Although the servlet API doesn't help you with this, how about having your servlet
add a request attribute containing its own request URI, before it forwards to the
JSP page?  That way, from the JSP page perspective, you just use a request-scoped
bean to retrieve the URL it should use when generating ACTION attributes.

In practice, I haven't really had any difficulties with hard coding, because what I
actually do is use a relative URL (instead of an absolute one) for the ACTION
attribute.  The relative path to my servlet is hard coded (I normally use
extension-mapping, but you could also hard code to a fixed name with a
<servlet-mapping> element), but I can change the context path of my app, or even
move to a different host, without affecting the URL that I generate.

>
> -AMT
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to