/*
 * $Id: CSSIncludeTag.java,v 1.2 2006/10/04 03:15:09 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: CSSIncludeTag.java,v $
 * Revision 1.2  2006/10/04 03:15:09  marbobo
 * + Vollständige Unterstützung für Templates implementiert
 * + Alles von Virtoweb auf ProCoBa umgestellt
 *
 * Revision 1.1  2005/02/14 14:00:51  bigmac
 * *** empty log message ***
 *
 */
package vkc.view.tag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import vkc.db.entities.VKCUser;
import vkc.util.ServletUtils;
import vkc.view.WebShare;

public final class CSSIncludeTag extends TagSupport {
    public int doEndTag() throws JspException {
        try {
        	JspWriter writer = pageContext.getOut();
            HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
            VKCUser user = ServletUtils.getUser(request);

        	writer.print("<link rel=\"stylesheet\" ");
        	writer.print("href=\"");
        	writer.print(request.getContextPath());
        	writer.print(ServletUtils.replacePathVars(WebShare.getApplicationCss(), user));
        	writer.print("\" />");
        } catch (IOException ioex) {
            throw new JspException(ioex);
        }

        return EVAL_PAGE;
    }

    public int doStartTag() throws JspException {
        return SKIP_BODY;
    }

    public void release() {
        super.release();
    }
}