org.apache.catalina.ssi
Class SSIServletExternalResolver

java.lang.Object
  extended byorg.apache.catalina.ssi.SSIServletExternalResolver
All Implemented Interfaces:
SSIExternalResolver

public class SSIServletExternalResolver
extends java.lang.Object
implements SSIExternalResolver

An implementation of SSIExternalResolver that is used with servlets.

Version:
$Revision: 1.3 $, $Date: 2004/08/26 21:40:03 $
Author:
Dan Sandberg

Nested Class Summary
protected  class SSIServletExternalResolver.ServletContextAndPath
           
 
Field Summary
protected  int debug
           
protected  boolean isVirtualWebappRelative
           
protected  javax.servlet.http.HttpServletRequest req
           
protected  javax.servlet.http.HttpServletResponse res
           
protected  javax.servlet.http.HttpServlet servlet
           
protected  java.lang.String[] VARIABLE_NAMES
           
 
Constructor Summary
SSIServletExternalResolver(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean isVirtualWebappRelative, int debug)
           
 
Method Summary
 void addVariableNames(java.util.Collection variableNames)
          Adds any external variables to the variableNames collection.
protected  java.lang.String getAbsolutePath(java.lang.String path)
           
protected  java.lang.String getCGIVariable(java.lang.String name)
           
 java.util.Date getCurrentDate()
          Returns the current date.
 long getFileLastModified(java.lang.String path, boolean virtual)
           
 long getFileSize(java.lang.String path, boolean virtual)
           
 java.lang.String getFileText(java.lang.String originalPath, boolean virtual)
           
protected  java.lang.String getPathWithoutContext(java.lang.String servletPath)
           
protected  java.lang.String getPathWithoutFileName(java.lang.String servletPath)
           
protected  java.lang.Object getReqAttributeIgnoreCase(java.lang.String targetName)
           
protected  SSIServletExternalResolver.ServletContextAndPath getServletContextAndPath(java.lang.String originalPath, boolean virtual)
           
protected  SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromNonVirtualPath(java.lang.String nonVirtualPath)
           
protected  SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromVirtualPath(java.lang.String virtualPath)
           
protected  java.net.URLConnection getURLConnection(java.lang.String originalPath, boolean virtual)
           
 java.lang.String getVariableValue(java.lang.String name)
           
protected  boolean isNameReserved(java.lang.String name)
           
protected  boolean isRootContext(javax.servlet.ServletContext servletContext)
           
 void log(java.lang.String message, java.lang.Throwable throwable)
           
protected  java.lang.String nullToEmptyString(java.lang.String string)
           
 void setVariableValue(java.lang.String name, java.lang.String value)
          Set the named variable to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VARIABLE_NAMES

protected final java.lang.String[] VARIABLE_NAMES

servlet

protected javax.servlet.http.HttpServlet servlet

req

protected javax.servlet.http.HttpServletRequest req

res

protected javax.servlet.http.HttpServletResponse res

isVirtualWebappRelative

protected boolean isVirtualWebappRelative

debug

protected int debug
Constructor Detail

SSIServletExternalResolver

public SSIServletExternalResolver(javax.servlet.http.HttpServlet servlet,
                                  javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res,
                                  boolean isVirtualWebappRelative,
                                  int debug)
Method Detail

log

public void log(java.lang.String message,
                java.lang.Throwable throwable)
Specified by:
log in interface SSIExternalResolver

addVariableNames

public void addVariableNames(java.util.Collection variableNames)
Description copied from interface: SSIExternalResolver
Adds any external variables to the variableNames collection.

Specified by:
addVariableNames in interface SSIExternalResolver
Parameters:
variableNames - the collection to add to

getReqAttributeIgnoreCase

protected java.lang.Object getReqAttributeIgnoreCase(java.lang.String targetName)

isNameReserved

protected boolean isNameReserved(java.lang.String name)

setVariableValue

public void setVariableValue(java.lang.String name,
                             java.lang.String value)
Description copied from interface: SSIExternalResolver
Set the named variable to the specified value. If value is null, then the variable will be removed ( ie. a call to getVariableValue will return null )

Specified by:
setVariableValue in interface SSIExternalResolver
Parameters:
name - of the variable
value - of the variable

getVariableValue

public java.lang.String getVariableValue(java.lang.String name)
Specified by:
getVariableValue in interface SSIExternalResolver

getCGIVariable

protected java.lang.String getCGIVariable(java.lang.String name)

getCurrentDate

public java.util.Date getCurrentDate()
Description copied from interface: SSIExternalResolver
Returns the current date. This is useful for putting the SSI stuff in a regression test. Since you can make the current date a constant, it makes testing easier since the output won't change.

Specified by:
getCurrentDate in interface SSIExternalResolver
Returns:
the data

nullToEmptyString

protected java.lang.String nullToEmptyString(java.lang.String string)

getPathWithoutFileName

protected java.lang.String getPathWithoutFileName(java.lang.String servletPath)

getPathWithoutContext

protected java.lang.String getPathWithoutContext(java.lang.String servletPath)

getAbsolutePath

protected java.lang.String getAbsolutePath(java.lang.String path)
                                    throws java.io.IOException
Throws:
java.io.IOException

getServletContextAndPathFromNonVirtualPath

protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromNonVirtualPath(java.lang.String nonVirtualPath)
                                                                                               throws java.io.IOException
Throws:
java.io.IOException

getServletContextAndPathFromVirtualPath

protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromVirtualPath(java.lang.String virtualPath)
                                                                                            throws java.io.IOException
Throws:
java.io.IOException

isRootContext

protected boolean isRootContext(javax.servlet.ServletContext servletContext)

getServletContextAndPath

protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPath(java.lang.String originalPath,
                                                                                    boolean virtual)
                                                                             throws java.io.IOException
Throws:
java.io.IOException

getURLConnection

protected java.net.URLConnection getURLConnection(java.lang.String originalPath,
                                                  boolean virtual)
                                           throws java.io.IOException
Throws:
java.io.IOException

getFileLastModified

public long getFileLastModified(java.lang.String path,
                                boolean virtual)
                         throws java.io.IOException
Specified by:
getFileLastModified in interface SSIExternalResolver
Throws:
java.io.IOException

getFileSize

public long getFileSize(java.lang.String path,
                        boolean virtual)
                 throws java.io.IOException
Specified by:
getFileSize in interface SSIExternalResolver
Throws:
java.io.IOException

getFileText

public java.lang.String getFileText(java.lang.String originalPath,
                                    boolean virtual)
                             throws java.io.IOException
Specified by:
getFileText in interface SSIExternalResolver
Throws:
java.io.IOException


Copyright 2000-2002 Apache Software Foundation. All Rights Reserved.