First, with an HTML link, you're not forwarding a request.  Instead, the
client is creating a new request when the user clicks on the link, and this
request is not the same as the request object that is used on the
server-side.  The servlet container creates a HttpServletRequest object from
the request sent by the client.

Second, the link is a client-side entity, and so it doesn't have access to
any server-side objects.

However having said that, using JavaScript you can "forward" the request
parameters used in the original page request.  Use a javascript function for
the address of the link, and in the function, strip the parameter's from the
page request and append them to the URL of the new page.   Finally, set the
target frame/window href to the new URL.

Again you're limited to whatever request parameters were in the original
page request.  You cannot access any server side object that you may have
inserted into a HttpServletRequest object.  Here's a short example.

<script>
 function gotoPageUsingOldParams(newPage)
  {
    var params = self.location.search;
    var newURL = newPage + params;
    self.location.href = newURL;
  }
</script>

<a href="javascript:gotoPageUsingOldParms('foo.jsp')">Foo</a>


David



----- Original Message -----
From: David Geary <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 29, 1999 6:01 PM
Subject: Forwarding with a Link


> Is there a way to forward a request to a JSP page with a link? If the
> HTML anchor tag is used in a JSP page to load another JSP page, the
> request does not get forwarded.
>
> Thanks,
>
>
> david
>
>
===========================================================================
> 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
>

===========================================================================
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