public abstract class AbstractServlet
extends javax.servlet.http.HttpServlet
javax.servlet.ServletConfig
interface (in particular the getInitParameter()
method)
to record detailed configuration information used by
the servlet and it's children.
The servlet should be started in the servlet engine with the following
initParameters for the tomcat servlet engine:
<servlet> <servlet-name> dts </servlet-name> <servlet-class> opendap.servers.test.dts </servlet-class> <init-param> <param-name>INFOcache</param-name> <param-value>/home/Datasets/info</param-value> </init-param> <init-param> <param-name>DDScache</param-name> <param-value>/home/Datasets/dds</param-value> </init-param> <init-param> <param-name>DAScache</param-name> <param-value>/home/Datasets/das</param-value> </init-param> <init-param> <param-name>DDXcache</param-name> <param-value>/home/Datasets/ddx</param-value> </init-param> </servlet>Obviously the actual values of these parameters will depend on your particular file system.
processDodsURL()
could be overloaded
if some kind of special processing of the incoming request is needed
to ascertain the OPeNDAP URL information.Modifier and Type | Field and Description |
---|---|
protected boolean |
allowDeflate
************************************************************************
Compression
|
static org.slf4j.Logger |
log |
Constructor and Description |
---|
AbstractServlet() |
Modifier and Type | Method and Description |
---|---|
void |
anyExceptionHandler(java.lang.Throwable e,
ReqState rs)
************************************************************************
Sends an error to the client.
|
void |
badURL(ReqState rs)
************************************************************************
Sends an html document to the client explaining that they have used a
poorly formed URL and then the help page...
|
void |
dap2ExceptionHandler(DAP2Exception de,
HttpServletResponse response)
************************************************************************
Sends a OPeNDAP DAP2 error to the client.
|
void |
doDebug(ReqState rs)
************************************************************************
Default handler for debug requests;
|
protected boolean |
doDebugCmd(java.lang.String cmd,
java.util.StringTokenizer tz,
java.io.PrintWriter pw) |
void |
doGet(HttpServletRequest request,
HttpServletResponse response)
***********************************************************************
Handles incoming requests from clients.
|
void |
doGetASC(ReqState rs)
************************************************************************
Default handler for OPeNDAP ascii data requests.
|
void |
doGetBLOB(ReqState rs)
************************************************************************
Default handler for the client's data request.
|
void |
doGetCatalog(ReqState rs)
************************************************************************
Default handler for OPeNDAP catalog.xml requests.
|
void |
doGetDAP2Data(ReqState rs)
************************************************************************
Default handler for the client's data request.
|
void |
doGetDAS(ReqState rs)
************************************************************************
Default handler for the client's DAS request.
|
void |
doGetDDS(ReqState rs)
************************************************************************
Default handler for the client's DDS request.
|
void |
doGetDDX(ReqState rs)
************************************************************************
Default handler for the client's DDS request.
|
void |
doGetDIR(ReqState rs)
************************************************************************
Default handler for the client's directory request.
|
void |
doGetHELP(ReqState rs)
************************************************************************
Default handler for the client's help request.
|
void |
doGetHTML(ReqState rs)
************************************************************************
Default handler for OPeNDAP .html requests.
|
void |
doGetINFO(ReqState rs)
************************************************************************
Default handler for OPeNDAP info requests.
|
void |
doGetStatus(ReqState rs)
************************************************************************
Default handler for OPeNDAP status requests; not publically available,
used only for debugging
|
void |
doGetSystemProps(ReqState rs)
************************************************************************
Default handler for OPeNDAP status requests; not publically available,
used only for debugging
|
void |
doGetVER(ReqState rs)
************************************************************************
Default handler for the client's version request.
|
protected abstract GuardedDataset |
getDataset(ReqState rs)
************************************************************************
This method must be implemented locally for each OPeNDAP server.
|
protected ReqState |
getRequestState(HttpServletRequest request,
HttpServletResponse response) |
java.lang.String |
getRootPath()
Getter function for rootpath
|
java.lang.String |
getServerName()
************************************************************************
In this (default) implementation of the getServerName() method we just get
the name of the servlet and pass it back.
|
abstract java.lang.String |
getServerVersion()
This function must be implemented locally for each OPeNDAP server.
|
void |
init()
************************************************************************
Intitializes the servlet.
|
void |
IOExceptionHandler(java.io.IOException e,
ReqState rs)
************************************************************************
Sends an error to the client.
|
void |
parseExceptionHandler(ParseException pe,
HttpServletResponse response)
************************************************************************
Turns a ParseException into a OPeNDAP DAP2 error and sends it to the client.
|
protected void |
printCatalog(ReqState rs,
java.io.PrintWriter os) |
static void |
printDODSException(DAP2Exception de) |
protected void |
printStatus(java.io.PrintWriter os) |
static void |
printThrowable(java.lang.Throwable t) |
void |
probeRequest(java.io.PrintWriter ps,
ReqState rs)
************************************************************************
This is a bit of instrumentation that I kept around to let me look at the
state of the incoming
HttpServletRequest from the client. |
void |
sendDODSError(HttpServletRequest request,
HttpServletResponse response,
java.lang.String clientMsg,
java.lang.String serverMsg)
************************************************************************
Sends a OPeNDAP DAP2 error (type UNKNOWN ERROR) to the client and displays a
message on the server console.
|
static void |
setLog(java.lang.Class cl) |
public static org.slf4j.Logger log
protected boolean allowDeflate
public static void setLog(java.lang.Class cl)
public static void printDODSException(DAP2Exception de)
public static void printThrowable(java.lang.Throwable t)
public java.lang.String getRootPath()
public abstract java.lang.String getServerVersion()
protected abstract GuardedDataset getDataset(ReqState rs) throws java.lang.Exception
rs
- The ReqState object for this particular client request.DAP2Exception
java.io.IOException
ParseException
java.lang.Exception
ServerDDS
public void init() throws ServletException
ServletException
public void parseExceptionHandler(ParseException pe, HttpServletResponse response)
pe
- The ParseException
that caused the problem.response
- The HttpServletResponse
for the client.public void dap2ExceptionHandler(DAP2Exception de, HttpServletResponse response)
de
- The OPeNDAP DAP2 exception that caused the problem.response
- The HttpServletResponse
for the client.public void IOExceptionHandler(java.io.IOException e, ReqState rs)
e
- The exception that caused the problem.rs
- The ReqState
for the client.public void anyExceptionHandler(java.lang.Throwable e, ReqState rs)
e
- The exception that caused the problem.rs
- The ReqState
for the client.public void sendDODSError(HttpServletRequest request, HttpServletResponse response, java.lang.String clientMsg, java.lang.String serverMsg) throws java.io.IOException, ServletException
request
- The client's HttpServletRequest
request object.response
- The server's HttpServletResponse
response object.clientMsg
- Error message String
to send to the client.serverMsg
- Error message String
to display on the server console.java.io.IOException
ServletException
public void doGetDAS(ReqState rs) throws java.lang.Exception
Once the DAS has been parsed it is sent to the requesting client.
rs
- The ReqState of this client request. Contains all kinds of
important stuff.java.lang.Exception
ReqState
public void doGetDDS(ReqState rs) throws java.lang.Exception
Once the DDS has been parsed and constrained it is sent to the requesting client.
rs
- The ReqState of this client request. Contains all kinds of
important stuff.java.lang.Exception
ReqState
public void doGetDDX(ReqState rs) throws java.lang.Exception
Once the DDS has been parsed and constrained it is sent to the requesting client.
rs
- The ReqState of this client request. Contains all kinds of
important stuff.java.lang.Exception
ReqState
public void doGetBLOB(ReqState rs) throws java.lang.Exception
Once the DDS has been parsed, the data is read (using the class in the localized server factory etc.), compared to the constraint expression, and then sent to the client.
rs
- The ReqState of this client request. Contains all kinds of
important stuff.java.lang.Exception
ReqState
public void doGetDAP2Data(ReqState rs) throws java.lang.Exception
Once the DDS has been parsed, the data is read (using the class in the localized server factory etc.), compared to the constraint expression, and then sent to the client.
rs
- The ReqState of this client request. Contains all kinds of
important stuff.java.io.IOException
ServletException
java.lang.Exception
ReqState
public void doGetDIR(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetDirHandler
public void doGetVER(ReqState rs) throws java.lang.Exception
Returns a plain text document with server version and OPeNDAP core version #'s
rs
- The client's ReqState
java.lang.Exception
public void doGetHELP(ReqState rs) throws java.lang.Exception
Returns an html page of help info for the server
rs
- The client's ReqState
java.lang.Exception
public void badURL(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
public void doGetASC(ReqState rs) throws java.lang.Exception
rs
- the decoded Request Statejava.lang.Exception
public void doGetINFO(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetInfoHandler
public void doGetHTML(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetHTMLInterfaceHandler
public void doGetCatalog(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetHTMLInterfaceHandler
protected void printCatalog(ReqState rs, java.io.PrintWriter os) throws java.io.IOException
java.io.IOException
public void doDebug(ReqState rs) throws java.io.IOException
rs
- The client's ReqState
object.java.io.IOException
protected boolean doDebugCmd(java.lang.String cmd, java.util.StringTokenizer tz, java.io.PrintWriter pw)
public void doGetSystemProps(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetHTMLInterfaceHandler
public void doGetStatus(ReqState rs) throws java.lang.Exception
rs
- The client's ReqState
java.lang.Exception
GetHTMLInterfaceHandler
protected void printStatus(java.io.PrintWriter os) throws java.io.IOException
java.io.IOException
public void probeRequest(java.io.PrintWriter ps, ReqState rs)
HttpServletRequest
from the client.
This method calls the get*
methods of the request and prints
the results to standard out.ps
- The PrintStream
to send output.rs
- The ReqState
object to probe.public java.lang.String getServerName()
public void doGet(HttpServletRequest request, HttpServletResponse response)
AbstractServlet
.request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.ReqState
protected ReqState getRequestState(HttpServletRequest request, HttpServletResponse response) throws DAP2Exception
request
- DAP2Exception