Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to redirect to another page

 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two questions? How can I redirect to another page through a conditional and from a button press. I cannot figure this out, if you know how please let me know. Thanks.

Psedou code is below.

---------first -----------
<%
if(x == 1)
go to www.first.html

else
go to www.second.jsp

%>
-------second----------if this button is press I want to redirect to a different page

<input type="submit" name="Submit3" value="Delete Record" redirect to www.third.jsp >
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I redirect to another page through a conditional and from a button press.


You don't. A redirect is a server-side activity. A button press is a client-side activity. To move to another page as a result of a button press you would use the normal client-side mechanisms: submit a form, load a new page under javascript control, and so on.

if this button is press I want to redirect to a different page

<input type="submit" name="Submit3" value="Delete Record" redirect to www.third.jsp >


Again, a pure HTML/Javascript issue. Simply place the button in a form whose action specifies the page to which you want to submit.
[ September 19, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posted by Fritz in another (now closed) topic:

posted September 19, 2005 02:50 PM Profile for Fritz Largosa Email Fritz Largosa Send New Private Message Edit/Delete Post What is the command to allow me to load another page? Below is the sample code of what I want to do. Thanks.

<%
if( x = 1)
%>
go to www.one.html // I do not know this command in javascript.

<%else%>
to to www.two.jsp
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I assume from this that you have a server-side variable named x that will determine where a button will send the page to?

I'm also assuming that you in a pre-JSP 2.0 environment using scriptlets rather than the JSTL. If so, I'd code it something along the lines of:



under JSP 2.0:



[ September 19, 2005: Message edited by: Bear Bibeault ]
[ September 19, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. If the URL to be generated needed params or was internal to the web app, I'd opt for the <c:url> tag over the simple <c:set> shown above.
 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic