Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Tolls

Thread: Java upload file?

  1. #1
    darklydeadly is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Java upload file?

    Sorry if my question is not clear? I am trying to upload a file through webpage and process with java.
    The file is browsed by user using
    <h3>XML configuration file</h3>

    <p>This input the XML file that contain all configuration parameter for the simulation</p><br/>
    <input type="hidden" name="MAX_FILE_SIZE" value="500" />
    <!--<input type="file" id="XMLinput" name="XMLinput" size="40" multiple> <br/>-->
    <input type="file" id="XMLinput" name="XMLinput" size="40"> <br/>
    <output id="list"></output>

    How do I get the file and pass it to java ? I tried Request.getParameter("XMLinput"), but it doesn't work.
    The servlet i'm using is Tomcat.

    Cheers

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Java upload file?

    There are plenty of results from Googling 'java servlet file upload'.
    Apache has a package that is handy.
    darklydeadly likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    darklydeadly is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: Java upload file?

    Thanks Tolls, I tried that and there was an example using com.oreilly.servlet.MultipartRequest; library, which is not installed on the computer. And since it is university comp, I can not add extra libraries to it.
    What I'm looking for is a simple method to pass the file that I select at the html page into a java class like File.
    Sorry, I just start dealing with java recently.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Java upload file?

    You can't download jar files (there's no such thing as 'installation' with pure Java apps)?
    Then you'll have to look into how multipart requests work.
    I try not to reinvent the wheel these days.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. :large file upload to server(chunk upload)
    By tommy_725 in forum Networking
    Replies: 0
    Last Post: 10-16-2009, 12:21 AM
  2. Java Applets and File Upload
    By effkay in forum Java Applets
    Replies: 0
    Last Post: 07-14-2009, 09:03 PM
  3. code to upload a file in java
    By radhika123 in forum New To Java
    Replies: 6
    Last Post: 07-11-2008, 07:04 AM
  4. file upload in java
    By muralikrishna in forum New To Java
    Replies: 6
    Last Post: 06-25-2008, 08:24 AM
  5. JFileUpload 2.0 released - Java file upload applet
    By jfileupload in forum Java Software
    Replies: 0
    Last Post: 03-09-2008, 02:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •