issessionfromurltag.java

来自「jakarta-taglibs」· Java 代码 · 共 81 行

JAVA
81
字号
/*
 * Copyright 1999,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.taglibs.request;

import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

/**
 * JSP Tag <b>issessionfromurl</b>, used to determine if HttpServletRequest
 * session is from URL encoding.
 * <p>
 * Includes the body of the tag if is from URL encoding.
 * <p>
 * You can set the optional tag attribute <b>value</b> to <i>true</i> or
 * <i>false</i>.  The body of the tag is included if issessionfromurl matches
 * the value.
 * <p>
 * JSP Tag Lib Descriptor
 * <p><pre>
 * &lt;name&gt;issessionfromurl&lt;/name&gt;
 * &lt;tagclass&gt;org.apache.taglibs.request.IsSessionFromURLTag&lt;/tagclass&gt;
 * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
 * &lt;info&gt;Test whether the HTTP connection is secure (using HTTPS).&lt;/info&gt;
 *   &lt;attribute&gt;
 *     &lt;name&gt;value&lt;/name&gt;
 *     &lt;required&gt;false&lt;/required&gt;
 *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
 *   &lt;/attribute&gt;
 * </pre>
 *
 * @author Glenn Nielsen
 */

public class IsSessionFromURLTag extends TagSupport
{
    private boolean value = true;

    /**
     * Determines whether session is from URL encoding
     *
     * @return SKIP_BODY if issessionfromurl doesn't match value, EVAL_BODY_include if issessionfromurl matches value
     */
    public final int doStartTag() throws JspException
    {
	boolean result = ((HttpServletRequest)pageContext.getRequest()).isRequestedSessionIdFromURL();

	if( value == result )
	    return EVAL_BODY_INCLUDE;

	return SKIP_BODY;
    }

    /**
     * Set the optional tag attribute <b>value</b> to true or false. 
     *
     * @param boolean true or false
     */
    public final void setValue(boolean value)
    {
	this.value = value;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?