KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > html > RewriteTag


1 /*
2  * $Id: RewriteTag.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.taglib.html;
20
21 import java.net.MalformedURLException JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import javax.servlet.jsp.JspException JavaDoc;
25
26 import org.apache.struts.taglib.TagUtils;
27
28 /**
29  * Generate a URL-encoded URI as a string.
30  *
31  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
32  */

33 public class RewriteTag extends LinkTag {
34
35
36     // --------------------------------------------------------- Public Methods
37

38
39     /**
40      * Render the appropriately encoded URI.
41      *
42      * @exception JspException if a JSP exception has occurred
43      */

44     public int doStartTag() throws JspException JavaDoc {
45
46         // Generate the hyperlink URL
47
Map JavaDoc params = TagUtils.getInstance().computeParameters
48             (pageContext, paramId, paramName, paramProperty, paramScope,
49              name, property, scope, transaction);
50              
51         String JavaDoc url = null;
52         try {
53             // Note that we're encoding the & character to & in XHTML mode only,
54
// otherwise the & is written as is to work in javascripts.
55
url =
56                 TagUtils.getInstance().computeURLWithCharEncoding(
57                     pageContext,
58                     forward,
59                     href,
60                     page,
61                     action,
62                     module,
63                     params,
64                     anchor,
65                     false,
66                     this.isXhtml(),
67                     useLocalEncoding);
68                     
69         } catch (MalformedURLException JavaDoc e) {
70             TagUtils.getInstance().saveException(pageContext, e);
71             throw new JspException JavaDoc
72                 (messages.getMessage("rewrite.url", e.toString()));
73         }
74
75         TagUtils.getInstance().write(pageContext, url);
76
77         return (SKIP_BODY);
78
79     }
80
81
82
83     /**
84      * Ignore the end of this tag.
85      *
86      * @exception JspException if a JSP exception has occurred
87      */

88     public int doEndTag() throws JspException JavaDoc {
89
90         return (EVAL_PAGE);
91
92     }
93
94
95 }
96
Popular Tags