File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Login/Register based web page presentation

 
raghu yeggina
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scriptlet in jsp is consider poor practice . use struts-tag or jstl/EL
 
raghu yeggina
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Seetharam,

I am forwarding it.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then request attribute is preferred
 
raghu yeggina
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic