The Artima Developer Community
Sponsored Link

Java Answers Forum
How to control which button is processed in JSP.

2 replies on 1 page. Most recent reply: Sep 26, 2002 7:43 AM by Ioan Salau

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Sid

Posts: 1
Nickname: mas969
Registered: Sep, 2002

How to control which button is processed in JSP. Posted: Sep 25, 2002 8:21 AM
Reply to this message Reply
Advertisement
How to control which button is processed in JSP.

I have a html page called "formftplogoff.htm"
The form has two buttons:
[Yes] and [No]
Here is the simple form

If the Yes button is executted it goes to a JSP page "processftplogoff.jsp" and the logging of process is executed. How can I control the second operation When "no" is pressed. If no is presses than the user is taken to page called "preferences.jsp". How can I do this?

The book I am using shows forms with "submit" button so basically one buton action. Please help.



<html>
<head>
<title> FTP Log off </title>
<body>

<p>Do you wish to log off from ftp server?</p>
<FORM ACTION="processftplogoff.jsp" METHOD="get">
<input type="button" value="Yes" name="b1">
<input type="button" value="No" name="b2">
</form>
</body>
</html>




siddhartha

Posts: 15
Nickname: saddysan
Registered: Jul, 2002

Re: How to control which button is processed in JSP. Posted: Sep 25, 2002 10:46 AM
Reply to this message Reply
Use two form tags instead of one like this
Also use input type=submit
I hope this should work

<html>
<head>
<title>
FTP Log off
</title>
<body>
<p>Do you wish to log off from ftp server?</p>
<FORM ACTION="processftplogoff.jsp" METHOD="get">
<input type="submit" value="Yes" name="b1">
</FORM>

<FORM ACTION="preferences.jsp" METHOD="get">
<input type="submit" value="No" name="b2">
</form>
</body>
</html>

Ioan Salau

Posts: 2
Nickname: insight
Registered: Sep, 2002

Re: How to control which button is processed in JSP. Posted: Sep 26, 2002 7:43 AM
Reply to this message Reply
Into HTML:
......
<form action="processftplogoff.jsp" method="GET">
<input type="Submit" name="okbutton" value=" OK " >
<input type="Submit" name="cancelbutton" value=" Cancel ">
......

Into jsp:

<%

String action=request.getParameter("Submit");
...
System.out.println("You pressed "+action+" button");
if ( action.equals("okbutton") ) {
// OK button
} else if ( ation.equals("cancelbutton") ) {
// CANCEL button
}


%>

Flat View: This topic has 2 replies on 1 page
Topic: Need some help. How do I tackle this? Previous Topic   Next Topic Topic: URGENT!!! one day left.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use