This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JSP page with buttons 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 "JSP page with buttons" Watch "JSP page with buttons" New topic

JSP page with buttons

JC Bismark

Joined: Jun 27, 2008
Posts: 29
I want to design a Member.jsp page showing the writing "Fan Club" and two buttons "Add New" and "Delete".Each button will invoke different jsp pages:
"Add New" invoke JSPMemberDetails.jsp
"Delete" invoke JSPMemberList.jsp

I understand that in case of one button "Add New" in the page the action attribute will refer to the JSPMemberDetails.jsp destination.

How we create it in case of two buttons? do I put the two input tags (for buttons)in the same form, in that case there are both refer to the same page JSPMemberDetails.jsp .Please,advise...

Using Eclipse IDE,my jsp page with one button:
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60737

In the submit handler for the form, check which button invoked the handler and set the form's action accordingly.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
JC Bismark

Joined: Jun 27, 2008
Posts: 29
Hello Bear,

Can you be more specific about the handler?

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Originally posted by JC Bismark:
Hello Bear,

Can you be more specific about the handler?


This talks about the handler Bear was speaking of. You'll need to use the technique as Bear suggested and determine which button triggered it.

You can also use the buttons onclick handler to help with this. Something like this.

GenRocket - Experts at Building Test Data
JC Bismark

Joined: Jun 27, 2008
Posts: 29
Hi Gregg,

I'm not familiar with javascript, so by using the onClick event handler
<FORM onSubmit="alert(button + pressed")">

-How we use it within the form?I tried to write it like this but it within the form but it don't let me: input type="submit" onClik = "button=this.value" VALUE="Add New"
this other one is the same with VALUE="Delete"
- How we deal with the ACTION attribute? knowing that the 2 buttons go to two different jsp pages destination?
jQuery in Action, 2nd edition
subject: JSP page with buttons
Similar Threads
Question on BUTTON name/value pairs sent from JSP
Simple examples of JSP
problem inserting data into MS Access
Request Attribute confusion
Building JSP pages and link to MySQL table