I have 2 submit buttons in a jsp page. in the form action, i forward the request to a servlet. N in the servlet, i need to write logic for the respective button clicked in the previous jsp and redirect to a new jsp... Kindly help me with this... I am new to jsp n servlets......

Recommended Answers

All 4 Replies

try using the RequestDispatcher object

you could use javascript for it...

u can have a hidden field who's value changes on the button click..
and then you pass this value to the next page and depending upon the value passed
write your logic..

this should be your html

<input type='hidden' id='thisone' name='thisone' value='0'>

this should be the javascript function

function cvalue()
  {
   document.getElementById('thisone').value="1";
 }

and this is what the buttons should be like

<input type='submit' value='submit1' >
<input type='submit' value='submit2' onClick='cvalue()'>

and on the second page you use the value of the field thisone
if its 0 means submit1 was clicked and if its 1 submit2 was clicked..


hope it helps...

I have 2 submit buttons in a jsp page. in the form action, i forward the request to a servlet. N in the servlet, i need to write logic for the respective button clicked in the previous jsp and redirect to a new jsp... Kindly help me with this... I am new to jsp n servlets......

If you took care in searching before posting you would found this recent thread

thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.