tempFile.delete();
	protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException	{		//first, adjust the path		String path = adjustPath(request);				//second, perform descriptor actions		Descriptor descriptor = Descriptor.getDescriptorSingleton();    	if(descriptor != null)    	{    		//TODO: figure out a way to log PUT requests with HttpServletRequestWrapper and Descriptor.doLogRequestInReplayLog()     		    		//map's the path if a mapping is specified in the descriptor    		path = descriptor.mapPath(path);    	}				//third, authenticate the user		User user = authenticate(request,response);		if (user == null) {                        // You now get a challenge if there is no user			//response.sendError(HttpServletResponse.SC_FORBIDDEN,			//		"Permission denied: unknown user or password");			return;		}				//fourth, process the request		ServletInputStream is = request.getInputStream();		int len = request.getContentLength();		// put may send a lot of data, so save it		// to a temporary file first.		File tempFile = File.createTempFile("existSRV", ".tmp");		OutputStream os = new FileOutputStream(tempFile);		byte[] buffer = new byte[4096];		int count, l = 0;		do {			count = is.read(buffer);			if (count > 0)				os.write(buffer, 0, count);			l += count;		} while (l < len);		os.close();				DBBroker broker = null;		try {			broker = pool.get(user);			srvREST.doPut(broker, tempFile, XmldbURI.create(path), request, response);		} catch (BadRequestException e) {			response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());		} catch (PermissionDeniedException e) {			response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());		} catch (EXistException e) {			response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());		} finally {			pool.release(broker);		}        tempFile.delete();	}