GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes page forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "page forward" Watch "page forward" New topic
Author

page forward

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
How do I create a HTML button that once it's clicked it forward current page to a new JSP ?

I tried

<input type="button" value="Forwarded Page" href="http://www.yahoo.com">
<input type="button" value="Forwarded Page" onClick="http://www.yahoo.com">

<input type="button" value="Forwarded Page" href="/myapp/myAction">
<input type="button" value="Forwarded Page" onClick="/myapp/myAction">

But they don't work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61304
    
  66

You can't. Forwards happen on the server. All you can do from a client is a redirect.

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61304
    
  66

ben oliver wrote:But they don't work.

ItDoesntWorkIsUseless


Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Use a Servlet. Have your JSP page submit the request to your servlet, which then forwards to the target JSP page.
This has the added benefit of keeping your application logic on the server site and out of your JSP (view) page.
 
GeeCON Prague 2014
 
subject: page forward