This method receives requests for modification of the
XML-RPC configuration information, all from the
{@link #doGet}
method. This will again
use the utility class to update the configuration
file, letting the {@link XmlRpcConfiguration}
object handle the actual writing to a file.
// Update the configuration information
if (config == null) {
config = new XmlRpcConfiguration(CONFIG_FILENAME);
}
// Save the hostname
String hostname =
req.getParameterValues("hostname")[0];
if ((hostname != null) && (!hostname.equals(""))) {
config.setHostname(hostname);
}
// Save the port number
int portNumber;
try {
portNumber =
Integer.parseInt(
req.getParameterValues("port")[0]);
} catch (Exception e) {
portNumber = 0;
}
if (portNumber > 0) {
config.setPortNumber(portNumber);
}
// Save the SAX driver class
String driverClass =
req.getParameterValues("driverClass")[0];
if ((driverClass != null) && (!driverClass.equals(""))) {
config.setDriverClass(driverClass);
}
// Save the handlers
String[] handlerIDs =
req.getParameterValues("handlerID");
String[] handlerClasses =
req.getParameterValues("handlerClass");
Hashtable handlers = new Hashtable();
for (int i=0; i<handlerIDs.length; i++) {
handlers.put(handlerIDs[i], handlerClasses[i]);
}
config.setHandlers(handlers);
try {
// Request the changes be written to the configuration store
config.saveConfiguration(CONFIG_FILENAME);
} catch (IOException e) {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println(e.getMessage());
return;
}
// Output a confirmation message
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("Changes saved <br />");
out.println("<a href=\"" + FORM_ACTION +
"\">Return to Configuration Administration" +
"</a>");
out.close();