KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > authoring > tags > RssBadgeTag


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 JavaDoc;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.jsp.JspException JavaDoc;
25 import javax.servlet.jsp.tagext.Tag JavaDoc;
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 org.apache.roller.ui.core.tags.HybridTag
36 {
37     static final long serialVersionUID = 8569693454388788128L;
38     
39     private static Log mLogger =
40        LogFactory.getFactory().getInstance(RssBadgeTag.class);
41
42     //------------------------------------------------------------------------
43
/**
44      * Process start tag.
45      * @return EVAL_SKIP_BODY
46      */

47     public int doStartTag( PrintWriter JavaDoc pw ) throws JspException JavaDoc
48     {
49         try
50         {
51             HttpServletRequest JavaDoc req =
52                 (HttpServletRequest JavaDoc)pageContext.getRequest();
53             RollerRequest rreq = RollerRequest.getRollerRequest(req);
54
55             WebsiteData website = rreq.getWebsite();
56             pw.println(
57                    "<a HREF="+"\"" + req.getContextPath() + "/rss/"
58                 + website.getHandle() + "\">"
59                 + "<img "+"src=\"" + req.getContextPath() + "/images/rssbadge.gif\" "
60                 + "class=\"rssbadge\" "
61                 + "alt=\"XML\""
62                 + "/>"
63                 + "</a>");
64          }
65         catch (Exception JavaDoc e)
66         {
67             mLogger.error("Exception",e);
68             throw new JspException JavaDoc(
69                 e.getClass().toString()+": "+e.getMessage(),e);
70         }
71         return Tag.SKIP_BODY;
72     }
73 }
74
75
Popular Tags