JSPTemplates

org.tp23.jasper
Class DestinationImpl

java.lang.Object
  |
  +--org.tp23.jasper.DestinationImpl
All Implemented Interfaces:
Destination

public class DestinationImpl
extends java.lang.Object
implements Destination

Replacement for a request/response. It contains an internal StringBuffer to which the jsp writes which can then be read as a normal String.

Author:
Paul Hinds

Constructor Summary
DestinationImpl(java.util.Map properties, Engine server)
          The Properties supplied are analogous to the request parameters
 
Method Summary
 void forward(java.lang.String jsp)
          forward to another MyJasper JSP (does not work if you give it a URL).
 java.lang.String getCalledUri()
          gets the String supplied to call the JSP.
 java.lang.String getOutput()
          gets the result of the page.
 java.io.OutputStream getOutputStream()
          get the StringWriter in an OutputStream wrapper
 java.lang.Object getParameter(java.lang.String key)
          get a parameter similar to a request parameter but can be any object passed by the engine.
 Engine getServer()
          Gets the MyJasper that is running the JSP.
 Session getSession()
          returns the Session.
 java.io.StringWriter getWriter()
          get the StringWriter to which data is being written
 void include(java.lang.String jsp)
          Include another MyJasper JSP (does not work if you give it a URL).
 void setCalledUri(java.lang.String uri)
          Called by the container, the uri can be reset by a JSP but it will have no effect.
 void setSession(Session session)
          Sets the session to any HashSession.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DestinationImpl

public DestinationImpl(java.util.Map properties,
                       Engine server)
The Properties supplied are analogous to the request parameters
Parameters:
properties - Any parameters required in the JSP
server - the container in which this destination exists
Method Detail

setCalledUri

public void setCalledUri(java.lang.String uri)
Called by the container, the uri can be reset by a JSP but it will have no effect.
Specified by:
setCalledUri in interface Destination

getCalledUri

public java.lang.String getCalledUri()
gets the String supplied to call the JSP. but available in the running JSP
Specified by:
getCalledUri in interface Destination
See Also:
MyJasper.getOutput(java.lang.String)

setSession

public void setSession(Session session)
Sets the session to any HashSession. Use this to override the default server wide session.
Specified by:
setSession in interface Destination
Parameters:
session - The new session value

getServer

public Engine getServer()
Gets the MyJasper that is running the JSP.
Specified by:
getServer in interface Destination
Returns:
The server value

getWriter

public java.io.StringWriter getWriter()
get the StringWriter to which data is being written
Specified by:
getWriter in interface Destination
Returns:
The internal writer

getOutputStream

public java.io.OutputStream getOutputStream()
get the StringWriter in an OutputStream wrapper
Specified by:
getOutputStream in interface Destination
Returns:
A Thin wrapper around the internal StringWriter

getSession

public Session getSession()
returns the Session. In a JSP the session variable can also be used
Specified by:
getSession in interface Destination
Returns:
The current session

getParameter

public java.lang.Object getParameter(java.lang.String key)
get a parameter similar to a request parameter but can be any object passed by the engine. This can be used in the JSP.
Specified by:
getParameter in interface Destination
Parameters:
key - key to the session object (generally a String)
Returns:
The parameter value

getOutput

public java.lang.String getOutput()
gets the result of the page. Returned as a String not a Stream so watch out for generating really big JSP output because it is stored internally in its entirity.
Specified by:
getOutput in interface Destination
Returns:
The output of the JSP

forward

public void forward(java.lang.String jsp)
             throws JspEngineException
forward to another MyJasper JSP (does not work if you give it a URL). (yet) this clears the contents of the internal sting buffer and then passes control to the include method
Specified by:
forward in interface Destination

include

public void include(java.lang.String jsp)
             throws JspEngineException
Include another MyJasper JSP (does not work if you give it a URL). (yet) now supports files as well
Specified by:
include in interface Destination
Parameters:
jsp - if it ends in .jsp it is treated as a MyJasper jsp from the current jsp root directory if not is is treated a a fileName on the local machine either abslolute (if it begins with X: or / or relative to the current jsp root

JSPTemplates