File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to go to particular method in Action class when i click the submit button in Jsp?

 
Vidya Gupta
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my jsp am having 3 submit buttons, If i click one submit button it should go to the particular method in the Action class and display the data that is hard coded data in the Action class. If i click second submit button it should go to that particular method in the Action class and display the data that is hard coded data in the Action class etc. How can i go to the particular method in Action class from the jsp when i click submit button? Please give me some suggestions..

Thanks,
Vidya
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here JavaScript helps you using js identify which action has selected and call the respective action.
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To deal with the above scenario struts1 provides two classes DispatchAction and LookupDispatchAction.
Refer to the below mentioned link for details(For DispatchAction):
Click Here
If you need any further explanation reply back.

Regards,
Sandy
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not a good practice to use javascript.
As javascript can be disabled in clients web browser.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually am having a small doubt, we normally write <form action="someaction"> tag in the jsp..
That means after submitting the form it will go to the particular action which is specified in the "action" attribute.
Am i right? If so, in my newly created jsp am having 3 submit buttons. When creating each submit button ill write "onclick="some javascript function to go to particular action class".
Now on clicking each submit button it will go to particular action method that is specified in the onclick attribute..
Now my doubt is what should i write in the action attribute of form which containing 3 submit buttons?
 
Sandip Ram
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vidya,
Yes, your right and this is a not a small doubt also.
If you go through the documentation then may be you get your answer so easily.
So please once go to struts documentation and search struts predefined classes.
There are two classes that is DispatchAction and LookUpdispatchAction class which is help you to clear your doubt.

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic