I have a requirement in my struts 1.2 project in which there's a login.jsp which has two buttons 'login' and 'register' which loads a page named registration.jsp which provides the login and registration divisions on the same page.
Now my requirement is to make the focus of 'Login Name' s textbox on when clicked on 'login' or to make the focus of 'First Name' 's textbox on when clicked on 'register' in my login.jsp page.
Here when we are clicking on login or register we are switching from module to another causing the request go to struts-config.xml of another module.
I have two options in my mind where one is to set a request parameter when calling a method in an action class where the request is going in both cases and there setting a session attribute named 'clicked' and setting it to 'login' or 'register' and then getting the session attribute in the registration.jsp page and then checking its value if its 'clicked' or 'register' and then based on the value calling a method on the body tag's onload option. just like this below.
Please suggest me if its a proper coding or not.
And also i have a second option to specify two separate paths to login and register which have the same functionality till the time we go to tiles defs and specify two separate jsp's for the both and the only change that will be there is the change in the method of the onload property of the body tag.
but i have a doubt that is it correct to accept redundancy in code for this requirement..
Please suggest me an optimum solution for the present requirement.
1. No need to set "session" variable, a setting request variable will help
2. You can totally hide the either part as per the user wish (login or registration) if you used Struts logi:present, like