Source code: com/tripi/asp/HTMLNode.java
1 /**
2 * ArrowHead ASP Server
3 * This is a source file for the ArrowHead ASP Server - an 100% Java
4 * VBScript interpreter and ASP server.
5 *
6 * For more information, see http://www.tripi.com/arrowhead
7 *
8 * Copyright (C) 2002 Terence Haddock
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 package com.tripi.asp;
26
27 import java.io.IOException;
28
29 /**
30 * HTMLNode handles a normal HTML %> ... <% "output" node.
31 *
32 * @author Terence Haddock
33 * @version 0.9
34 */
35 public class HTMLNode implements Node
36 {
37 /** Text string of the HTML */
38 String html;
39
40 /**
41 * Constructor.
42 *
43 * @param inHtml HTML string of this node.
44 */
45 public HTMLNode(String inHtml)
46 {
47 html = inHtml;
48 }
49
50 /**
51 * Dumps this node.
52 * @see Node#dump()
53 */
54 public void dump()
55 {
56 System.out.print("%>" + html + "<%");
57 }
58
59 /**
60 * Prepares this node for execution.
61 * @param context AspContext this node will be executed under.
62 * @see Node#prepare(AspContext)
63 */
64 public void prepare(AspContext context)
65 {
66 /* Nothing to do */
67 }
68
69 /**
70 * Executes this node within the specified context. This node simply
71 * calls the Response.Write routine within the current context
72 * to output this node.
73 * @param context AspContext to execute this node under.
74 * @see Node#execute(AspContext)
75 * @throws AspException if an error occurs
76 */
77 public Object execute(AspContext context) throws AspException
78 {
79 final IdentNode respIdent = new IdentNode("response");
80 JavaObjectNode respObj = (JavaObjectNode)context.getValue(respIdent);
81 Response resp = (Response)respObj.getSubObject();
82 try {
83 resp.Write(html);
84 } catch (IOException ex) {
85 throw new AspNestedException(ex);
86 }
87
88 return null;
89 }
90 };
91