Index: /greenstone3/trunk/src/java/org/greenstone/server/BaseServerSettings.java
===================================================================
--- /greenstone3/trunk/src/java/org/greenstone/server/BaseServerSettings.java	(revision 18709)
+++ /greenstone3/trunk/src/java/org/greenstone/server/BaseServerSettings.java	(revision 18710)
@@ -13,12 +13,9 @@
 
 public abstract class BaseServerSettings extends JDialog
-
 {
-
     static Logger logger = Logger.getLogger(BaseServerSettings.class.getName());
     static final int DEFPORT = 8080;
 
     JCheckBox autoEnter;
-    JComboBox servlet_combobox;
 
     protected JSpinner portNumber_spinner = null;
@@ -34,9 +31,7 @@
     protected int portNum = DEFPORT;
     protected boolean autoStart = false;
-    protected String servletDefault = null;
     protected String browserPath = "";
     protected boolean useDefaultBrowser = true;
 
-    protected HashMap url_mappings = null;
     protected JDialog self;
     protected BaseServer server;
@@ -44,5 +39,5 @@
     public BaseServerSettings(BaseServer server) 
     {
-	super((Frame)null, "", true);
+	super(server.getServerControl(), "", true);
 	this.self = this;
         this.server = server;
@@ -82,5 +77,5 @@
 
 	portNumber_spinner = new JSpinner(new SpinnerNumberModel(portNum,1,65535,1));
-	portNumber_spinner.setEditor(new JSpinner.NumberEditor(portNumber_spinner, "#####")); 
+	portNumber_spinner.setEditor(new JSpinner.NumberEditor(portNumber_spinner, "#####"));
 
 	autoEnter = new JCheckBox(server.dictionary.get("ServerSettings.Auto_Start"));
@@ -186,4 +181,6 @@
 
 
+    protected String onSave() { return ""; }
+    protected void save(ScriptReadWrite scriptReadWrite, ArrayList newFileLines) {}
     protected abstract JPanel createServletPanel();
 
@@ -238,10 +235,14 @@
             	has_changed = true;
 	    }
-	    if(servletDefault != null && servlet_combobox != null) {
-		if (!servletDefault.equals(servlet_combobox.getSelectedItem())) {
-		    has_changed = true;
-		    require_restart = true; 
-		}
-	    }
+
+	    // call subclass' onSave method
+	    String result = onSave();
+	    if(result.indexOf("changed") != -1) {
+		has_changed = true;
+	    }
+	    if(result.indexOf("restart") != -1) {
+		require_restart = true;
+	    }
+
             //changed to use other browser
             if (useDefaultBrowser && other_browser_button.isSelected()){
@@ -274,7 +275,7 @@
 		newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.AUTOSTART, newAutoEnter);
 		
-		String newServletDef = (String) servlet_combobox.getSelectedItem();
-		newFileLines = scriptReadWrite.queryReplace(newFileLines,BaseServer.Property.DEFAULT_SERVLET, (String) url_mappings.get(newServletDef));
-
+		// call the subclass' save() method to save custom elements
+		save(scriptReadWrite, newFileLines);
+		
 		String osName = System.getProperty("os.name");
                 if (osName.startsWith("Windows")){
Index: /greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java
===================================================================
--- /greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java	(revision 18709)
+++ /greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java	(revision 18710)
@@ -1,11 +1,15 @@
 package org.greenstone.server;
 
+import java.awt.BorderLayout;
+import java.awt.event.*;
 import javax.swing.*;
-import java.awt.BorderLayout;
+import javax.swing.event.*;
 
 import org.greenstone.server.BaseServerSettings;
 
-public class Server2Settings extends BaseServerSettings
+public class Server2Settings extends BaseServerSettings implements ChangeListener, ActionListener
 {
+    protected JComboBox prefix_combobox;
+
     public Server2Settings(BaseServer server) 
     {
@@ -15,9 +19,12 @@
     protected JPanel createServletPanel()
     {
+	portNumber_spinner.addChangeListener(this);
+
 	JLabel prefix_label = new JLabel(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".URL"));
 
-	JComboBox prefix_combobox = new JComboBox();
+	prefix_combobox = new JComboBox();
 	prefix_combobox.setEditable(true);
 	prefix_combobox.addItem(server.getBrowserURL());
+	prefix_combobox.addActionListener(this);
 
 	JPanel comb_panel = new JPanel();
@@ -27,4 +34,65 @@
 	return comb_panel;
     }
-    
+
+    public String onSave() 
+    {
+	return "";
+    }
+
+    public void stateChanged(ChangeEvent e) {
+	int portNumber = ((Integer)portNumber_spinner.getValue()).intValue();
+	String url = (String)prefix_combobox.getSelectedItem();
+
+	String pre = "";
+	if(url.indexOf("http://") != -1) {
+	    pre = "http://";
+	    url = url.substring(7);
+	}
+
+	String[] parts = url.split("/");
+	String prefix = parts[0];
+
+	int colon = prefix.indexOf(':');
+	if(colon != -1) {
+	    prefix = prefix.substring(0, colon);
+	} 
+	
+	url = pre + prefix + ":" + portNumber;
+	for(int i = 1; i < parts.length; i++) {
+	    url = url + "/" + parts[i];
+	}
+
+	prefix_combobox.setSelectedItem(url);	
+    }
+
+    public void actionPerformed(ActionEvent e) {
+    	System.err.println("*** Port number changed in url box!");
+	String url = (String)prefix_combobox.getSelectedItem();
+	int portNumber = 80;
+
+	String oldUrl = url;
+	if(url.indexOf("http://") != -1) {
+	    url = url.substring(7);
+	}
+	int colon = url.indexOf(':');
+	int slash = url.indexOf('/');
+	if(slash == -1) {
+	    slash = url.length();
+	}
+	if(colon != -1) {
+	    url = url.substring(colon+1, slash);
+	    try { 
+		portNumber_spinner.setValue(Integer.decode(url));
+	    } catch(NumberFormatException nfe) { // couldn't parse port number
+		// not an integer, leave portnumber at 80
+		String oldNum = Integer.toString((Integer)portNumber_spinner.getValue());
+		oldUrl = oldUrl.replace(oldNum, "80");
+		portNumber_spinner.setValue(80);
+	    }
+	} else { // no port number
+	    oldUrl = oldUrl.replace(url, url+":80");
+	    portNumber_spinner.setValue(80);
+	}
+    }
+
 }
