Class DTSServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
This is the OPeNDAP Test servlet (dts). It allows the owner of the server to deliver data in ANY valid DDS to a client. This DDS will be filled with invented data if the client requests a DataDDS. This kind of test fixture is useful for evaluating a clients ability to handle the various complexities of the OPeNDAP data types.
Configuration:
The AbstractServlet relies on the jakarta.servlet.ServletConfig
interface (in particular the getInitParameter() method)
to retrieve configuration information used by the servlet.
InitParameters:
-
DebugOn - This controls ouput to the terminal from which
the servlet engine was launched. The value is a list of
flags that turn on debugging instrumentation in different
parts of the code. Values are:
- showRequest - Show information about the clients request.
- showResponse - Show information about the servlets response.
- probeRequest - Show an exhaustive amount of information about the clients request object.
- INFOcache - This is should be set to the directory containing the files used by the ".info" service for the servlet. This directory should contain any dataset specific "over-ride" files (see below), any dataset specific additional information files (see below), and any servlet specific information files(see below).
- DDScache - This is should be set to the directory containing the DDS files for the datasets used by the servlet. Some servlets have been developed that do not use DDS's that are cached on the disk, however the default behaviour is for the servlet to load DDS images from disk.
- DAScache - This is should be set to the directory containing the DAS files for the datasets used by the servlet. Some servlets have been developed that do not use DAS's that are cached on the disk, however the default behaviour is for the servlet to load DAS images from disk.
<servlet>
<servlet-name>
dts
</servlet-name>
<servlet-class>
opendap.servers.dts
</servlet-class>
<init-param>
<param-name>DebugOn</param-name>
<param-value>showRequest showResponse </param-value>
</init-param>
<init-param>
<param-name>INFOcache</param-name>
<param-value>/usr/Java-OPeNDAP/sdds-testsuite/info/</param-value>
</init-param>
<init-param>
<param-name>DDScache</param-name>
<param-value>/usr/Java-OPeNDAP/sdds-testsuite/dds/</param-value>
</init-param>
<init-param>
<param-name>DAScache</param-name>
<param-value>/usr/Java-OPeNDAP/sdds-testsuite/das/</param-value>
</init-param>
</servlet>
- See Also:
-
Field Summary
FieldsFields inherited from class opendap.servlet.AbstractServlet
allowDeflate -
Constructor Summary
ConstructorsConstructorDescription************************************************************************ Intitializes the servlet. -
Method Summary
Modifier and TypeMethodDescriptionvoidanyExceptionHandler(Throwable e, opendap.servlet.ReqState rs) Sends an error to the client.voidbadURL(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sends an html document to the client explaining that they have used a poorly formed URL and then the help page...voiddap2ExceptionHandler(opendap.dap.DAP2Exception de, jakarta.servlet.http.HttpServletResponse response) Sends a OPeNDAP DAP2 error to the client.voiddoDebug(opendap.servlet.ReqState rs) Handler for debug requests;protected booleandoDebugCmd(String cmd, StringTokenizer tz, PrintStream pw) voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles incoming requests from clients.voiddoGetASC(opendap.servlet.ReqState rs) Handler for OPeNDAP ascii data requests.voiddoGetBLOB(opendap.servlet.ReqState rs) Handler for the client's data request.voiddoGetCatalog(opendap.servlet.ReqState rs) Handler for OPeNDAP catalog.xml requests.voiddoGetDAP2Data(opendap.servlet.ReqState rs) Handler for the client's data request.voiddoGetDAS(opendap.servlet.ReqState rs) Handler for the client's DAS request.voiddoGetDDS(opendap.servlet.ReqState rs) Handler for the client's DDS request.voiddoGetDDX(opendap.servlet.ReqState rs) Handler for the client's DDX request.voiddoGetDIR(opendap.servlet.ReqState rs) Handler for the client's directory request.voiddoGetHELP(opendap.servlet.ReqState rs) Handler for the client's help request.voiddoGetHTML(opendap.servlet.ReqState rs) Handler for OPeNDAP .html requests.voiddoGetINFO(opendap.servlet.ReqState rs) Handler for OPeNDAP info requests.voiddoGetStatus(opendap.servlet.ReqState rs) Handler for OPeNDAP status requests; not publically available, used only for debuggingvoiddoGetSystemProps(opendap.servlet.ReqState rs) Handler for OPeNDAP status requests; not publically available, used only for debuggingvoiddoGetVER(opendap.servlet.ReqState rs) Handler for the client's version request.protected opendap.servlet.GuardedDatasetgetDataset(opendap.servlet.ReqState rs) ************************************************************************ This method must be implemented locally for each OPeNDAP server.protected opendap.servlet.ReqStategetRequestState(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Getter function for rootpathIn this (default) implementation of the getServerName() method we just get the name of the servlet and pass it back.This method returns a String containing the OPeNDAP Server Version...voidinit()voidIOExceptionHandler(IOException e, opendap.servlet.ReqState rs) Sends an error to the client.voidparseExceptionHandler(opendap.dap.parsers.ParseException pe, jakarta.servlet.http.HttpServletResponse response) Turns a ParseException into a OPeNDAP DAP2 error and sends it to the client.protected voidprintCatalog(opendap.servlet.ReqState rs, PrintWriter os) protected voidvoidprobeRequest(PrintStream ps, opendap.servlet.ReqState rs) This is a bit of instrumentation that I kept around to let me look at the state of the incomingHttpServletRequestfrom the client.voidsendDODSError(opendap.servlet.ReqState rs, String clientMsg, String serverMsg) Sends a OPeNDAP DAP2 error (type UNKNOWN ERROR) to the client and displays a message on the server console.Methods inherited from class opendap.servlet.AbstractServlet
badURL, doDebugCmd, printDODSException, printThrowable, probeRequest, sendDODSError, setLog, setRootpathMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
log
public static org.slf4j.Logger log
-
-
Constructor Details
-
DTSServlet
public DTSServlet()************************************************************************ Intitializes the servlet. Init (at this time) basically sets up the object opendap.util.util.Debug from the debuggery flags in the servlet InitParameters. The Debug object can be referenced (with impunity) from anywhere in the VM.
-
-
Method Details
-
getRootPath
Getter function for rootpath- Returns:
- rootpath
-
getServerVersion
This method returns a String containing the OPeNDAP Server Version...- Specified by:
getServerVersionin classopendap.servlet.AbstractServlet
-
getDataset
protected opendap.servlet.GuardedDataset getDataset(opendap.servlet.ReqState rs) throws opendap.dap.DAP2Exception, IOException, opendap.dap.parsers.ParseException ************************************************************************ This method must be implemented locally for each OPeNDAP server. The local implementation of this method is the key piece for connecting any localized data types that are derived from the opendap.Server types back into the running servlet.This method should do the following:
- Make a new ServerFactory (aka BaseTypeFactory) for the dataset requested.
- Instantiate a ServerDDS using the ServerFactory and populate it (this could be accomplished by just opening a (cached?) DDS in a file and parsing it)
- Return this freshly minted ServerDDS object (to the servlet code where it is used.)
- Specified by:
getDatasetin classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState object for this particular client request.- Returns:
- The ServerDDS object all parsed and ready to roll.
- Throws:
opendap.dap.DAP2ExceptionIOExceptionopendap.dap.parsers.ParseException
-
init
public void init() throws jakarta.servlet.ServletException- Overrides:
initin classjakarta.servlet.GenericServlet- Throws:
jakarta.servlet.ServletException
-
parseExceptionHandler
public void parseExceptionHandler(opendap.dap.parsers.ParseException pe, jakarta.servlet.http.HttpServletResponse response) Turns a ParseException into a OPeNDAP DAP2 error and sends it to the client.- Overrides:
parseExceptionHandlerin classopendap.servlet.AbstractServlet- Parameters:
pe- TheParseExceptionthat caused the problem.response- TheHttpServletResponsefor the client.
-
dap2ExceptionHandler
public void dap2ExceptionHandler(opendap.dap.DAP2Exception de, jakarta.servlet.http.HttpServletResponse response) Sends a OPeNDAP DAP2 error to the client.- Overrides:
dap2ExceptionHandlerin classopendap.servlet.AbstractServlet- Parameters:
de- The OPeNDAP DAP2 exception that caused the problem.response- TheHttpServletResponsefor the client.
-
IOExceptionHandler
Sends an error to the client. fix: The problem is that if the message is already committed when the IOException occurs, the headers dont get set.- Overrides:
IOExceptionHandlerin classopendap.servlet.AbstractServlet- Parameters:
e- The exception that caused the problem.rs- TheReqStatefor the client.
-
anyExceptionHandler
Sends an error to the client.- Overrides:
anyExceptionHandlerin classopendap.servlet.AbstractServlet- Parameters:
e- The exception that caused the problem.rs- TheReqStatefor the client.
-
sendDODSError
public void sendDODSError(opendap.servlet.ReqState rs, String clientMsg, String serverMsg) throws Exception Sends a OPeNDAP DAP2 error (type UNKNOWN ERROR) to the client and displays a message on the server console.- Parameters:
rs- The client'sReqStateobject.clientMsg- Error messageStringto send to the client.serverMsg- Error messageStringto display on the server console.- Throws:
Exception
-
doGetDAS
Handler for the client's DAS request. Operates on the assumption that the DAS information is cached on a disk local to the server. If you don't like that, then you better override it in your server :)Once the DAS has been parsed it is sent to the requesting client.
- Overrides:
doGetDASin classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState of this client request. Contains all kinds of important stuff.- Throws:
Exception- See Also:
-
ReqState
-
doGetDDS
Handler for the client's DDS request. Requires the getDDS() method implemented by each server localization effort.Once the DDS has been parsed and constrained it is sent to the requesting client.
- Overrides:
doGetDDSin classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState of this client request. Contains all kinds of important stuff.- Throws:
Exception- See Also:
-
ReqState
-
doGetDDX
Handler for the client's DDX request. Requires the getDDX() method implemented by each server localization effort.Once the DDX has been parsed and constrained it is sent to the requesting client.
- Overrides:
doGetDDXin classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState of this client request. Contains all kinds of important stuff.- Throws:
Exception- See Also:
-
ReqState
-
doGetBLOB
Handler for the client's data request. Requires the getDDS() method implemented by each server localization effort.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.
- Overrides:
doGetBLOBin classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState of this client request. Contains all kinds of important stuff.- Throws:
Exception- See Also:
-
ReqState
-
doGetDAP2Data
Handler for the client's data request. Requires the getDDS() method implemented by each server localization effort.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.
- Overrides:
doGetDAP2Datain classopendap.servlet.AbstractServlet- Parameters:
rs- The ReqState of this client request. Contains all kinds of important stuff.- Throws:
IOExceptionjakarta.servlet.ServletExceptionException- See Also:
-
ReqState
-
doGetDIR
Handler for the client's directory request.Returns an html document to the client showing (a possibly pseudo) listing of the datasets available on the server in a directory listing format.
The bulk of this code resides in the class opendap.servlet.GetDirHandler and documentation may be found there.
- Overrides:
doGetDIRin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetDirHandler
-
doGetVER
Handler for the client's version request.Returns a plain text document with server version and OPeNDAP core version #'s
- Overrides:
doGetVERin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception
-
doGetHELP
Handler for the client's help request.Returns an html page of help info for the server
- Overrides:
doGetHELPin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception
-
badURL
public void badURL(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception Sends an html document to the client explaining that they have used a poorly formed URL and then the help page...- Parameters:
request- The client'srequestresponse- The clientresponse- Throws:
Exception
-
doGetASC
Handler for OPeNDAP ascii data requests. Returns the request data as a comma delimited ascii file. Note that this means that the more complex OPeNDAP structures such as Grids get flattened...Modified 2/8/07 jcaron to not make a DConnect2 call to itself
- Overrides:
doGetASCin classopendap.servlet.AbstractServlet- Parameters:
rs- the decoded Request State- Throws:
Exception
-
doGetINFO
Handler for OPeNDAP info requests. Returns an HTML document describing the contents of the servers datasets.The bulk of this code resides in the class opendap.servlet.GetInfoHandler and documentation may be found there.
- Overrides:
doGetINFOin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetInfoHandler
-
doGetHTML
Handler for OPeNDAP .html requests. Returns the OPeNDAP Web Interface (aka The Interface From Hell) to the client.The bulk of this code resides in the class opendap.servlet.GetHTMLInterfaceHandler and documentation may be found there.
- Overrides:
doGetHTMLin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetHTMLInterfaceHandler
-
doGetCatalog
Handler for OPeNDAP catalog.xml requests.- Overrides:
doGetCatalogin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetHTMLInterfaceHandler
-
printCatalog
- Overrides:
printCatalogin classopendap.servlet.AbstractServlet- Throws:
IOException
-
doDebug
public void doDebug(opendap.servlet.ReqState rs) Handler for debug requests;- Overrides:
doDebugin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqStateobject.
-
doDebugCmd
-
doGetSystemProps
Handler for OPeNDAP status requests; not publically available, used only for debugging- Overrides:
doGetSystemPropsin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetHTMLInterfaceHandler
-
doGetStatus
Handler for OPeNDAP status requests; not publically available, used only for debugging- Overrides:
doGetStatusin classopendap.servlet.AbstractServlet- Parameters:
rs- The client'sReqState- Throws:
Exception- See Also:
-
GetHTMLInterfaceHandler
-
printStatus
- Overrides:
printStatusin classopendap.servlet.AbstractServlet
-
probeRequest
This is a bit of instrumentation that I kept around to let me look at the state of the incomingHttpServletRequestfrom the client. This method calls theget*methods of the request and prints the results to standard out.- Parameters:
ps- ThePrintStreamto send output.rs- TheReqStateobject to probe.
-
getServerName
In this (default) implementation of the getServerName() method we just get the name of the servlet and pass it back. If something different is required, override this method when implementing the getDDS() and getServerVersion() methods.
This is typically used by the getINFO() method to figure out if there is information specific to this server residing in the info directory that needs to be returned to the client as part of the .info rs.getResponse().
- Overrides:
getServerNamein classopendap.servlet.AbstractServlet- Returns:
- A string containing the name of the servlet class that is running.
-
doGet
public void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles incoming requests from clients. Parses the request and determines what kind of OPeNDAP response the client is requesting. If the request is understood, then the appropriate handler method is called, otherwise an error is returned to the client.This method is the entry point for
DTSServlet.- Overrides:
doGetin classopendap.servlet.AbstractServlet- Parameters:
request- The client'sHttpServletRequestrequest object.response- The server'sHttpServletResponseresponse object.- See Also:
-
ReqState
-
getRequestState
@Nonnull protected opendap.servlet.ReqState getRequestState(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws opendap.dap.DAP2Exception - Overrides:
getRequestStatein classopendap.servlet.AbstractServlet- Parameters:
request-- Returns:
- the request state
- Throws:
opendap.dap.DAP2Exception
-