1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.taglib.util;
24
25 import javax.servlet.jsp.tagext.TagSupport;
26 import javax.servlet.jsp.JspWriter;
27 import javax.servlet.http.HttpServletRequest;
28 import java.io.IOException;
29
30 import org.talika.tarsis.Globals;
31
32 /**
33 * Implementation of <util:link> tag.
34 *
35 * @author Jose M. Palomar
36 * @version $Revision: 130 $
37 */
38 public class LinkTag extends TagSupport {
39
40
41 /**
42 * <code>command</code> attribute.
43 */
44 private String command;
45
46
47 /**
48 * Process the start tag for this instance.
49 *
50 * @return int SKIP_BODY.
51 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
52 */
53 public int doStartTag() {
54
55 try {
56
57 JspWriter out = pageContext.getOut();
58 HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
59
60 out.print(request.getContextPath());
61 out.print(Globals.CONTROLLER_SERVLET);
62 if (!command.startsWith("/")) {
63 out.print("/");
64 }
65 out.print(command);
66
67 }
68 catch (IOException ioe) {
69
70 }
71
72 return SKIP_BODY;
73
74 }
75
76 /**
77 * Sets <code>command</code> attribute value.
78 *
79 * @param command String <code>command</code> attribute value.
80 */
81 public void setCommand(String command) {
82 this.command = command;
83 }
84
85 /**
86 * Called on a Tag handler to release state.
87 *
88 * @see javax.servlet.jsp.tagext.Tag#release()
89 */
90 public void release() {
91
92 super.release();
93
94 this.command = null;
95
96 }
97
98 }