-
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
-
Re: Java upload file?
There are plenty of results from Googling 'java servlet file upload'.
Apache has a package that is handy.
-
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.
-
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.