Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: File not posting using MultipartRequestEntity

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default File not posting using MultipartRequestEntity

    This is my first time using a multipart form to post data to an HTML form post. I am not sure if I am missing something, but I get no errors and the script completes as far as I can tell, but no data is added to the server the file is submitted to. Am I missing something from the code below
    public static void main(String[] args) throws IOException {
        try {
            File f = new File("C://xxxxx/test.txt");
            PostMethod postMessage = new PostMethod("xxxxxxx");
            Part[] parts = {
                    new FilePart(f.getName(), f)
            };
     
            postMessage.setRequestEntity(new MultipartRequestEntity(parts, postMessage.getParams()));
            HttpClient client = new HttpClient();
     
            client.executeMethod(postMessage);
            System.out.print("Test");
        } catch (HttpException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            //  TODO Auto-generated catch block
            e.printStackTrace();
        }  
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: File not posting using MultipartRequestEntity

    Your code refers to classes not part of J2SE...I'd recommend posting an SSCCE (with the imports, links to libraries used, etc...). Just in case you are unsure of how to use the libraries you use, I'd recommend consulting their API's and documentation.

Similar Threads

  1. Exception Posting Image.
    By patKevin in forum Exceptions
    Replies: 1
    Last Post: July 24th, 2011, 01:04 PM
  2. The problems with cross-posting
    By copeg in forum The Cafe
    Replies: 0
    Last Post: January 9th, 2011, 09:23 PM
  3. Facing problem with posting Excel file for download - Content in browser
    By ragz_82 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 9th, 2010, 08:28 AM

Tags for this Thread