String traceDirMessage;
String contMessage;
String setParamMessage;
String setParamMessage2;
String netParamMessage;
LocalizedResource langUtil;
langUtil = getCurrentAppUI(request);
response.setContentType("text/html; charset=UTF-8");
//prevent caching of the servlet since contents can change - beetle 4649
response.setHeader("Cache-Control", "no-cache,no-store");
formHeader = "<form enctype='multipart/form-data; charset=UTF-8' action='" +
request.getRequestURI() +" '>";
out = new PrintWriter(new
OutputStreamWriter(response.getOutputStream(), "UTF8"),true);
//inialize messages
logOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOn"));
logOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_LogOff"));
traceOnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOn"));
traceOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOff"));
startMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Start"));
stopMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Stop"));
traceSessionMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceSessButton"));
traceOnOffMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceOnOff"));
returnMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Return"));
traceDirMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_TraceDir"));
contMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_Continue"));
setParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam"));
setParamMessage2 = escapeSingleQuotes(langUtil.getTextMessage("SRV_SetParam2"));
netParamMessage = escapeSingleQuotes(langUtil.getTextMessage("SRV_NetParam"));
printBanner(langUtil);
// set up a server we can use
if (server == null) {
try {
server = new NetworkServerControl();
}catch (Exception e) {
printErrorForm(langUtil, request, e, returnMessage);
return;
}
}
server.setClientLocale(locale);
String form = getForm(request);
String doAction = getDoAction(request);
// if doAction is set, use it to determine form
if (doAction != null )
{
if (doAction.equals(traceOnOffMessage))
form = traceSessionMessage;
else
form = doAction;
}
// if no form, determine form based on server status
boolean serverStatus = getServerStatus();
if (form == null)
{
if (serverStatus)
form = startMessage;
else
form = stopMessage;
}
else if (form.equals(startMessage))
{
if (!serverStatus) {
runServer(langUtil, request, returnMessage);
}
}
else if (form.equals(stopMessage))
{
if (serverStatus) {
shutdownServer(langUtil, request, returnMessage);
}
setDefaults();
}
else if (form.equals(returnMessage) || form.equals(returnMessage))
{
// check if server is still running and use that to determine which form
if (serverStatus)
{
form = startMessage;
}
else
{
form = stopMessage;
}
}
out.println( formHeader);
// display forms
form = escapeSingleQuotes(form);
doAction = escapeSingleQuotes(doAction);
if (form.equals(startMessage))
{
String logButton = getLogging(request);
String traceButton = getTrace(request);
if (logButton != null && logButton.equals(logOnMessage))
{
if (logging(langUtil, true, request, returnMessage))
logStatus = true;
}
if (logButton != null && logButton.equals(logOffMessage))
{
if (logging(langUtil, false, request, returnMessage))
logStatus = false;
}
if (traceButton != null && traceButton.equals(traceOnMessage))
{
if (traceAll(langUtil, true, request, returnMessage))
traceStatus = true;
}
if (traceButton != null && traceButton.equals(traceOffMessage))
{
if (traceAll(langUtil, false, request, returnMessage))
traceStatus = false;
}
displayCurrentStatus(request, langUtil, returnMessage);
out.println( "<h4>"+langUtil.getTextMessage("SRV_StopButton")+"</h4>" );
out.println( "<INPUT type=submit name=form value='"+ stopMessage + "'>" );
out.println( "<h4>"+langUtil.getTextMessage("SRV_LogButton2")+"</h4>" );
if (logStatus)
{
out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
}
else
{
out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
}
out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceButton2")+"</h4>" );
if (traceStatus)
{
out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage+ "'>" );
}
else
{
out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
}
out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceSession")+"</h4>" );
out.println( "<INPUT type=submit name=form value='"+ traceSessionMessage + "'>" );
out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceDirButton")+"</h4>" );
out.println( "<INPUT type=submit name=form value='"+ traceDirMessage + "'>" );
out.println( "<h4>"+langUtil.getTextMessage("SRV_ThreadButton")+"</h4>" );
out.println( "<INPUT type=submit name=form value='"+ netParamMessage+ "'>" );
}
else if (form.equals(stopMessage))
{
printAsContentHeader(langUtil.getTextMessage("SRV_NotStarted"));
String logButton = getLogging(request);
String traceButton = getTrace(request);
if (logButton != null && logButton.equals(logOnMessage))
logStatus = true;
if (logButton != null && logButton.equals(logOffMessage))
logStatus = false;
if (traceButton != null && traceButton.equals(traceOnMessage))
traceStatus = true;
if (traceButton != null && traceButton.equals(traceOffMessage))
traceStatus = false;
if (logStatus)
{
out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOffButton")+"</h4>" );
out.println( "<INPUT type=submit name=logform value='"+logOffMessage + "'>" );
}
else
{
out.println( "<h4>"+langUtil.getTextMessage("SRV_LogOnButton")+"</h4>" );
out.println( "<INPUT type=submit name=logform value='"+logOnMessage + "'>" );
}
if (traceStatus)
{
out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOffButton")+"</h4>" );
out.println( "<INPUT type=submit name=traceform value='"+traceOffMessage + "'>" );
}
else
{
out.println( "<h4>"+langUtil.getTextMessage("SRV_TraceOnButton")+"</h4>" );
out.println( "<INPUT type=submit name=traceform value='"+traceOnMessage + "'>" );
}
out.println( "<h4>"+langUtil.getTextMessage("SRV_StartButton")+"</h4>" );
out.println( "<INPUT type=submit name=form value='"+startMessage+ "'>" );
}
else if (form.equals(traceSessionMessage))
{
if (doAction != null)
{
if (doAction.equals(traceOnOffMessage))
{
String sessionid = request.getParameter("sessionid");
int session = 0;
try {
session = (new Integer(sessionid)).intValue();
} catch (Exception e) {
printErrorForm(langUtil, request,
langUtil.getTextMessage("SRV_InvalidVal",
sessionid, langUtil.getTextMessage("SRV_SessionID")),
returnMessage);
return;
}
Properties p = null;
try {
p = server.getCurrentProperties();
} catch (Exception e) {
printErrorForm(langUtil, request, e, returnMessage);
return;
}
// if it's on, turn it off, if its off, turn it on
boolean val;
if (p.getProperty(Property.DRDA_PROP_TRACE+sessionid) != null)
val = false;
else
val = true;
if (traceSession(langUtil, val, session, request, returnMessage))
{
if (val)
out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOn", sessionid)+"</h4>");
else
out.println( "<h4>"+langUtil.getTextMessage("SRV_StatusTraceNoOff", sessionid)+"</h4>");
}
else
return;
}
}
printAsContentHeader(langUtil.getTextMessage("SRV_TraceSessButton"));
out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
"SRV_SessionID", "sessionId") + "</h4>");
out.println( "<INPUT type=text name=sessionid size=10 maxlength=10 " +
"id='sessionId' value=''>");
out.println( "<h4> </h4>");
out.println( "<INPUT type=submit name=doaction value='"+traceOnOffMessage+ "'>" );
out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
}
else if (form.equals(traceDirMessage))
{
boolean set = false;
String traceDirectory = null;
printAsContentHeader(traceDirMessage);
if (doAction != null)
{
if (doAction.equals(traceDirMessage))
{
traceDirectory = getParam(request, "tracedirectory");
if (traceDirectory(langUtil, traceDirectory, request,
returnMessage) )
set = true;
else
return;
}
}
if (set)
{
out.println( "<h2>"+langUtil.getTextMessage("SRV_TraceDirDone", traceDirectory)+"</h2>");
out.println( "<INPUT type=submit name=form value='"+returnMessage+"'>" );
}
else
{
out.println( "<h4>" + getHtmlLabelledMessageInstance(langUtil,
"SRV_TraceDir", "tracedir") + "</h4>");
out.println( "<INPUT type=text name=tracedirectory size=60 maxlength=256 " +
"id='tracedir' value='"+tracingDirectory+"'>");
out.println( "<h4> </h4>");
out.println( "<INPUT type=submit name=doaction value='"+traceDirMessage+ "'>" );
out.println( "<INPUT type=submit name=form value='"+returnMessage+ "'>" );
}
}
else if (form.equals(netParamMessage))
{
int maxThreads = 0;
int timeSlice = 0;
String maxName = langUtil.getTextMessage("SRV_NewMaxThreads");
String sliceName = langUtil.getTextMessage("SRV_NewTimeSlice");
try {
Properties p = server.getCurrentProperties();
String val = p.getProperty(Property.DRDA_PROP_MAXTHREADS);
maxThreads= (new Integer(val)).intValue();
val = p.getProperty(Property.DRDA_PROP_TIMESLICE);
timeSlice= (new Integer(val)).intValue();
} catch (Exception e) {
printErrorForm(langUtil, request, e, returnMessage);
return;
}
if (doAction != null && doAction.equals(netParamMessage))
{
int newMaxThreads = getIntParameter(request, "newmaxthreads",
"SRV_NewMaxThreads", langUtil, returnMessage);
int newTimeSlice = (newMaxThreads == INVALID) ? NOT_GIVEN :
getIntParameter(request, "newtimeslice", "SRV_NewTimeSlice", langUtil,
returnMessage);
if ((newMaxThreads == INVALID) || (newTimeSlice == INVALID))
return;
else if (!(newMaxThreads == NOT_GIVEN && newTimeSlice == NOT_GIVEN))
{
if (newMaxThreads != NOT_GIVEN)
maxThreads = newMaxThreads;
if (newTimeSlice != NOT_GIVEN)
timeSlice = newTimeSlice;
if (!setNetParam(langUtil, maxThreads, timeSlice, request,
returnMessage))
return;
}
}
out.println(formHeader);
printAsContentHeader(netParamMessage);
out.println( "<h4>"+langUtil.getTextMessage("SRV_MaxThreads", new Integer(maxThreads).toString()) +"</h4>");
out.println( "<h4>"+langUtil.getTextMessage("SRV_TimeSlice", new Integer(timeSlice).toString()) +"</h4>");
out.println( "<h4> </h4>");
out.println( "<h4> <label for='newmaxthreads'>"+maxName+"</label> </h4>");
out.println( "<INPUT type=text name=newmaxthreads size=10 maxlength=10 " +
"id='newmaxthreads' value=''>" );
out.println( "<h4> <label for='newslice'>"+sliceName+"</label> </h4>");