All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.abc.templates.HtmlWriter

java.lang.Object
   |
   +----com.abc.templates.HtmlWriter

public class HtmlWriter
extends OutputStream

Object responsible for dynamic substitution and output page to browser.

Tags to substitute must start and end with symbol @. Their lenght must be less than 20 characters. Double @ will be interpreted as 1 symbol @. You can not split tags into 2 strings and output it with 2 prints. (See example 3).

Examples: assuming bbbb="" and we did not specify @dddd@

1. print("aaaaa@bbbb@cccc@dddd@ccc"); //less than 20 characters

    output: aaaaacccc@dddd@ccc

2. print("aaaaaaaaa@bbbbCCCC"); // no second @ to match the first one 

    output: aaaaaaaaa@bbbbCCCC

3. print("aaaaaaaaa@bb"); print("bb@cc");

    output: aaaaaaaaa@bbbb@cc

4. print("aaaaaaaaa@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb@cccccc"); //more than 20 characters

    output: aaaaaaaaa@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb@cccccc

5. print("aaaaaaaaa@@bbbbb"); // two @ replaced by one

    output: aaaaaaaaa@bbbbb


 o HtmlWriter(HttpServletResponse resp, boolean bBuffered)
constructor. If you want to buffer your output in memory you need pass bBuffered as true. Usually you will pass false.
 o HtmlWriter(HttpServletResponse resp, boolean bBuffered, Substitutor additional)
constructor. If HtmlWriter will no find tag to substitute in local table it will look in additional.
 o addSubstitute(String sTag, String sValue)
Method for adding substitution tokens. Example addSubstitute("Name", "George Ter-Saakov");
 o close()
Will close output and flush output stream.
 o flush()
Will flush output stream.
 o getCharCounter()
returns amount of character written to output.
 o getResponse()
returns HttpServletResponse object.
 o print(byte)
outputs byte to otputstream.
 o print(byte[])
outputs array of bytes to otputstream.
 o print(byte[], int iFrom, int iLength)
outputs array of bytes to otputstream.
 o print(char)
outputs byte to otputstream.
 o print(char[])
outputs array of bytes to otputstream.
 o print(String)
outputs string to otputstream.
 o setContentType(String)
set conten type. The same as HttpServletResponse.setContentType.

 

 o HtmlWriter

 public HtmlWriter(HttpServletResponse res,
                   boolean buffered) throws IOException

 o HtmlWriter

 public HtmlWriter(HttpServletResponse res,
                   boolean buffered,
                   Substitutor subst) throws IOException

 o addSubstitute

 public final void addSubstitute(String sName,
                                 String sSubstitute)
Method for adding substitution tokens to tokens collections.
Parameters:
sName - name of token (case insensitive)
sSubstitute - will be replaced with this string (case sensitive)

 o close

 public final void close() throws IOException

 o flush

 public final void flush() throws IOException

 o getCharCounter

 public final int getCharCounter()
Returns:
amount of characters outputted to browser. (not used in DxiServlet).

 o getResponse

 public final HttpServletResponse getResponse()

 o print

 public final void print(byte s[]) throws IOException

 o print

 public final void print(byte s[],
                         int iFrom,
                         int iLength) throws IOException

 o print

 public final void print(char b[]) throws IOException

 o print

 public final void print(byte b) throws IOException

 o print

 public final void print(char b) throws IOException

 o print

 public final void print(String s) throws IOException

 o setContentType

 public final void setContentType(String sContentType)

All Packages  Class Hierarchy  This Package  Previous  Next  Index