FileDocCategorySizeDatePackage
ValidateSessionTag.javaAPI DocExample2765Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.generic

ValidateSessionTag

public class ValidateSessionTag extends TagSupport
This class is a custom action for checking if a session contains information about an authenticated user.
author
Hans Bergsten, Gefion software
version
1.0.1

Fields Summary
private String
name
private String
errorMsg
private String
loginPage
Constructors Summary
Methods Summary
public intdoEndTag()
Looks for the specified session bean. If not found, forwards the request to the specifed error page with the parameters origURL and errorMsg.

        if (pageContext.getAttribute(name, PageContext.SESSION_SCOPE) == null) {
            HttpServletRequest request = 
                (HttpServletRequest) pageContext.getRequest();
            String origURL = HttpUtils.getRequestURL(request).toString();
	    String queryString = request.getQueryString();
	    if (queryString != null) {
		origURL += "?" + queryString;
	    }
	    String loginURL = loginPage + "?origURL=" + 
                URLEncoder.encode(origURL) +
                "&errorMsg=" + URLEncoder.encode(errorMsg);
            try {
                pageContext.forward(loginURL);
            }
            catch (IOException e) {
                throw new JspException("IOException when forwarding to loginPage: " +
                    e.getMessage());
            }
            catch (ServletException e) {
                throw new JspException("ServletException when forwarding to loginPage: " +
                    e.getMessage());
            }
            return SKIP_PAGE;
        }
        return EVAL_PAGE;
    
public voidrelease()
Releases all instance variables.

        name =  null;
        errorMsg = null;
        loginPage = null;
        super.release();
    
public voidsetErrorMsg(java.lang.String errorMsg)
Sets the error message to display on the login page.

param
errorMsg the error message to display on the login page

        this.errorMsg = errorMsg;
    
public voidsetLoginPage(java.lang.String loginPage)
Sets the login page URL

param
loginPage the login page URL

        this.loginPage = loginPage;
    
public voidsetName(java.lang.String name)
Sets the name of the session object to look for.

param
name the name of the session object to look for

        this.name = name;