01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18:
19: package org.apache.roller.ui.authoring.tags;
20:
21: import java.io.PrintWriter;
22:
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.jsp.JspException;
25: import javax.servlet.jsp.tagext.Tag;
26:
27: import org.apache.commons.logging.Log;
28: import org.apache.commons.logging.LogFactory;
29: import org.apache.roller.pojos.WebsiteData;
30: import org.apache.roller.ui.core.RollerRequest;
31:
32: /**
33: * @jsp.tag name="RssBadge"
34: */
35: public class RssBadgeTag extends
36: org.apache.roller.ui.core.tags.HybridTag {
37: static final long serialVersionUID = 8569693454388788128L;
38:
39: private static Log mLogger = LogFactory.getFactory().getInstance(
40: RssBadgeTag.class);
41:
42: //------------------------------------------------------------------------
43: /**
44: * Process start tag.
45: * @return EVAL_SKIP_BODY
46: */
47: public int doStartTag(PrintWriter pw) throws JspException {
48: try {
49: HttpServletRequest req = (HttpServletRequest) pageContext
50: .getRequest();
51: RollerRequest rreq = RollerRequest.getRollerRequest(req);
52:
53: WebsiteData website = rreq.getWebsite();
54: pw.println("<a href=" + "\"" + req.getContextPath()
55: + "/rss/" + website.getHandle() + "\">" + "<img "
56: + "src=\"" + req.getContextPath()
57: + "/images/rssbadge.gif\" " + "class=\"rssbadge\" "
58: + "alt=\"XML\"" + "/>" + "</a>");
59: } catch (Exception e) {
60: mLogger.error("Exception", e);
61: throw new JspException(e.getClass().toString() + ": "
62: + e.getMessage(), e);
63: }
64: return Tag.SKIP_BODY;
65: }
66: }
|