|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
dods.servlet.DODSServlet
DODSServlet is the base servlet class for all DODS servers. (Well, all DODS servers running as java servlets) Default handlers for all of the acceptable DODS client requests are here.
Each of the request handlers appears as an adjunct method to the doGet() method of the base servlet class. This is an abstract class because it is left to the individual server development efforts to write the getDDS() and getServerVersion() methods. The getDDS() method is intended to be where the server specific DODS server data types are used via their associated class factory. This code relies on thejavax.servlet.ServletConfig
interface (in particular the getInitParameter()
method)
to retrieve the name of a .ini file containing information
about where to find extensive configuration information used by
the servlet. Alternate methods for establishing this functionality
can be arranged by overloading the method loadIniFile()
The servlet should be started in the servlet engine with the following
initParameters set:
For the old jswdk servlet engine:
dts.code=dods.servers.test.dts dts.initparams=iniFilePath=/usr/dods/dts,iniFileName=dts.iniFor the tomcat servlet engine:
<servlet> <servlet-name> dts </servlet-name> <servlet-class> dods.servers.test.dts </servlet-class> <init-param> <param-name>iniFilePath</param-name> <param-value>/usr/dods/dts</param-value> </init-param> <init-param> <param-name>iniFileName</param-name> <param-value>dts.ini</param-value> </init-param> </servlet>Assuming, of course, that the .ini file is located in /usr/dods/dts and is named dts.ini. For example .ini files look in the subdirectory Java-DODS/.ini (where Java-DODS is the top of the distribution). Also, the method
processDodsURL()
could be overloaded
if some kind of special processing of the incoming request is needed
to ascertain the DODS URL information.
processDodsURL(HttpServletRequest)
,
Serialized FormConstructor Summary | |
DODSServlet()
|
Method Summary | |
void |
anyExceptionHandler(java.lang.Throwable e,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Sends an error to the client. |
void |
badURL(javax.servlet.http.HttpServletRequest request,
javax.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... |
void |
dodsExceptionHandler(DODSException de,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Sends a DODS error to the client. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
*********************************************************************** Handles incoming requests from clients. |
void |
doGetASC(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for DODS ascii data requests. |
void |
doGetCatalog(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Default handler for DODS catalog.xml requests. |
void |
doGetDAS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for the client's DAS request. |
void |
doGetDDS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for the client's DDS request. |
void |
doGetDIR(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for the client's directory request. |
void |
doGetDODS(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for the client's data request. |
void |
doGetHELP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Default handler for the client's help request. |
void |
doGetHTML(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for DODS .html requests. |
void |
doGetINFO(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ReqState rs)
************************************************************************ Default handler for DODS info requests. |
void |
doGetStatus(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Default handler for DODS status requests; not publically available, used only for debugging |
void |
doGetVER(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Default handler for the client's version request. |
protected DAS |
getDAS(ReqState rs)
************************************************************************ In this (default) implementation of the getDAS() method a locally cached DAS is retrieved and parsed. |
protected abstract GuardedDataset |
getDataset(ReqState rs)
************************************************************************ This method must be implemented locally for each DODS server. |
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 DODS server. |
void |
init()
************************************************************************ Intitializes the servlet. |
protected boolean |
isTheClientCompressed(javax.servlet.http.HttpServletRequest request)
Deprecated. This method has been encapsulated in the ReqState object and is no longer needed here. |
java.io.DataInputStream |
openCachedDAS(ReqState rs)
************************************************************************ Opens a DAS cached on local disk. |
java.io.DataInputStream |
openCachedDDS(ReqState rs)
************************************************************************ Opens a DDS cached on local disk. |
void |
parseExceptionHandler(ParseException pe,
javax.servlet.http.HttpServletResponse response)
************************************************************************ Turns a ParseException into a DODS error and sends it to the client. |
protected void |
printCatalog(java.io.PrintWriter os)
|
protected void |
printStatus(java.io.PrintWriter os)
|
void |
probeRequest(javax.servlet.http.HttpServletRequest request)
************************************************************************ This is a bit of instrumentation that I kept around to let me look at the state of the incoming HttpServletRequest from the client. |
protected ReqState |
processDodsURL(javax.servlet.http.HttpServletRequest request)
Deprecated. This method has been moved to the ReqState object and is no longer needed here. |
void |
sendDODSError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String clientMsg,
java.lang.String serverMsg)
************************************************************************ Sends a DODS error (type UNKNOWN ERROR) to the client and displays a message on the server console. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DODSServlet()
Method Detail |
public abstract java.lang.String getServerVersion()
protected abstract GuardedDataset getDataset(ReqState rs) throws DODSException, java.io.IOException, ParseException
rs
- The ReqState object for this client request.
DODSException
java.io.IOException
ParseException
ServerDDS
,
sqlServerFactory
,
test_ServerFactory
public void init() throws javax.servlet.ServletException
javax.servlet.ServletException
public void parseExceptionHandler(ParseException pe, javax.servlet.http.HttpServletResponse response)
pe
- The ParseException
that caused the problem.response
- The HttpServletResponse
for the client.public void dodsExceptionHandler(DODSException de, javax.servlet.http.HttpServletResponse response)
de
- The DODS exception that caused the problem.response
- The HttpServletResponse
for the client.public void anyExceptionHandler(java.lang.Throwable e, javax.servlet.http.HttpServletResponse response, ReqState rs)
e
- The exception that caused the problem.response
- The HttpServletResponse
for the client.protected DAS getDAS(ReqState rs) throws DODSException, ParseException
rs
- The ReqState object for this client request.
dataSet
DODSException
ParseException
DAS
public void sendDODSError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String clientMsg, java.lang.String serverMsg) throws java.io.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.
java.io.IOException
javax.servlet.ServletException
public java.io.DataInputStream openCachedDDS(ReqState rs) throws DODSException
This method uses the iniFile
object cached by
loadIniFile()
to determine where to look for the cached
DDS
.
rs
- The ReqState object for this client request.
DataInputStream
from which the DDS can
be read.
DODSException
public java.io.DataInputStream openCachedDAS(ReqState rs) throws java.io.FileNotFoundException
This method uses the iniFile
object cached by
loadIniFile()
to determine where to look for the cached
DDS
.
If the DAS cannot be found an error is sent back to the client.
rs
- The ReqState object for this client request.
DataInputStream
from which the DAS can
be read.
java.io.FileNotFoundException
public void doGetDAS(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
Once the DAS has been parsed it is sent to the requesting client.
request
- The client's HttpServletRequest
request object.response
- The server's HttpServletResponse
response object.rs
- The ReqState object for this client request.
java.io.IOException
javax.servlet.ServletException
public void doGetDDS(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
Once the DDS has been parsed and constrained it is sent to the requesting client.
request
- The client's HttpServletRequest
request object.response
- The server's HttpServletResponse
response
object.rs
- The ReqState object for this client request.
java.io.IOException
javax.servlet.ServletException
public void doGetDODS(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
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.
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.rs
- The ReqState object for this client request.
java.io.IOException
javax.servlet.ServletException
public void doGetDIR(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsDIR
public void doGetVER(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Returns a plain text document with server version and DODS core version #'s
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetHELP(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Returns an html page of help info for the server
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
public void badURL(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
public void doGetASC(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsASCII
public void doGetINFO(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsINFO
public void doGetHTML(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsHTML
public void doGetCatalog(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsHTML
protected void printCatalog(java.io.PrintWriter os) throws java.io.IOException
java.io.IOException
public void doGetStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
dodsHTML
protected void printStatus(java.io.PrintWriter os) throws java.io.IOException
java.io.IOException
public void probeRequest(javax.servlet.http.HttpServletRequest request)
HttpServletRequest
from the client.
This method calls the get*
methods of the request and prints
the results to standard out.
request
- The HttpServletRequest
object to probe.protected boolean isTheClientCompressed(javax.servlet.http.HttpServletRequest request)
request
- The HttpServletRequest
sent by the client
in question.
ReqState
protected ReqState processDodsURL(javax.servlet.http.HttpServletRequest request) throws BadURLException
HttpServletRequest
and from it sets the
cached values for:
setDataSet()
and getDataSet()
) setCE()
and getCE()
) setRequestSuffix()
and getRequestSuffix()
)
request
- The HttpServletRequest
sent by the client
in question.
BadURLException
ReqState
public java.lang.String getServerName()
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
DODSServlet
. It uses
the methods processDodsURL
to extract the DODS URL
information from the incoming client request. This DODS URL information
is cached and made accessible through get and set methods.
After processDodsURL
is called loadIniFile()
is called to load configuration information from a .ini file,
If the standard behaviour of the servlet (extracting the DODS URL
information from the client request, or loading the .ini file) then
you should overload processDodsURL
and loadIniFile()
. We don't recommend overloading doGet()
beacuse
the logic contained there may change in our core and cause your server
to behave unpredictably when future releases are installed.
request
- The client's HttpServletRequest
request
object.response
- The server's HttpServletResponse
response
object.
java.io.IOException
javax.servlet.ServletException
processDodsURL(HttpServletRequest)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |