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 |
static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
AbstractServlet() |
| Modifier and Type | Method and Description |
|---|---|
void |
anyExceptionHandler(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(opendap.dap.DAP2Exception de,
javax.servlet.http.HttpServletResponse response)
Sends a OPeNDAP DAP2 error to the client.
|
void |
doDebug(ReqState rs)
Default handler for debug requests;
|
protected boolean |
doDebugCmd(String cmd,
StringTokenizer tz,
PrintWriter pw) |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.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(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
String |
getServerName()
In this (default) implementation of the getServerName() method we just get
the name of the servlet and pass it back.
|
abstract String |
getServerVersion()
This function must be implemented locally for each OPeNDAP server.
|
void |
IOExceptionHandler(IOException e,
ReqState rs)
Sends an error to the client.
|
protected static void |
parseConstraint(CEEvaluator ce,
ReqState rs) |
void |
parseExceptionHandler(opendap.dap.parsers.ParseException pe,
javax.servlet.http.HttpServletResponse response)
Turns a ParseException into a OPeNDAP DAP2 error and sends it to the client.
|
protected void |
printBadURLPage(PrintWriter pw)
Prints the Bad URL Page page to the passed PrintWriter
|
protected void |
printCatalog(ReqState rs,
PrintWriter os) |
protected void |
printStatus(PrintWriter os) |
static void |
printThrowable(Throwable t) |
void |
probeRequest(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(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String clientMsg,
String serverMsg)
Sends a OPeNDAP DAP2 error (type UNKNOWN ERROR) to the client and displays a
message on the server console.
|
static void |
setLog(Class<?> cl) |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, servicepublic static void setLog(Class<?> cl)
public static void printThrowable(Throwable t)
public abstract String getServerVersion()
protected abstract GuardedDataset getDataset(ReqState rs) throws Exception
rs - The ReqState object for this particular client request.Exceptionpublic void parseExceptionHandler(opendap.dap.parsers.ParseException pe,
javax.servlet.http.HttpServletResponse response)
pe - The ParseException that caused the problem.response - The HttpServletResponse for the client.public void dap2ExceptionHandler(opendap.dap.DAP2Exception de,
javax.servlet.http.HttpServletResponse response)
de - The OPeNDAP DAP2 exception that caused the problem.response - The HttpServletResponse for the client.public void IOExceptionHandler(IOException e, ReqState rs)
e - The exception that caused the problem.rs - The ReqState for the client.public void anyExceptionHandler(Throwable e, ReqState rs)
e - The exception that caused the problem.rs - The ReqState for the client.public void sendDODSError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String clientMsg,
String serverMsg)
throws IOException,
javax.servlet.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.IOExceptionjavax.servlet.ServletExceptionpublic void doGetDAS(ReqState rs) throws Exception
Once the DAS has been parsed it is sent to the requesting client.
public void doGetDDS(ReqState rs) throws Exception
Once the DDS has been parsed and constrained it is sent to the requesting client.
public void doGetDDX(ReqState rs) throws Exception
Once the DDS has been parsed and constrained it is sent to the requesting client.
protected static void parseConstraint(CEEvaluator ce, ReqState rs) throws opendap.dap.parsers.ParseException, opendap.dap.DAP2Exception
opendap.dap.parsers.ParseExceptionopendap.dap.DAP2Exceptionpublic void doGetBLOB(ReqState rs) throws 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.
public void doGetDAP2Data(ReqState rs) throws 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.Exceptionpublic void doGetDIR(ReqState rs) throws Exception
rs - The client's ReqStateExceptionGetDirHandlerpublic void doGetVER(ReqState rs) throws Exception
Returns a plain text document with server version and OPeNDAP core version #'s
rs - The client's ReqStateExceptionpublic void doGetHELP(ReqState rs) throws Exception
rs - The client's ReqState Exceptionpublic void badURL(ReqState rs) throws Exception
rs - The client's ReqState Exceptionpublic void doGetASC(ReqState rs) throws Exception
rs - the decoded Request StateExceptionpublic void doGetINFO(ReqState rs) throws Exception
rs - The client's ReqState ExceptionGetInfoHandlerpublic void doGetHTML(ReqState rs) throws Exception
rs - The client's ReqStateExceptionGetHTMLInterfaceHandlerpublic void doGetCatalog(ReqState rs) throws Exception
rs - The client's ReqState ExceptionGetHTMLInterfaceHandlerprotected void printCatalog(ReqState rs, PrintWriter os) throws IOException
IOExceptionpublic void doDebug(ReqState rs) throws IOException
rs - The client's ReqState object.IOExceptionprotected boolean doDebugCmd(String cmd, StringTokenizer tz, PrintWriter pw)
public void doGetSystemProps(ReqState rs) throws Exception
rs - The client's ReqState ExceptionGetHTMLInterfaceHandlerpublic void doGetStatus(ReqState rs) throws Exception
rs - The client's ReqStateExceptionGetHTMLInterfaceHandlerprotected void printStatus(PrintWriter os) throws IOException
IOExceptionpublic void probeRequest(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 String getServerName()
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
AbstractServlet.doGet in class javax.servlet.http.HttpServletrequest - The client's HttpServletRequest request object.response - The server's HttpServletResponse response object.ReqStateprotected ReqState getRequestState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws opendap.dap.DAP2Exception
request - opendap.dap.DAP2Exceptionprotected void printBadURLPage(PrintWriter pw)
pw - PrintWriter stream to which to dump the bad URL page.