This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes File COuld not be posted on IIS 5.0 via Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "File COuld not be posted on IIS 5.0 via Servlet" Watch "File COuld not be posted on IIS 5.0 via Servlet" New topic

File COuld not be posted on IIS 5.0 via Servlet

Rakesh Jain

Joined: Aug 18, 2004
Posts: 2
Hi There

We have a working code that was running all well with Win NT server. The server was recently migrated to Win2K/ IIS5.0 and then we have all problem of doing an Http Put on the virtual directory on IIS5.0. No Idea why is this happenning. Surprisingly we could aboe to post the file in the virtual dirctory but then I think the server is not sending the reposnse back tot he Java programme and a user defined exception 'Failed to post attachment is printed in the Log file".
For your reference please find the code used to put the file in the Win2K IIS5.0 combination
try {

out.println("Going to read from : " + ATT_DIR + ATTFilename + "<br>");
FileInputStream fin = new FileInputStream (ATT_DIR + ATTFilename);
retval = putFile(ATT_POST_URL + ATTFilename, fin);

catch (Exception e) {

// The post failed. Let's exit.
String err_message = "Failed to post attachment to virtual directory.";
eCO_API_Servlet_Utils.write_trans_log_servlet( local_program_details, err_message );
eCO_API_Servlet_Utils.write_error_log_servlet( local_program_details, err_message );
String xml_response = eCO_API_Servlet_Utils.create_xml_file_upload_ack ( XMLOriginalFilename,
out.println( xml_response );
try { db_connection_work.close(); } catch ( Exception zzz){} // Close d/b connection
db_connection_work = null;

public static boolean putFile (String reqURL, FileInputStream fin) throws Exception {

HttpURLConnection conn = null;
URL url= null;
String line = new String();
StringBuffer buf = new StringBuffer();
String retval = new String("Not Defined");
BufferedOutputStream bo = null;
boolean success = false;
String err_message = "This is For testing";
try {
url= new URL (reqURL);
conn = (HttpURLConnection)url.openConnection();

byte[] block = new byte[1];
int readval =0;
bo = new BufferedOutputStream (conn.getOutputStream());

while (readval > -1) {

readval =,0,1);

eCO_API_Servlet_Utils.write_trans_log_servlet( local_program_details, err_message );
eCO_API_Servlet_Utils.write_trans_log_servlet( local_program_details, err_message );

InputStreamReader in = new InputStreamReader(conn.getInputStream());
BufferedReader data = new BufferedReader(in);

while ((line = data.readLine()) != null) {
buf.append(line + "\n");
retval = buf.toString();
eCO_API_Servlet_Utils.write_trans_log_servlet( local_program_details, err_message );
return true;

} catch (Exception e) {

Exception ex = new IOException (e.getMessage());
throw ex;
/** End of PUT */

An early repsonse on this will be much apprciated

I agree. Here's the link:
subject: File COuld not be posted on IIS 5.0 via Servlet
Similar Threads
C --> Java
FTPProtocolException:STOR and FTPProtocolException:LIST??
Cannot solve this problem
relative path name for propertiesObject.load()
Display Image in JSP using servlet