Index: lib/web.xml.geoserver
===================================================================
--- lib/web.xml.geoserver	(nonexistent)
+++ lib/web.xml.geoserver	(revision 5847)
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+    <display-name>GeoServer</display-name>
+  
+      <context-param>
+    <param-name>serviceStrategy</param-name>
+    <!-- Meaning of the different values :
+         
+         PARTIAL-BUFFER2
+         - Partially buffers the first xKb to disk. Once that has buffered, the the 
+           result is streamed to the user. This will allow for most errors to be caught
+           early. 
+           
+         BUFFER
+         - stores the entire response in memory first, before sending it off to
+           the user (may run out of memory)
+
+         SPEED
+         - outputs directly to the response (and cannot recover in the case of an
+           error)
+
+         FILE
+         - outputs to the local filesystem first, before sending it off to the user
+      -->
+    <param-value>SPEED</param-value>
+  </context-param>
+  
+  <!-- If true, enable versioning datastore as well -->
+  <context-param>
+    <param-name>enableVersioning</param-name>
+    <param-value>true</param-value>
+  </context-param>
+  
+  <context-param>
+    <!-- see comments on the PARTIAL-BUFFER strategy -->
+    <!-- this sets the size of the buffer.  default is "50" = 50kb -->
+
+    <param-name>PARTIAL_BUFFER_STRATEGY_SIZE</param-name>
+    <param-value>50</param-value>
+  </context-param>
+  
+    <!-- 
+    <context-param>
+      <param-name>PROXY_BASE_URL</param-name>
+      <param-value>http://82.58.146.45/</param-value>
+    </context-param>
+     -->
+   
+	<context-param>
+		<param-name>GEOSERVER_DATA_DIR</param-name>
+		<param-value>_GEOSERVER_DATA_DIR_VALUE_</param-value>
+	</context-param> 
+  
+    <!-- pick up all spring application contexts -->
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>classpath*:/applicationContext.xml classpath*:/applicationSecurityContext.xml</param-value>
+    </context-param>
+
+    <filter>
+     <filter-name>Acegi Filter Chain Proxy</filter-name>
+     <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
+     <init-param>
+       <param-name>targetClass</param-name>
+       <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
+     </init-param>
+    </filter>
+    
+       <filter>
+    <filter-name>Set Character Encoding</filter-name>
+    <filter-class>org.vfny.geoserver.filters.SetCharacterEncodingFilter</filter-class>
+    <init-param>
+      <param-name>encoding</param-name>
+      <param-value>UTF-8</param-value>
+    </init-param>
+  </filter>
+
+   <filter>
+    <filter-name>Reverse Proxy Filter</filter-name>
+    <filter-class>org.geoserver.filters.ReverseProxyFilter</filter-class>
+    <init-param>
+      <param-name>enabled</param-name>
+      <param-value>false</param-value>
+      <description>
+        Whether to enable the reverse proxy filter or not. Defaults to false. Set to true
+        in order for GeoServer to perform URL translation for the proxyfied base URL on
+        textual content whose MIME type matches one of the regular expressions set through
+        the mime-types init parameter.
+      </description>
+    </init-param>
+    <init-param>
+      <param-name>mime-types</param-name>
+      <param-value>text/html.*,text/css.*,text/javascript.*,application/x-javascript.*</param-value>
+      <description>
+        Comma separated list of response MIME types the filter shall process in order to translate
+        absolute urls using the configured proxyBaseUrl. Each token in the comma separated list
+        is interpreted as a java regular expression.
+      </description>
+    </init-param>
+   </filter>
+   
+   <filter>
+     <filter-name>GZIP Compression Filter</filter-name>
+     <filter-class>org.geoserver.filters.GZIPFilter</filter-class>
+     <init-param>
+         <!-- The compressed-types parameter is a comma-separated list of regular expressions.
+              If a mime type matches any of the regular expressions then it will be compressed.
+              -->
+         <param-name>compressed-types</param-name>
+         <param-value>text/.*,.*xml.*,application/json,application/x-javascript</param-value>
+     </init-param>
+   </filter>
+
+   <filter>
+     <filter-name>Request Logging Filter</filter-name>
+     <filter-class>org.geoserver.filters.LoggingFilter</filter-class>
+     <init-param>
+         <!-- The 'enabled' parameter is a boolean value, "true" (case-insensitive) for true or
+              any other value for false.  If enabled, then the logging will be performed;
+              otherwise the logging filter will have no effect.  If not specified, this 
+              parameter defaults to false.
+              -->
+         <param-name>enabled</param-name>
+         <param-value>false</param-value>
+     </init-param>
+     <init-param>
+     <!-- The 'log-request-bodies' parameter is a boolean value, "true" (case-insensitive) for
+          true or any other value for false.  If enabled, then the logging will include the body
+          of POST and PUT requests.  If not specified, this parameter defaults to false.
+          Note that this may noticeably degrade responsiveness of your geoserver since it will
+          not begin to process requests until the entire request body has been received by the 
+          server.
+          -->
+     <param-name>log-request-bodies</param-name>
+     <param-value>false</param-value>
+     </init-param>
+   </filter>
+
+    <filter-mapping>
+      <filter-name>GZIP Compression Filter</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+    
+    <filter-mapping>
+      <filter-name>Reverse Proxy Filter</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+  
+    <filter-mapping>
+      <filter-name>Request Logging Filter</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+   
+    <!-- 
+      If you want to use your security system comment out this one too
+    -->
+    <filter-mapping>
+      <filter-name>Acegi Filter Chain Proxy</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+    
+      <filter-mapping>
+      <filter-name>Set Character Encoding</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+    
+    <!-- general initializer, should be first thing to execute -->
+    <listener>
+      <listener-class>org.geoserver.GeoserverInitStartupListener</listener-class>
+    </listener>
+    
+    <!-- logging initializer, should execute before spring context startup -->
+    <listener>
+      <listener-class>org.geoserver.logging.LoggingStartupContextListener</listener-class>
+    </listener>
+  
+    <!--  spring context loader -->
+    <listener>
+      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+    
+    
+    <!-- spring dispatcher servlet, dispatches all incoming requests -->
+    <servlet>
+      <servlet-name>dispatcher</servlet-name>
+      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+    </servlet>
+    <servlet>
+	   <servlet-name>TestWfsPost</servlet-name>
+	   <servlet-class>org.vfny.geoserver.wfs.servlets.TestWfsPost</servlet-class>
+	</servlet>
+    
+    <servlet-mapping>
+        <servlet-name>dispatcher</servlet-name>
+        <url-pattern>/web/*</url-pattern>
+    </servlet-mapping>
+    <!-- TODO: find a way to remove this mighty list of mappings and have just one... -->
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/rest/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/security/*</url-pattern>
+    </servlet-mapping>    
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/wms/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/wcs/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/wfs/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/ows/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/wfsv/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/wcs111/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+      <servlet-name>dispatcher</servlet-name>
+      <url-pattern>/kml/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/styles/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/www/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/temp/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/history/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/gwc/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+     <servlet-name>dispatcher</servlet-name>
+     <url-pattern>/pdf/*</url-pattern>
+    </servlet-mapping>
+    
+    <servlet-mapping>
+     <servlet-name>TestWfsPost</servlet-name>
+     <url-pattern>/TestWfsPost/*</url-pattern>
+    </servlet-mapping>
+    
+    <mime-mapping>
+      <extension>xsl</extension>
+      <mime-type>text/xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+      <extension>sld</extension>
+      <mime-type>text/xml</mime-type>
+    </mime-mapping>
+  
+    <welcome-file-list>
+        <welcome-file>index.html</welcome-file>
+    </welcome-file-list>
+    
+</web-app>
Index: lib/admin/geoserver-configuration.jsp
===================================================================
--- lib/admin/geoserver-configuration.jsp	(revision 5846)
+++ lib/admin/geoserver-configuration.jsp	(revision 5847)
@@ -59,11 +59,28 @@
 	<hr class="config-line">
 	
 	<div class="form-row">
+		<img class="question-mark" src="style/images/question-mark.gif" 
+			onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GEOSERVER_DATA_DIR')"/>
+		<div class="textinput-label"><label for="geoserver.context" title="Geoserver data directory">Geoserver Data Directory</label></div>
+		<input class="textinput" id="geoserver.GEOSERVER_DATA_DIR" 
+				name="geoserver.GEOSERVER_DATA_DIR" 	             		    	    	           		    	             			
+				value="<%= request.getAttribute("geoserver.GEOSERVER_DATA_DIR") %>"/> 
+	</div>
+	<div class="form-row">
+		<img class="question-mark" src="style/images/question-mark.gif" 
+			onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GeoserverContext')"/>
+		<div class="textinput-label"><label for="geoserver.context" title="Geoserver context">Context</label></div>
+		<input class="textinput" id="geoserver.context" 
+				name="geoserver.context" 	             		    	    	           		    	             			
+				value="<%= request.getAttribute("geoserver.context") %>"/> 
+	</div>
+	<hr class="config-line">
+	<div class="form-row">
 				<img class="question-mark" src="style/images/question-mark.gif" 
 	           		 onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GeoserverUpdatePassword')"/>
 				<div class="textinput-label"><label for="geoserver.username" title="Geoserver user name">User Name</label></div>
 				<input class="textinput" id="geoserver.username" 
-					   name="geoserver.username" 	             		    	    	           		    	             			
+					   name="geoserver.username" readonly="readonly" 		    	    	           		    	             			
 	           		   value="<%= request.getAttribute("geoserver.username") %>"/> 
 	</div>
 	<div class="form-row">
Index: lib/metacat.properties
===================================================================
--- lib/metacat.properties	(revision 5846)
+++ lib/metacat.properties	(revision 5847)
@@ -409,16 +409,12 @@
 
 ######## Geoserver section              #######################################
 
-geoserver.loginPostPage=admin/loginSubmit.do
-geoserver.loginSuccessString=admin/logout.do
-geoserver.passwordPostPage=config/loginEditSubmit.do
-geoserver.passwordSuccessString=Data loaded without incident
-geoserver.applyPostPage=admin/saveToGeoServer.do
-geoserver.defaultUsername=admin
-geoserver.defaultPassword=geoserver
-geoserver.username=
+geoserver.username=admin
 geoserver.password=
+geoserver.context=geoserver
+geoserver.GEOSERVER_DATA_DIR=
 
+
 ######## workflowScheduler section              #######################################
 
 workflowScheduler.url=http://chico1.dyndns.org/workflowscheduler/scheduler
Index: src/edu/ucsb/nceas/metacat/spatial/SpatialFeatureSchema.java
===================================================================
--- src/edu/ucsb/nceas/metacat/spatial/SpatialFeatureSchema.java	(revision 5846)
+++ src/edu/ucsb/nceas/metacat/spatial/SpatialFeatureSchema.java	(revision 5847)
@@ -26,6 +26,7 @@
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.opengis.feature.simple.SimpleFeatureType;
 
+import edu.ucsb.nceas.metacat.properties.PropertyService;
 import edu.ucsb.nceas.metacat.util.SystemUtil;
 import edu.ucsb.nceas.utilities.PropertyNotFoundException;
 
@@ -42,7 +43,7 @@
 	static {
 		try {
 			
-			String geoserverDataDir = System.getProperty("GEOSERVER_DATA_DIR");
+			String geoserverDataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR");
 			if (geoserverDataDir != null) {
 				// use configured resource (might be same as local)
 				polygonShpUri = geoserverDataDir + "/data/metacat_shps/data_bounds.shp";
Index: src/edu/ucsb/nceas/metacat/util/GeoserverUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/util/GeoserverUtil.java	(revision 5846)
+++ src/edu/ucsb/nceas/metacat/util/GeoserverUtil.java	(revision 5847)
@@ -26,16 +26,17 @@
 
 package edu.ucsb.nceas.metacat.util;
 
-import org.apache.commons.httpclient.HttpClient;
 import org.apache.log4j.Logger;
 
-import java.io.IOException;
-import java.util.HashMap;
+import java.io.StringReader;
 
 import edu.ucsb.nceas.metacat.properties.PropertyService;
 import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
 import edu.ucsb.nceas.utilities.FileUtil;
+import edu.ucsb.nceas.utilities.GeneralPropertyException;
 import edu.ucsb.nceas.utilities.PropertyNotFoundException;
+import edu.ucsb.nceas.utilities.SortedProperties;
+import edu.ucsb.nceas.utilities.UtilException;
 
 public class GeoserverUtil {
 	
@@ -47,67 +48,6 @@
 	 */
 	private GeoserverUtil() {}
 	
-	/**
-	 * Log in to geoserver as the administrative user. If the geoserver.username
-	 * and geoserver.password already exists in metacat.properties, we assume
-	 * that the password was already changed at least once. We use these values.
-	 * Otherwise we use the default values.
-	 * 
-	 * @param httpClient
-	 *            the HttpClient we will use to post. This is passed in since it
-	 *            may need to be used after login by other methods.
-	 */
-	public static void loginAdmin(HttpClient httpClient) throws MetacatUtilException {
-		try {
-			String username = 
-				PropertyService.getProperty("geoserver.username");
-			String password = 
-				PropertyService.getProperty("geoserver.password");
-			String defaultUserName = 
-				PropertyService.getProperty("geoserver.defaultUsername");
-			String defaultPassword = 
-				PropertyService.getProperty("geoserver.defaultPassword");
-			String loginSuccessString = 
-				PropertyService.getProperty("geoserver.loginSuccessString");
-			
-			HashMap<String, String> paramMap = new HashMap<String, String>();
-			// if the username and password exist, we assume the geoserver was 
-			// already updated at least once.  Use the existing values as the 
-			// current admin values.  Otherwise,use the default values.
-			if (username != null && !username.equals("")
-					&& password != null && !password.equals("")) {
-				paramMap.put("username", username);
-				paramMap.put("password", password);
-			} else {
-				paramMap.put("username", defaultUserName);
-				paramMap.put("password", defaultPassword);
-			}
-			
-			// Create the post url from values in metacat.properties
-			String loginPostPage = 
-				PropertyService.getProperty("geoserver.loginPostPage");
-			String loginPostURL = SystemUtil.getContextURL() + "/"
-					+ loginPostPage;
-			
-			logMetacat.debug("loginPostURL: " + loginPostURL);
-			
-			// Do the post
-			String postResult = RequestUtil.post(httpClient, loginPostURL, paramMap);
-			
-			// check to see if the success string is part of the result
-			if(postResult.indexOf(loginSuccessString) == -1) {
-				logMetacat.debug(postResult);
-				throw new MetacatUtilException("Could not log in to geoserver.");
-			}
-
-		} catch (PropertyNotFoundException pnfe) {
-			throw new MetacatUtilException("Property error while logging in with " 
-					+ "default account: " + pnfe.getMessage());
-		} catch (IOException ioe) {
-			throw new MetacatUtilException("I/O error while logging in with " 
-					+ "default account: " + ioe.getMessage());
-		} 
-	}
 	
 	/**
 	 * Change the password on the geoserver. The loginAdmin method must have
@@ -122,50 +62,30 @@
 	 * @param password
 	 *            the new password
 	 */
-	public static void changePassword(HttpClient httpClient, String username, String password) 
+	public static void changePassword(String username, String password) 
 		throws MetacatUtilException {
 		try {	
 			
-			HashMap<String, String> paramMap = new HashMap<String, String>();
-			paramMap.put("username", username);
-			paramMap.put("password", password);
+			// the users file
+			String usersFile = 
+			 PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR")
+				+ FileUtil.getFS() 
+				+ "security"
+				+ FileUtil.getFS()
+				+ "users.properties";
+			SortedProperties userProperties = new SortedProperties(usersFile);
+			userProperties.load();
+			/* looks like this:
+				#Wed Jan 26 12:13:09 PST 2011
+				admin=geoserver,ROLE_ADMINISTRATOR,enabled
+			*/
+			String value = password + ",ROLE_ADMINISTRATOR,enabled";
+			userProperties.setProperty(username, value);
 			
-			// Create the post url from values in metacat.properties
-			String passwordPostPage = 
-				PropertyService.getProperty("geoserver.passwordPostPage");
-			String passwordPostURL = SystemUtil.getContextURL() + "/"
-					+ passwordPostPage;
-			
-			String passwordSuccessString = 
-				PropertyService.getProperty("geoserver.passwordSuccessString");
-
-			logMetacat.debug("passwordPostURL: " + passwordPostURL);
-			
-			// Do the post
-			String postResult = RequestUtil.post(httpClient, passwordPostURL, paramMap);
-			
-			// check to see if the success string is part of the result
-			if(postResult.indexOf(passwordSuccessString) == -1) {
-				logMetacat.debug(postResult);
-				throw new MetacatUtilException("Could not change geoserver password.");
-			}
-			
-			// send a post to apply the password changes.  Unfortunately, there really
-			// isn't anything of the geoserver side saying if the post passed, so we have
-			// to assume it did.
-			String applyPostPage = 
-				PropertyService.getProperty("geoserver.applyPostPage");
-			String applyPostURL = SystemUtil.getContextURL() + "/"
-				+ applyPostPage;
-			RequestUtil.post(httpClient, applyPostURL, null);		
-			
-		} catch (PropertyNotFoundException pnfe) {
-			throw new MetacatUtilException("Property error while logging in with " 
-					+ "default account: " + pnfe.getMessage());
-		} catch (IOException ioe) {
-			throw new MetacatUtilException("I/O error while logging in with " 
-					+ "default account: " + ioe.getMessage());
-		} 
+		} catch (Exception e) {
+			throw new MetacatUtilException("Property error while changing default password: " 
+				 + e.getMessage());
+		}
 	}
 	
 	/**
@@ -184,4 +104,49 @@
 		// geoserver is configured if not unconfigured
 		return !geoserverConfiguredString.equals(PropertyService.UNCONFIGURED);
 	}
+	
+	public static void writeConfig() throws MetacatUtilException {
+		try {
+			// the template geoserver web.xml file
+			String configFileTemplate = 
+				SystemUtil.getContextDir()
+				+ FileUtil.getFS()
+				+ "web.xml.geoserver";
+			
+			// the destination for the template
+			String configFileDestination = 
+				PropertyService.getProperty("application.deployDir")
+				+ FileUtil.getFS()
+				+ PropertyService.getProperty("geoserver.context")
+				+ FileUtil.getFS() 
+				+ "WEB-INF"
+				+ FileUtil.getFS()
+				+ "web.xml";
+			
+			// look up the configured value for the data dir, write it to the file
+			String dataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR");
+			String configContents = FileUtil.readFileToString(configFileTemplate, "UTF-8");
+			configContents = configContents.replace("_GEOSERVER_DATA_DIR_VALUE_", dataDir);
+			FileUtil.writeFile(configFileDestination, new StringReader(configContents), "UTF-8");			
+		} catch (PropertyNotFoundException pnfe) {
+			throw new MetacatUtilException(
+					"Property error while setting geoserver config: " + pnfe.getMessage());
+		}
+		catch (UtilException ue) {
+			throw new MetacatUtilException(
+					"Util error while setting geoserver config: " + ue.getMessage());
+		}
+	
+	}
+	
+	/**
+	 * Get the server URL with the Geoserver context. This is made up of the server URL +
+	 * file separator + the Geoserver context
+	 * 
+	 * @return string holding the server URL with context
+	 */
+	public static String getGeoserverContextURL() throws PropertyNotFoundException {
+		return SystemUtil.getServerURL() + "/"
+				+ PropertyService.getProperty("geoserver.context");
+	}
 }
Index: src/edu/ucsb/nceas/metacat/admin/GeoserverAdmin.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/GeoserverAdmin.java	(revision 5846)
+++ src/edu/ucsb/nceas/metacat/admin/GeoserverAdmin.java	(revision 5847)
@@ -31,7 +31,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.httpclient.HttpClient;
 import org.apache.log4j.Logger;
 
 import edu.ucsb.nceas.metacat.properties.PropertyService;
@@ -97,9 +96,13 @@
 
 				String username = PropertyService.getProperty("geoserver.username");
 				String password = PropertyService.getProperty("geoserver.password");
+				String context = PropertyService.getProperty("geoserver.context");
+				String dataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR");
 				
 				request.setAttribute("geoserver.username", username);
 				request.setAttribute("geoserver.password", password);
+				request.setAttribute("geoserver.context", context);
+				request.setAttribute("geoserver.GEOSERVER_DATA_DIR", dataDir);
 
 				// Forward the request to the JSP page
 				RequestUtil.forwardRequest(request, response,
@@ -165,14 +168,26 @@
 				
 				String username = (String)request.getParameter("geoserver.username");
 				String password = (String)request.getParameter("geoserver.password");
+				String context = (String)request.getParameter("geoserver.context");
+				String dataDir = (String)request.getParameter("geoserver.GEOSERVER_DATA_DIR");
 				
+				// process the context/data dir
+				if (context != null && dataDir != null) {
+					PropertyService.setPropertyNoPersist("geoserver.context", context);
+					boolean reconfig = PropertyService.checkAndSetProperty(request, "geoserver.GEOSERVER_DATA_DIR");
+					PropertyService.persistProperties();
+					// put the web.xml in place
+					if (reconfig) {
+						GeoserverUtil.writeConfig();
+					}
+				} else {
+					validationErrors.add("Context and Data Directory cannot be null");
+				}
+				
 				if (username == null || password == null) {
-					validationErrors.add("User Name and Password can not be null");
+					validationErrors.add("User Name and Password cannot be null");
 				} else {
-					HttpClient httpClient = new HttpClient();
-					GeoserverUtil.loginAdmin(httpClient);
-					GeoserverUtil.changePassword(httpClient, username, password);
-
+					GeoserverUtil.changePassword(username, password);
 					PropertyService.setPropertyNoPersist("geoserver.username", username);
 					PropertyService.setPropertyNoPersist("geoserver.password", password);
 					PropertyService.persistProperties();
