• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

write an object to tomcat server from http socket client

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
URL url = new URL(model.Upload_URL);
header.append("POST ");
System.out.println("path "+url.getPath());
header.append(url.getPath());
System.out.println("path "+url.getHost());
System.out.println("path "+url.getQuery());
if (null != url.getQuery() && !"".equals(url.getQuery())) {
header.append("?");
header.append(url.getQuery());
}
header.append(" HTTP/1.1\r\n");
// Header: General
header.append("Host: ");
header.append(url.getHost());
header.append("\r\n");
//header.append("Accept: */*\r\n");
// Header: Request
//header.append("User-Agent: Mozilla/4.0\r\n");
// Header: Entity
header.append("Content-type:multipart/form-data; boundary="); //" application/octet-stream; boundary=");
header.append(boundary.substring(2, boundary.length()) + "\r\n");
header.append("Content-length: ");
header.append(contentLength+ "\r\n");
header.append("Cookie: ");
header.append(sb1.toString());
header.append("\r\n");
// Blank line
header.append("\r\n");
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why did you post that?
Do you have a question?

If you're looking for code to upload a file to a web server (simulating uploading from an HTML form), have a look at the Jakarta Commons FileUpload library.
[ August 18, 2005: Message edited by: Jesper de Jong ]
reply
    Bookmark Topic Watch Topic
  • New Topic