KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > micronova > jsp > tag > IncludeTag


1 /*
2
3 Copyright 2003-2007 MicroNova (R)
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or
7 without modification, are permitted provided that the following
8 conditions are met:
9
10     * Redistributions of source code must retain the above copyright
11     notice, this list of conditions and the following disclaimer.
12
13     * Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17     * Neither the name of MicroNova nor the names of its contributors
18     may be used to endorse or promote products derived from this
19     software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
32
33 */

34
35
36 package com.micronova.jsp.tag;
37
38 import java.io.*;
39 import java.util.*;
40 import java.net.*;
41 import javax.net.ssl.*;
42 import java.security.cert.X509Certificate JavaDoc;
43 import com.micronova.util.*;
44
45 public class IncludeTag extends MapTag
46 {
47     private static final String JavaDoc DEFAULTEXPORT = "${" + VALUEVAR + "." + NetUtil.RESPONSE + "." + NetUtil.CONTENT + "}";
48
49     protected boolean _asynchronous;
50     protected NestedMap _asynchronousMap;
51
52     protected void init()
53     {
54         super.init();
55
56         _export = DEFAULTEXPORT;
57
58         _asynchronous = false;
59
60         Map map = _map;
61
62         map.put(NetUtil.USESTRUSTMANAGER, "true");
63         map.put(NetUtil.USESHOSTNAMEVERIFIER, "true");
64         map.put(NetUtil.THROWSEXCEPTION, "true");
65         map.put(NetUtil.FOLLOWSREDIRECTS, "true");
66         map.put(NetUtil.ALLOWSFILE, "false");
67     }
68
69     protected Object JavaDoc processValue(Object JavaDoc tagValue) throws Exception JavaDoc
70     {
71         if (_asynchronous)
72         {
73             NetUtil netUtil = new NetUtil(_map);
74
75             Thread JavaDoc thread = new Thread JavaDoc(netUtil);
76             thread.start();
77
78             return thread;
79         }
80         else
81         {
82             return NetUtil.request(_map);
83         }
84     }
85
86     /** sets URL */
87
88     public void setUrl(Object JavaDoc expression) throws Exception JavaDoc
89     {
90         _map.put(NetUtil.URL, evaluateAttribute("url", expression, String JavaDoc.class));
91     }
92
93     /** allows "file" URL */
94
95     public void setAllowsFile(Object JavaDoc expression) throws Exception JavaDoc
96     {
97         _map.put(NetUtil.ALLOWSFILE, evaluateAttribute("allowsFile", expression, Boolean JavaDoc.class));
98     }
99
100     /** sets asynchronous */
101
102     public void setAsynchronous(Object JavaDoc expression) throws Exception JavaDoc
103     {
104         boolean asynchronous = ((Boolean JavaDoc)evaluateAttribute("asynchronous", expression, Boolean JavaDoc.class)).booleanValue();
105
106         if (asynchronous)
107         {
108             _export = "${" + VALUEVAR + "}";
109         }
110         
111         _asynchronous = asynchronous;
112     }
113 }
114
Popular Tags