Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP action help(Basic question)

 
Rashmi Reddy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need some help in JSP action call. The scenario is like this.
I have a jsp page with 2 buttons create & modify. I have to write same Action class for both buttons but with different sequence(or methods).
How do i do that?
Thanks in advance,
Rashmi
 
jyothsna kumari
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
i think u can do like this.onclick of the first button u call a function,do the needed things and then submit the form.similarly in the onclick of the second button,call the other function,do the needed things and then submit the form.in this way u can run the same class with different functions.
<script language="javascript">
function submitform1()
{
.....
form.submit();
}
function submitform2()
{
.....
form.submit();
}
</script>
thanks,
jyothsna
 
Rashmi Reddy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think my question is misleading. Let me explain it
I have a action class for the jsp called TestAction.java.
In the TestJSP.jsp i have Save & Submit as two button. Both on click of Save & Submit i'll be calling same action class. But within action based on the request parameter i have to call the different methods....
I hope this question is more clear. please help me.'
Thanks
Rashmi
 
B Mampilli
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
in the jsp file you could have a hidden field
<input type=hidden name=toDo>
when a button in clicked you could call a javascript that sets a value into this hidden field and then submit the form to the servlet.
In the servlet, you could do a
request.getParameter("toDo");
then depending on the value returned, call the appropriate function.
Hope this helps.
 
jyothsna kumari
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i got the question.
for this u can do like this.in the java class u can check which button is clicked. u can use 'request.getParameter("button")'.if button is clicked it returns the value else null.by doing this u can get which button is clicked and can call corresponding function.
or u can place the buttons in different forms and can run different classes if there functionality is total different.
have any questions pls let em know.
thanks,
jyothsna
 
Rashmi Reddy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thanks Jyothsa & Boney... there i get my answer. I guess that will work.
I would try it in my jsp & let you know
Thanks again,
Rashmi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic