FileDocCategorySizeDatePackage
BackRefTag.javaAPI DocExample1699Wed Jun 16 14:50:24 BST 2004com.darwinsys.jsptags

BackRefTag

public class BackRefTag extends javax.servlet.jsp.tagext.TagSupport
BackRefTag - generate a href back to the referrer, initially for use on help.
version
$Id: BackRefTag.java,v 1.3 2004/06/16 18:50:24 ian Exp $

Fields Summary
private static final String
DEFAULT_LABEL
private String
surroundingtag
private String
label
Constructors Summary
Methods Summary
public intdoEndTag()
Invoked at the end tag boundary, does the work


	          
	     
		final String myLabel = label == null ? DEFAULT_LABEL : label;
		try {
			final HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
			final JspWriter out = pageContext.getOut();
			final String whereFrom = request.getHeader("referer");
			if (whereFrom == null) {
				System.out.println("Warning: BackRefTag: no referer");
				return SKIP_BODY;
			}
			if (surroundingtag != null) {
				out.println("<" + surroundingtag + ">");
			}
			out.println("<a href=" + whereFrom + ">" + 
							(label == null ? DEFAULT_LABEL : label) + "</a>");
			if (surroundingtag != null) {
				out.println("<" + "/" + surroundingtag + ">");
			}
			out.flush();
			return SKIP_BODY;
		} catch (Throwable t) {
			System.err.println("Tag caught: " + t);
			throw new JspException(t.toString());
		}
	
public voidsetLabel(java.lang.String lab)

param
lab The label to print (e.g., "Back");

		label = lab;
	
public voidsetSurroundingtag(java.lang.String surround)

param
surround The HTML tag to surrounding the link (e.g., "h6").

		surroundingtag = surround;