This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

File COuld not be posted on IIS 5.0 via Servlet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
//fin.close();

}
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,
ECO_CONSTANTS.ATT_FILE_UPLOAD_RESPONSE_CODE_POST,
ECO_CONSTANTS.ATT_FILE_UPLOAD_RESPONSE_TEXT_POST );
out.println( xml_response );
out.close();
try { db_connection_work.close(); } catch ( Exception zzz){} // Close d/b connection
db_connection_work = null;
return;
}
}

********************
********************
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();
conn.setDoOutput(true);
conn.setRequestMethod("PUT");

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

while (readval > -1) {

readval = fin.read(block,0,1);
bo.write(block,0,1);

}
fin.close();
eCO_API_Servlet_Utils.write_trans_log_servlet( local_program_details, err_message );
bo.close();
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();
in.close();
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

Cheers
Rakesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic