wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Navigate from one JSP to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Navigate from one JSP to another" Watch "Navigate from one JSP to another" New topic
Author

Navigate from one JSP to another

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
I have a JSP which has a button.
<button type= >Click Me</button>
This is not part of any form but rather a stand-alone button. How do I move to B.jsp when I click this button in A.jsp?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

Pure HTML. Check out the anchor tag. (It might be a good idea to have a basic knowledge of HTML before delving off into JSP).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
<input type="button" name="blah" onclick="document.location.href='asdf.jsp'">
or <a href="asdf.jsp"><input type="button name="blah"></a>
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
Thanks.
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
This is what I did-
<a href="/nextpage.jsp"> <button type=submit>Order Now</button></a>
Button visible and on miving the mouse over it, shows that this will navigate to nextpage.jsp.
But on clicking it, getting a 404 error.
/nextpage.jsp is not available.
Can you help me?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

Two things:
1) Combining the a and the button tag is not a good idea. Use one or the other.
2) The href must be a valid url for the page. We can't possibly help you with your 404 with the information you have provided so far.
Mishra Anshu
Ranch Hand

Joined: Sep 16, 2003
Posts: 224
Instead of

try:--
<a href="nextpage.jsp"><input type= button>Order Now</button> </a>
href="nextpage.jsp" or href="../nextpage.jsp", depends on the relative locations of the two files stored.
Hope I understood you right :roll:


"Ignorance is bliss"
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
Thanks.
The ../nextpage.jsp worked just fine.
Vinil Mehta
Greenhorn

Joined: Aug 17, 2011
Posts: 9

[Thread hijack removed. Please start new topics for your own questions.]


Techata
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Navigate from one JSP to another
 
Similar Threads
how to call jsf button action using javascript
My Cancel button is not working in struts1.2
html:link struts
jsp onClick then forward
How do i create dynamic input fields after click a button?