File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Login/Register based web page presentation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Login/Register based web page presentation " Watch "Login/Register based web page presentation " New topic
Author

Login/Register based web page presentation

raghu yeggina
Greenhorn

Joined: Feb 11, 2009
Posts: 27
Hi Friends,

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.

Thanks in advance
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Two points:
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



[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Scriptlet in jsp is consider poor practice . use struts-tag or jstl/EL
raghu yeggina
Greenhorn

Joined: Feb 11, 2009
Posts: 27
Thanks Sagar and Seetharaman,

Still there's a small question Sagar. No need to set "session" variable, a setting request variable will help .

does request variable means that request parameter is alone sufficient or we need to set a request attribute?

Thanks in advance.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

raghu yeggina wrote:does request variable means that request parameter is alone sufficient or we need to set a request attribute?

Better you set the request attribute depends upon the action execution (login or registration )
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

raghu yeggina wrote:
does request variable means that request parameter is alone sufficient or we need to set a request attribute

whether you are forwarding or redirecting to an appropriate page?
raghu yeggina
Greenhorn

Joined: Feb 11, 2009
Posts: 27
Hi Seetharam,

I am forwarding it.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

then request attribute is preferred
raghu yeggina
Greenhorn

Joined: Feb 11, 2009
Posts: 27
Hi Sagar & Seetharam,

Our requirement is fulfilled successfully with the help of request attribute as suggested by you.


Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Login/Register based web page presentation