ms.showError("No redirect found");
ms.showError("No confirm line found");
	public void run() 	{		// get the file component head		String fileFieldName = ms.getParameter("FILE_FIELD_NAME");		if (fileFieldName == null) fileFieldName = "file_0";		StringBuffer fileHeader = new StringBuffer();        fileHeader.append("--" + boundary + "\r\n");        fileHeader.append("Content-Disposition: form-data; name=\""+fileFieldName+"\"; fileName=\""+fileName+"\"\r\n");        fileHeader.append("Content-Type: application/octet-stream");        fileHeader.append("\r\n\r\n");		// get the other POST components and the tail		StringBuffer tail = new StringBuffer();		int i = 0;		String fieldName = ms.getParameter("FIELD_NAME_"+i);		String fieldValue = ms.getParameter("FIELD_VALUE_"+i);		while (fieldName != null) {			//ms.showError("Field "+fieldName+"   set to  "+fieldValue);			tail.append(getPostComponent(fieldName, fieldValue));			i++;			fieldName = ms.getParameter("FIELD_NAME_"+i);			fieldValue = ms.getParameter("FIELD_VALUE_"+i);		}		tail.append("\r\n--");		tail.append(boundary);		tail.append("--\r\n");		// get the request header		StringBuffer header = new StringBuffer();		header.append("POST "+submitURL.getPath()+"?"+submitURL.getQuery()+" HTTP/1.1\r\n");		header.append("Host: "+submitURL.getHost()+"\r\n");		header.append("Content-type: multipart/form-data; boundary="+boundary+"\r\n");		header.append("Content-length: "+((int)(fileData.length + fileHeader.length() + tail.length()))+"\r\n");		header.append("Connection: Keep-Alive\r\n");		header.append("\r\n");		//JOptionPane.showMessageDialog(ms.ij, "HEADER: "+header);		Socket sock = null;		DataOutputStream dataout = null;		BufferedReader datain = null;		try {			sock = new Socket(submitURL.getHost(), (-1 == submitURL.getPort())?80:submitURL.getPort());		    dataout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));			datain  = new BufferedReader(new InputStreamReader(sock.getInputStream()));			// send the header			dataout.writeBytes(header.toString());			// send the file			dataout.writeBytes(fileHeader.toString());			byte[] byteBuff = new byte[1024];			int numBytes = 0;			int totalBytes = 0;			ByteArrayInputStream is = new ByteArrayInputStream(fileData);			while(-1 != (numBytes = is.read(byteBuff))) {				//JOptionPane.showMessageDialog(ij, "Wrote "+numBytes+" bytes");				dataout.write(byteBuff, 0, numBytes);				totalBytes += numBytes;				ms.setProgress(totalBytes);				try { Thread.sleep(20); } catch (Exception e) {}			}			// wind it up			dataout.writeBytes(tail.toString());			dataout.flush();		} catch (Exception e) {			ms.showError("Error while writing to server: "+e.getMessage());			e.printStackTrace();			return;		}		try {			// get the server's response			String line = datain.readLine();			String confirmLine = null;			URL redirectLocation;			String error = null;			//StringBuffer sb = new StringBuffer();			while ((line != null)) { 				//sb.append(line + "\n");				if (line.indexOf("403 Forbidden") != -1) {					error = "Server returned 403 forbidden.  You don't seem to have access to the system";					break;				}				if (line.indexOf("MySource Warning") != -1) {					error = "MySource Warning: \n" + getMysourceMessage(datain);					break;				}				if (line.indexOf("MySource Error") != -1) {					error = "MySource Error: \n" + getMysourceMessage(datain);					break;				}				if (line.trim().startsWith(ServerSubmitter.CONFIRM_PREFIX)) {					confirmLine = line.trim();					break;				}				if (line.trim().startsWith(ServerSubmitter.ERROR_PREFIX)) {					error = line;					confirmLine = "";					break;				}				line = datain.readLine();			}			//ms.showError(sb.toString());			if (error != null) {				ms.showError(error);				ms.finish(null);				return;			}			if (confirmLine == null) {				ms.showError("No redirect found");				ms.finish(null);				return;			}			ms.finish(confirmLine.substring(ms.CONFIRM_PREFIX.length()+1));		} catch (Exception e) {			ms.showError("Error while reading server response: "+e.getMessage());			e.printStackTrace();			ms.finish(null);			return;		}	}//end run()