1 package org.apache.jetspeed.services.jsp.tags;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import javax.servlet.jsp.JspException;
20 import javax.servlet.jsp.PageContext;
21 import javax.servlet.jsp.tagext.TagSupport;
22
23
24 import org.apache.turbine.util.ContentURI;
25 import org.apache.turbine.util.RunData;
26 import org.apache.turbine.services.jsp.JspService;
27
28
29 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
30 import org.apache.jetspeed.services.logging.JetspeedLogger;
31
32 /***
33 * Supporting class for the contentURI tag.
34 * Returns the URL for the given webapp relative URI
35 *
36 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>
37 * @version $Id: ContentURITag.java,v 1.7 2004/02/23 03:59:40 jford Exp $
38 */
39 public class ContentURITag extends TagSupport
40 {
41 /***
42 * Static initialization of the logger for this class
43 */
44 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ContentURITag.class.getName());
45
46 /***
47 * type parameter defines type of URI that is requested
48 */
49 private String href;
50
51 /***
52 * The setter for type parameter
53 */
54 public void setHref(String href)
55 {
56 this.href = href;
57 }
58
59 public int doStartTag() throws JspException
60 {
61 RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
62
63 String result = new ContentURI(data).getURI(this.href);
64
65 try
66 {
67 if (result != null) {
68 pageContext.getOut().print(result);
69 }
70 }
71 catch (Exception e)
72 {
73 String message = "Error processing contentUri-tag, parameter: "+ href;
74 logger.error(message, e);
75 try
76 {
77 data.getOut().print( message );
78 }
79 catch(java.io.IOException ioe) {}
80 }
81
82 return EVAL_BODY_INCLUDE;
83 }
84
85 }