Session Handling In JSP:
Session Handling In JSP:
Session management can be getting by using the following things:
• Cookies
• URL rewriting
• Hidden form fields
Last edited by nitesh14; 02-06-2010 at 03:35 PM.
Follow the given code below which is resolves your problem:
public class ProcessLoginAction
extends LoginAction
{
public ActionForward doAction(ActionMapping mapping,
ActionForm form,
BreadCrumbTrail breadCrumbTrail,
EventLog eventLog, User user,
HttpServletRequest request,
HttpServletResponse response)
{
ActionForward forward=null;
UserManager userManager=Context.getContext().getUserManager();
String username=
((String) request.getParameter(Parameters.USERNAME));
String password=
((String) request.getParameter(Parameters.PASSWORD));
String redirect=
((String) request.getParameter(Parameters.REFERRER));
if ( (username==null) || (username.equals(""))
||(password==null) || (password.equals(""))
)
{
String userMessage =
"Please enter both a username and password.";
request.setAttribute(Attributes.USER_MESSAGE,userM essage);
forward = mapping.findForward(ActionForwardConstants.LOGIN_M AIN);
} else
{
try
{
User registeredUser=
userManager.authorizeUser(username,password);
// get session
HttpSession session = request.getSession(true);
session.setAttribute(Attributes.USER,registeredUse r);
if ( redirect==null || redirect.equals("") )
{
redirect=Links.linkToHomeMain();
}
forward=new ActionForward(redirect);
forward.setRedirect(true);
} catch ( AuthorizationException ae )
{
String userMessage =
"Invalid username/password combination. Please try again.";
request.setAttribute(Attributes.USER_MESSAGE,userM essage);
forward =
mapping.findForward(ActionForwardConstants.LOGIN_M AIN);
}
}
return forward;
} // doAction
Last edited by nitesh14; 02-06-2010 at 03:35 PM.
Bookmarks