aspose file tools*
The moose likes JSP and the fly likes JSP action help(Basic question) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP action help(Basic question)" Watch "JSP action help(Basic question)" New topic
Author

JSP action help(Basic question)

Rashmi Reddy
Greenhorn

Joined: Oct 16, 2003
Posts: 19
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

Joined: Jul 21, 2003
Posts: 108
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

Joined: Oct 16, 2003
Posts: 19
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

Joined: Aug 05, 2002
Posts: 61
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.


Boney
SCJP, SCWCD
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
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

Joined: Oct 16, 2003
Posts: 19
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP action help(Basic question)