/**
*
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class goodsRequestProcessor extends RequestProcessor {
/** This method checks whether the method get executed before any processing
* @see org.apache.struts.action.RequestProcessor#processPreprocess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
* @return boolean
* normal processing of the user request is done
* login required page is displayed
*/
protected boolean processPreprocess(HttpServletRequest req, HttpServletResponse res)
{
ActionErrors errors = new ActionErrors();
if(errors)
return true;
else if
return false;
try
{
ForwardConfig config =findForwardConfig("loginrequired");
req.setAttribute(Globals.ERROR_KEY, errors);
/*
* Created on Apr 13, 2009
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package goods.war;
/**This method is called to validate.
* It first checks whether a URL
* It also destroys user session
* @param HttpServletRequest req
* @param ActionErrors errors
* @return boolean
* if a user session is available and user has requested a valid URL
* otherwise
*/
public static boolean validateAction()
{
HttpSession session = req.getSession(false);
if(session)
{
/**This method is called to terminate session
* it gets all the attributes
* @param HttpSession session
*/
public static void invalidateSession()
{
Enumeration allAttrib = session.getAttributeNames();
if(allAttrib)
{
while(allAttrib.hasMoreElements())
{
session.removeAttribute(allAttrib.nextElement());
}
}
session.invalidate();
session=null;
}
/**This method is called to checks whether a user session is available or not.
* @param HttpServletRequest req
* @param ActionErrors errors
* @return boolean
* <br>true : if a user session is available
* <br>false : otherwise
*/
public static boolean isLoggedIn()
{
HttpSession session = req.getSession(false);
if(session)
return true;
else
{
System.err.println("login required");
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.session.failed"));
}
return false;
}