In a small Struts application (not using any data base) I have a login.jsp
and register.jsp
.
Once the Login is successful it is redirected to success.jsp
.
Once the Registration is successful it is redirected to the same success.jsp
.
Now, once I login I want to display the login name of the person who logged in and after registration I want to show the name of the person who registered. As I am using the same success.jsp
, how will I display them?
I am using <jsp:usebean>
, <jsp:setProperty>
, <jsp:getProperty>
tags to get the value of the 开发者_StackOverflowattribute.
Check whether bean is initialized, if not so don't use that and use other, for eg for registration only that bean will be init, not login one.
I got a solution!
Alog with Loginform bean and Registerform bean, I took another Bean Suppose UserBean and provided setter and getter methods for the LoginName in that bean and i inherited that bean in my Login and register bean.
In Success jsp I took a form object of UserBean and wrote the following logic
UserForm form=null; form=null!=request.getAttribute("LoginForm") ?(UserForm)request.getAttribute(LoginForm) :(UserForm)request.getAttribute("RegisterForm");
精彩评论