1    package com.instantbank.collections.main.web;
2    
3    import java.io.IOException;
4    import javax.servlet.jsp.JspException;
5    import javax.servlet.jsp.tagext.TagSupport;
6    import oracle.xml.parser.v2.XMLDocument;
7    import oracle.xml.parser.v2.XMLNode;
8    import org.w3c.dom.Node;
9    import com.instantbank.collections.util.StringFormat;
10   
11   public class ValueOfTag extends TagSupport {
12     private String name = null;
13     private XMLNode node = null;
14   
15   
16     public void setName(String name) {
17       this.name = name;
18     }
19   
20   
21     public void setNode(Node node) {
22       XMLDocument root;
23   
24       if(node instanceof XMLDocument) {
25         root = (XMLDocument)node;
26         this.node = (XMLNode)root.getDocumentElement();
27       }
28       else {
29         this.node = (XMLNode)node;
30       }
31     }
32   
33   
34     public int doStartTag() throws JspException {
35       String value;
36   
37       try {
38         value = StringFormat.toSafeJavaString(node.valueOf("./" + name));
39         if(value == null) {
40           value = "";
41         }
42       }
43       catch(Exception e) {
44         value = "";
45       }
46       try {
47         pageContext.getOut().print(value);
48       }
49       catch(IOException e) {
50         throw new JspException(e.getMessage());
51       }
52       return SKIP_BODY;
53     }
54   
55   
56     public void release() {
57       node = null;
58       name = null;
59     }
60   }
61