i have implemented a simple login application in Struts 2. In the login page, i added 2 buttons. first button is for the new user registration process and second button to login process for existing users. Now, on click of either button calls the execute method of the same action class. how could i distinguish them in the execute call? for your reference, login.jsp is attached below:
please tell me the best way of implementing the above logic in struts 2.
I guess it is not possible to have two submit but for a single form.. why can't you make "sign-up" as a hyperlink, since sign-up just have to open the register page and you really don't have any information to send to the server..
Joined: Jun 28, 2007
thanks gopi chand, it seems to be a better approach. but, from the learning struts approach, i want to implement 2 buttons on the same form. and then on click of those buttons, separate process executed. i am able to put 2 submit buttons on the same form with different name as mentioned in the login.jsp file of my first post. but am not able to distinguish them in the execute method call.
The value of the submit button, like all the other HTML input tags, gets submitted with the form in a variable which has the same name as the "name" parameter (in your code, "signin" and "newuser"). You can add those two variables to your Action and check which one gets set.