• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Login/Register based web page presentation

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


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

I am forwarding it.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then request attribute is preferred
 
raghu yeggina
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic