Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.drda
Class NetServlet  view NetServlet download NetServlet.java

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.apache.derby.drda.NetServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class NetServlet
extends javax.servlet.http.HttpServlet

This servlet can be used to start Derby Network Server from a remote location.

These servlet configuration parameters are understood by this servlet.


Field Summary
private  java.lang.String formHeader
           
private  java.lang.String host
           
private static int INVALID
           
private  java.lang.String[] knownLang
           
private  java.lang.String locale
           
private  boolean logStatus
           
private static int MAX_CONNECT_TRYS
           
private static int NOT_GIVEN
           
private  java.io.PrintWriter out
           
private  int portNumber
           
private  NetworkServerControl server
           
private  java.lang.Runnable service
           
private static java.lang.String SERVLET_ADDRESS
           
private static java.lang.String SERVLET_PROP_MESSAGES
           
private  boolean traceStatus
           
private  java.lang.String tracingDirectory
           
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
NetServlet()
           
 
Method Summary
private  void displayCurrentStatus(javax.servlet.http.HttpServletRequest request, org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, java.lang.String returnMessage)
          Display the current Network server status
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Get the form of NetServlet.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Get the form of NetServlet.
private  java.lang.String escapeSingleQuotes(java.lang.String str)
          If the received string has one or more single quotes in it, replace each one with the HTML escape-code for a single quote (apostrophe) so that the string can be properly displayed on a submit button.
private  org.apache.derby.iapi.tools.i18n.LocalizedResource getCurrentAppUI(javax.servlet.http.HttpServletRequest request)
          Determine the locale file needed for this browsers preferences Defaults to the settings for db2j.locale and db2j.codeset if set English otherwise if browsers preferences can't be found
private  java.lang.String getDoAction(javax.servlet.http.HttpServletRequest request)
           
private  java.lang.String getForm(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getHtmlLabelledMessageInstance(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, java.lang.String key, java.lang.String id)
          get an HTML labelled message from the resource bundle file, according to the given key.
private  int getIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String fieldKey, org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, java.lang.String returnMessage)
          Get an integer parameter
private  java.lang.String getLocStringFromLanguage(java.lang.String lang)
          Get locale string from language which may have qvalue set
private  java.lang.String getLogging(javax.servlet.http.HttpServletRequest request)
           
private  java.lang.String getParam(javax.servlet.http.HttpServletRequest request, java.lang.String paramName)
          get UTF8 parameter value and decode international characters
private  boolean getServerStatus()
          Get the currrent server status by using test connection
private  java.lang.String getTrace(javax.servlet.http.HttpServletRequest request)
           
 void init(javax.servlet.ServletConfig config)
          Initialize the servlet.
private static boolean isServerStarted(NetworkServerControl server, int ntries)
           
private  boolean logging(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, boolean val, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Turn logging of connections on
private  void printAsContentHeader(java.lang.String str)
          Print the received string as a header.
private  void printBanner(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil)
          Print Derby Network Server banner
private  void printErrorForm(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, javax.servlet.http.HttpServletRequest request, java.lang.Exception e, java.lang.String returnMessage)
          Display an error form
private  void printErrorForm(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, javax.servlet.http.HttpServletRequest request, java.lang.String msg, java.lang.String returnMessage)
          Display an error form
private  void runServer(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Start the network server and attempt to connect to it before returning
private  void setDefaults()
          Set defaults for logging and tracing (both off)
private  boolean setNetParam(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, int max, int slice, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Set Network server parameters
private  boolean shutdownServer(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Shutdown the network server
private  boolean traceAll(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, boolean val, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Change tracing for all sessions
private  boolean traceDirectory(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, java.lang.String traceDirectory, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Set trace directory
private  boolean traceSession(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil, boolean val, int session, javax.servlet.http.HttpServletRequest request, java.lang.String returnMessage)
          Change tracing for a given session
private  int translationAvailable(java.lang.String lang)
          Check if the required translation is available
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, 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
 

Field Detail

MAX_CONNECT_TRYS

private static final int MAX_CONNECT_TRYS
See Also:
Constant Field Values

SERVLET_PROP_MESSAGES

private static final java.lang.String SERVLET_PROP_MESSAGES
See Also:
Constant Field Values

SERVLET_ADDRESS

private static final java.lang.String SERVLET_ADDRESS
See Also:
Constant Field Values

formHeader

private java.lang.String formHeader

host

private java.lang.String host

portNumber

private int portNumber

tracingDirectory

private java.lang.String tracingDirectory

logStatus

private boolean logStatus

traceStatus

private boolean traceStatus

knownLang

private java.lang.String[] knownLang

locale

private java.lang.String locale

NOT_GIVEN

private static final int NOT_GIVEN
See Also:
Constant Field Values

INVALID

private static final int INVALID
See Also:
Constant Field Values

server

private NetworkServerControl server

out

private java.io.PrintWriter out

service

private java.lang.Runnable service
Constructor Detail

NetServlet

public NetServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize the servlet. Configuration parameters:
  • portNumber
    - Port number
  • traceDirectory
    - location of trace directory
  • startNetworkServerOnInit
    - start the server on initialization


doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Get the form of NetServlet. Provides buttons and forms to control the Network server.


doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Get the form of NetServlet. Provides a buttons and form to control the Network server


getForm

private java.lang.String getForm(javax.servlet.http.HttpServletRequest request)
                          throws java.io.IOException

getDoAction

private java.lang.String getDoAction(javax.servlet.http.HttpServletRequest request)
                              throws java.io.IOException

getLogging

private java.lang.String getLogging(javax.servlet.http.HttpServletRequest request)
                             throws java.io.IOException

getTrace

private java.lang.String getTrace(javax.servlet.http.HttpServletRequest request)
                           throws java.io.IOException

getParam

private java.lang.String getParam(javax.servlet.http.HttpServletRequest request,
                                  java.lang.String paramName)
                           throws java.io.IOException
get UTF8 parameter value and decode international characters


runServer

private void runServer(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                       javax.servlet.http.HttpServletRequest request,
                       java.lang.String returnMessage)
                throws javax.servlet.ServletException
Start the network server and attempt to connect to it before returning


printErrorForm

private void printErrorForm(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                            javax.servlet.http.HttpServletRequest request,
                            java.lang.Exception e,
                            java.lang.String returnMessage)
Display an error form


printErrorForm

private void printErrorForm(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                            javax.servlet.http.HttpServletRequest request,
                            java.lang.String msg,
                            java.lang.String returnMessage)
Display an error form


displayCurrentStatus

private void displayCurrentStatus(javax.servlet.http.HttpServletRequest request,
                                  org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                                  java.lang.String returnMessage)
Display the current Network server status


getServerStatus

private boolean getServerStatus()
Get the currrent server status by using test connection


shutdownServer

private boolean shutdownServer(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                               javax.servlet.http.HttpServletRequest request,
                               java.lang.String returnMessage)
Shutdown the network server


logging

private boolean logging(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                        boolean val,
                        javax.servlet.http.HttpServletRequest request,
                        java.lang.String returnMessage)
Turn logging of connections on


traceAll

private boolean traceAll(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                         boolean val,
                         javax.servlet.http.HttpServletRequest request,
                         java.lang.String returnMessage)
Change tracing for all sessions


traceSession

private boolean traceSession(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                             boolean val,
                             int session,
                             javax.servlet.http.HttpServletRequest request,
                             java.lang.String returnMessage)
Change tracing for a given session


traceDirectory

private boolean traceDirectory(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                               java.lang.String traceDirectory,
                               javax.servlet.http.HttpServletRequest request,
                               java.lang.String returnMessage)
Set trace directory


setNetParam

private boolean setNetParam(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                            int max,
                            int slice,
                            javax.servlet.http.HttpServletRequest request,
                            java.lang.String returnMessage)
Set Network server parameters


setDefaults

private void setDefaults()
Set defaults for logging and tracing (both off)


getIntParameter

private int getIntParameter(javax.servlet.http.HttpServletRequest request,
                            java.lang.String name,
                            java.lang.String fieldKey,
                            org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                            java.lang.String returnMessage)
Get an integer parameter


printBanner

private void printBanner(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil)
Print Derby Network Server banner


getCurrentAppUI

private org.apache.derby.iapi.tools.i18n.LocalizedResource getCurrentAppUI(javax.servlet.http.HttpServletRequest request)
Determine the locale file needed for this browsers preferences Defaults to the settings for db2j.locale and db2j.codeset if set English otherwise if browsers preferences can't be found


getLocStringFromLanguage

private java.lang.String getLocStringFromLanguage(java.lang.String lang)
Get locale string from language which may have qvalue set


translationAvailable

private int translationAvailable(java.lang.String lang)
Check if the required translation is available


getHtmlLabelledMessageInstance

public java.lang.String getHtmlLabelledMessageInstance(org.apache.derby.iapi.tools.i18n.LocalizedResource localUtil,
                                                       java.lang.String key,
                                                       java.lang.String id)
get an HTML labelled message from the resource bundle file, according to the given key.


printAsContentHeader

private void printAsContentHeader(java.lang.String str)
Print the received string as a header.


escapeSingleQuotes

private java.lang.String escapeSingleQuotes(java.lang.String str)
If the received string has one or more single quotes in it, replace each one with the HTML escape-code for a single quote (apostrophe) so that the string can be properly displayed on a submit button.


isServerStarted

private static boolean isServerStarted(NetworkServerControl server,
                                       int ntries)