~ubuntu-branches/ubuntu/trusty/libstruts1.2-java/trusty-proposed

« back to all changes in this revision

Viewing changes to src/share/org/apache/struts/taglib/html/RewriteTag.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2004-11-19 15:35:25 UTC
  • Revision ID: james.westby@ubuntu.com-20041119153525-mdu08a76z4zo67xt
Tags: upstream-1.2.4
ImportĀ upstreamĀ versionĀ 1.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RewriteTag.java,v 1.20 2004/03/14 06:23:46 sraeburn Exp $
 
3
 * $Revision: 1.20 $
 
4
 * $Date: 2004/03/14 06:23:46 $
 
5
 *
 
6
 * Copyright 1999-2004 The Apache Software Foundation.
 
7
 * 
 
8
 * Licensed under the Apache License, Version 2.0 (the "License");
 
9
 * you may not use this file except in compliance with the License.
 
10
 * You may obtain a copy of the License at
 
11
 * 
 
12
 *      http://www.apache.org/licenses/LICENSE-2.0
 
13
 * 
 
14
 * Unless required by applicable law or agreed to in writing, software
 
15
 * distributed under the License is distributed on an "AS IS" BASIS,
 
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
17
 * See the License for the specific language governing permissions and
 
18
 * limitations under the License.
 
19
 */
 
20
 
 
21
package org.apache.struts.taglib.html;
 
22
 
 
23
import java.net.MalformedURLException;
 
24
import java.util.Map;
 
25
 
 
26
import javax.servlet.jsp.JspException;
 
27
 
 
28
import org.apache.struts.taglib.TagUtils;
 
29
 
 
30
/**
 
31
 * Generate a URL-encoded URI as a string.
 
32
 *
 
33
 * @version $Revision: 1.20 $ $Date: 2004/03/14 06:23:46 $
 
34
 */
 
35
public class RewriteTag extends LinkTag {
 
36
 
 
37
 
 
38
    // --------------------------------------------------------- Public Methods
 
39
 
 
40
 
 
41
    /**
 
42
     * Render the appropriately encoded URI.
 
43
     *
 
44
     * @exception JspException if a JSP exception has occurred
 
45
     */
 
46
    public int doStartTag() throws JspException {
 
47
 
 
48
        // Generate the hyperlink URL
 
49
        Map params = TagUtils.getInstance().computeParameters
 
50
            (pageContext, paramId, paramName, paramProperty, paramScope,
 
51
             name, property, scope, transaction);
 
52
             
 
53
        String url = null;
 
54
        try {
 
55
            // Note that we're encoding the & character to & in XHTML mode only, 
 
56
            // otherwise the & is written as is to work in javascripts. 
 
57
                        url =
 
58
                                TagUtils.getInstance().computeURLWithCharEncoding(
 
59
                                        pageContext,
 
60
                                        forward,
 
61
                                        href,
 
62
                                        page,
 
63
                                        action,
 
64
                                        module,
 
65
                                        params,
 
66
                                        anchor,
 
67
                                        false,
 
68
                    this.isXhtml(),
 
69
                    useLocalEncoding);
 
70
                    
 
71
        } catch (MalformedURLException e) {
 
72
            TagUtils.getInstance().saveException(pageContext, e);
 
73
            throw new JspException
 
74
                (messages.getMessage("rewrite.url", e.toString()));
 
75
        }
 
76
 
 
77
        TagUtils.getInstance().write(pageContext, url);
 
78
 
 
79
        return (SKIP_BODY);
 
80
 
 
81
    }
 
82
 
 
83
 
 
84
 
 
85
    /**
 
86
     * Ignore the end of this tag.
 
87
     *
 
88
     * @exception JspException if a JSP exception has occurred
 
89
     */
 
90
    public int doEndTag() throws JspException {
 
91
 
 
92
        return (EVAL_PAGE);
 
93
 
 
94
    }
 
95
 
 
96
 
 
97
}