Referer taglib ver. 1.4


    Custom JSP tag. Evaluates and processes own body if the specified referer field matches to the given criteria. As a referer field you may use client's IP address, an URL for the page from which client's request was redirected to your JSP page (referer), User-Agent info and Accept header.

So, this tag will be useful when you need to add support for advertising, personalization or security in your JSP pages.

For example:
 


<%@ taglib uri="taglib.tld" prefix="if" %>

<!-- disable access from the specified IP address -->
<if:Referer field="ip" pattern="192.168.1.1">
   <% return; %>
</if:Referer>

When you describe your criteria, you may use metasymbol * which will match to any substring. For example:
 


<%@ taglib uri="taglib.tld" prefix="if" %>

<!-- some special procedure for all requests from Google -->
<if:Referer field="url" pattern="http://www.google.com*">
   <% out.println("Google is a cool search engine!"); %>
</if:Referer>

<!-- do something for MS IE browser -->
<if:Referer field="agent" pattern="*MSIE*">
   <% out.println("Your browser is MS IE!"); %>
</if:Referer>

<!-- do something for mobiles with WAP/WML -->
<if:Referer field="accept" pattern="*wap.wml*">
   <% out.println("User with mobile!"); %>
</if:Referer>

<!-- disable access for bots -->
<if:Referer field="agent" pattern="*bot*">
   <% return; %>
</if:Referer>

Tags are:

Referer

Evaluates own body in case of referer field matches to the given pattern. Parameters are:

1) field Optional parameter. Describes referer field. Possible values are ip, url, agent, accept. Default value is url.
2) pattern match criteria.
 

for downloading:

    Library: reftag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

     

Also in Coldtags: