1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.taglib;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import javax.servlet.http.HttpServletResponse;
30 import javax.servlet.jsp.JspException;
31
32
33
34 /***
35 * <p>
36 * the 3 examples below produce all the same result
37 * </p>
38 *
39 * <p>
40 * <linkURL href="customer.jsp" table="customer" position="1:2:12-3:4:1992"
41 * />
42 * </p>
43 *
44 * <p>
45 * <linkURL href="customer.jsp" table="customer" position="<%= currentKey
46 * %>" />
47 * </p>
48 *
49 * <p>
50 * <linkURL href="customer.jsp" table="customer" /> <position
51 * fieldName="id" value="103" /> <position fieldName="cust_lang"
52 * value="2" /> </linkURL>
53 * </p>
54 *
55 * <p>
56 * result (off course without the line feeds)
57 * </p>
58 * <pre>/servlet/control?
59 * ac_goto_x=t&
60 * data_ac_goto_x_fu=/customer.jsp&
61 * data_ac_goto_x_destTable=17&
62 * data_ac_goto_x_destPos=103~2</pre>
63 *
64 * <p>
65 * Use it like this:
66 * </p>
67 * <pre><a href="<linkURL href="customer.jsp" tableName="customer" position="103~2" />"> some text </a></pre>
68 *
69 * @author Neal Katz , based on work from Joachim Peer
70 */
71 public class DbRedirectURLTag extends DbLinkURLTag
72 implements javax.servlet.jsp.tagext.TryCatchFinally {
73 private static Log logCat = LogFactory.getLog(DbRedirectURLTag.class.getName());
74
75 /***
76 * DOCUMENT ME!
77 *
78 * @return DOCUMENT ME!
79 *
80 * @throws JspException thrown when error occurs in processing the body of
81 * this method
82 */
83 public int doBodyEndTag() throws javax.servlet.jsp.JspException {
84 return super.doBodyEndTag();
85 }
86
87
88 /***
89 * DOCUMENT ME!
90 *
91 * @return DOCUMENT ME!
92 *
93 * @throws JspException thrown when error occurs in processing the body of
94 * this method
95 */
96 public int doEndTag() throws javax.servlet.jsp.JspException {
97 try {
98 HttpServletResponse response = (HttpServletResponse) pageContext
99 .getResponse();
100 String s = makeUrl();
101 s = response.encodeURL(s);
102 response.sendRedirect(s);
103 } catch (java.io.IOException ioe) {
104 throw new JspException("IO Error: " + ioe.getMessage());
105 } catch (Exception e) {
106 throw new JspException("Error: " + e.getMessage());
107 }
108
109 return SKIP_PAGE;
110 }
111
112
113 /***
114 * DOCUMENT ME!
115 */
116 public void doFinally() {
117 logCat.info("doFinally called");
118 super.doFinally();
119 }
120
121
122
123
124 /***
125 * DOCUMENT ME!
126 *
127 * @return DOCUMENT ME!
128 *
129 * @throws JspException thrown when error occurs in processing the body of
130 * this method
131 * @throws IllegalArgumentException thrown when some parameters are missing.
132 */
133 public int doStartTag() throws javax.servlet.jsp.JspException {
134 return super.doStartTag();
135 }
136 }