Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File COuld not be posted on IIS 5.0 via Servlet  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!