File tempFile = File.createTempFile("exist", ".tmp");
File tempFile = File.createTempFile("existSRV", ".tmp");
	protected void doPut(HttpServletRequest request, HttpServletResponse response)			throws ServletException, IOException {		User user = authenticate(request);		if (user == null) {			response.sendError(HttpServletResponse.SC_FORBIDDEN,					"Permission denied: unknown user or password");			return;		}				String path = adjustPath(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("exist", ".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);			server.doPut(broker, tempFile, 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();	}