org.apache.catalina.ssi

## Class SSIServletExternalResolver

- java.lang.Object
- - org.apache.catalina.ssi.SSIServletExternalResolver

All Implemented Interfaces:
  SSIExternalResolver

    public class SSIServletExternalResolver
    extends Object
    implements SSIExternalResolver

An implementation of SSIExternalResolver that is used with servlets.

Author:
  Dan Sandberg, David Becker

### Nested Class Summary

Nested Classes
`protected static class` `SSIServletExternalResolver.ServletContextAndPath`

### Field Summary

Fields
`protected ServletContext` `context`
`protected int` `debug`
`protected String` `inputEncoding`
`protected boolean` `isVirtualWebappRelative`
`protected HttpServletRequest` `req`
`protected HttpServletResponse` `res`
`protected String[]` `VARIABLE_NAMES`

### Constructor Summary

Constructors
Constructor and Description
`SSIServletExternalResolver(ServletContext context, HttpServletRequest req, HttpServletResponse res, boolean isVirtualWebappRelative, int debug, String inputEncoding)`

### Method Summary

Methods
`void` `addVariableNames(Collection<String> variableNames)` Adds any external variables to the variableNames collection.
`protected String` `getAbsolutePath(String path)`
`protected String` `getCGIVariable(String name)`
`Date` `getCurrentDate()` Returns the current date.
`long` `getFileLastModified(String path, boolean virtual)`
`long` `getFileSize(String path, boolean virtual)`
`String` `getFileText(String originalPath, boolean virtual)`
`protected String` `getPathWithoutContext(String contextPath, String servletPath)`
`protected String` `getPathWithoutFileName(String servletPath)`
`protected Object` `getReqAttributeIgnoreCase(String targetName)`
`protected SSIServletExternalResolver.ServletContextAndPath` `getServletContextAndPath(String originalPath, boolean virtual)`
`protected SSIServletExternalResolver.ServletContextAndPath` `getServletContextAndPathFromNonVirtualPath(String nonVirtualPath)`
`protected SSIServletExternalResolver.ServletContextAndPath` `getServletContextAndPathFromVirtualPath(String virtualPath)`
`protected URLConnection` `getURLConnection(String originalPath, boolean virtual)`
`String` `getVariableValue(String name)`
`protected boolean` `isNameReserved(String name)`
`protected boolean` `isRootContext(ServletContext servletContext)`
`void` `log(String message, Throwable throwable)`
`protected String` `nullToEmptyString(String string)`
`void` `setVariableValue(String name, 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 String[] VARIABLE_NAMES

#### context

    protected ServletContext context

#### req

    protected HttpServletRequest req

#### res

    protected HttpServletResponse res

#### isVirtualWebappRelative

    protected boolean isVirtualWebappRelative

#### debug

    protected int debug

#### inputEncoding

    protected String inputEncoding

### Constructor Detail

#### SSIServletExternalResolver

    public SSIServletExternalResolver(ServletContext context,
                              HttpServletRequest req,
                              HttpServletResponse res,
                              boolean isVirtualWebappRelative,
                              int debug,
                              String inputEncoding)

### Method Detail

#### log

    public void log(String message,
           Throwable throwable)

Specified by:
  `log` in interface `SSIExternalResolver`

#### addVariableNames

    public void addVariableNames(Collection<String> 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 Object getReqAttributeIgnoreCase(String targetName)

#### isNameReserved

    protected boolean isNameReserved(String name)

#### setVariableValue

    public void setVariableValue(String name,
                        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 String getVariableValue(String name)

Specified by:
  `getVariableValue` in interface `SSIExternalResolver`

#### getCGIVariable

    protected String getCGIVariable(String name)

#### getCurrentDate

    public 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 String nullToEmptyString(String string)

#### getPathWithoutFileName

    protected String getPathWithoutFileName(String servletPath)

#### getPathWithoutContext

    protected String getPathWithoutContext(String contextPath,
                               String servletPath)

#### getAbsolutePath

    protected String getAbsolutePath(String path)
                              throws IOException

Throws:
  `IOException`

#### getServletContextAndPathFromNonVirtualPath

    protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromNonVirtualPath(String nonVirtualPath)
                                                                                                   throws IOException

Throws:
  `IOException`

#### getServletContextAndPathFromVirtualPath

    protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPathFromVirtualPath(String virtualPath)
                                                                                                throws IOException

Throws:
  `IOException`

#### isRootContext

    protected boolean isRootContext(ServletContext servletContext)

#### getServletContextAndPath

    protected SSIServletExternalResolver.ServletContextAndPath getServletContextAndPath(String originalPath,
                                                                            boolean virtual)
                                                                                 throws IOException

Throws:
  `IOException`

#### getURLConnection

    protected URLConnection getURLConnection(String originalPath,
                                 boolean virtual)
                                      throws IOException

Throws:
  `IOException`

#### getFileLastModified

    public long getFileLastModified(String path,
                           boolean virtual)
                             throws IOException

Specified by:
  `getFileLastModified` in interface `SSIExternalResolver`
Throws:
  `IOException`

#### getFileSize

    public long getFileSize(String path,
                   boolean virtual)
                     throws IOException

Specified by:
  `getFileSize` in interface `SSIExternalResolver`
Throws:
  `IOException`

#### getFileText

    public String getFileText(String originalPath,
                     boolean virtual)
                       throws IOException

Specified by:
  `getFileText` in interface `SSIExternalResolver`
Throws:
  `IOException`