I got a taglib that every time I try use it got a "Unable to find
setter method for attribute: class" error. The problem is that this
taglib just doesn't have such attribute. I found the error was in it by
commenting out the taglib call from my JSP file.
  Attached to this mail I send my taglib declaration and the tag
sources. Anyone can see the problem???
  BTW: You see I use a custom superclass for my tags, but I it's not the
problem, I got other tags running ok.
-- 

Felipe Schnack
Analista de Sistemas
[EMAIL PROTECTED]
Cel.: (51)91287530
Linux Counter #281893

Faculdade Ritter dos Reis
www.ritterdosreis.br
[EMAIL PROTECTED]
Fone/Fax.: (51)32303328
package com.w2.login.tags;

import com.w2.login.models.*;
import com.w2.login.*;
import com.w2.infra.tags.*;
import com.w2.infra.util.*;
import java.util.*;
import javax.servlet.http.*;
import java.io.*;

/**
 * <p>Confere se o usu&aacute;rio tem sess&atilde;o, garante que a p&aacute;gina
 * expire, etc. Tamb&eacute;m prov&ecirc; m&eacute;todos para destruir a sess&atilde;o.</p>
 * <p>Se ainda h&aacute; sess&atilde;o, grava uma mensagem de auditoria</p>
 * 
 * <p>@author Felipe Schnack</p>
 */
public class HasSessionTag extends Taglib
{
	/**
	 * <p>Nome do m&oacute;dulo atual, usado para limpar a sess&atilde;o quando ele
	 * &eacute; limpo</p>
	 */
	private String module = null;
	
	/**
	 * <p>Sess&atilde;o do usu&aacute;rio</p>
	 */
	private HttpSession session = pageContext.getSession();
	
	/**
	 * @see com.w2.infra.taglibs.Taglib#doTag()
	 */
	public int doTag() throws LoggedException
	{
		//se o modulo mudou, limpa a sessao
		String curmod = (String)session.getAttribute("modulename");
		if (curmod == null || !module.equalsIgnoreCase(curmod))
		{
			CtlLogin.clearSession(session);
		}
		
		//confere se a sessao eh valida, se os dados estao setados nela OK...
		HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
		HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
		if (session == null)
		{
			timeout(response);
		}
		else
		{
			//se ha o horario de logon na secao eh pq ela eh valida
			Date logon = (Date)session.getAttribute("logon");
			Pessoas pessoa = (Pessoas) session.getAttribute("pessoa");
			if (logon == null || pessoa == null)
			{
				timeout(response);
			}
			else
			{
				CtlAudit.urlAccess(session, request, response);
				response.setHeader("Cache-Control", "no-cache");
				response.setHeader("Pragma", "no-cache");
				response.setHeader("Expires", "-1");
			}
		}
		return SKIP_BODY;
	}
	
	/**
	 * <p>Par&acirc;metro obrigat&oacute;rio para setar o nome do m&oacute;dulo atual. Quando o
	 * nome muda, a sess&atilde;o &eacute; limpa usando CtlLogin.clearSession()</p>
	 * 
	 * @see com.w2.login.CtlLogin.clearSession()
	 */
	public void setModule(String mod)
	{
		module = mod;
	}
	
	/**
	 * <p>Redireciona o usu&aacute;rio para a p&aacute;gina de login, notificando erro de 
	 * timeout de sess&atilde;o</p>
	 * 
	 * @param response objeto com a resposta a ser enviada para o browser
	 */
	public static void timeout(HttpServletResponse response) throws LoggedException
	{
		try
		{
			response.sendRedirect("/forms?formname=logout?timeout=TRUE");
		}
		catch (IOException ioe)
		{
			throw new LoggedException(ioe, "Erro redirecionando para a pagina de login!");
		}
	}
	
	/**
	 * <p>Libera recursos da taglib</p>
	 */
	public void release()
	{
		super.release();
		module = null;
		session = null;
	}
}
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
        PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
        "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd";>
        
<taglib>
        <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>w2 login</short-name>
        <description>Taglib for w2's login</description>
        <tag>
                <name>hasSession</name>
                <tag-class>com.w2.login.tags.HasSessionTag</tag-class>
                <body-content>empty</body-content>
                <attribute>
                        <name>module</name>
                        <required>true</required>
                </attribute>
                <attribute>
                        <name>destroy</name>
                        <required>false</required>
                </attribute>
        </tag>
</taglib>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to