This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Processing multipart/form-data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Processing multipart/form-data" Watch "Processing multipart/form-data" New topic
Author

Processing multipart/form-data

Christopher Elkins
Ranch Hand

Joined: Oct 26, 2004
Posts: 45
One of my jsp pages allows a user to upload a file from their computer to the server. The page contents are submitted via HTML Form using the POST method and an enctype equal to "multipart/form-data". I need to write a class that will properly handle this type of request. I have looked through the forum and found several threads refering to this issue. They all state the same thing; use some third-party software. This is not an option for me since all of the code that we use must be developed internally. My question is this, is there any information out there on how to write this code? If so, where? Thanks for any help that you can provide.


Christopher Elkins, SCJP Java 2 Platform
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60767
    
  65

If you must write all the code that you use (do they expect you to write your own servlet container as well?), you'll need to parse the multi-part request yourself.

I'd grab one of the 3rd party tools that you found mentioned and look at the multi-part parsing code to learn what it entails. In particular, I remeber that looking at the O'Reilly MultipartParser class was very instructive.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christopher Elkins
Ranch Hand

Joined: Oct 26, 2004
Posts: 45
Thanks Bear. I'll take a look. Yeah, if it's not part of the java, javax or oracle packages we pretty much have to reinvent the wheel. It's a shame that it usually turns out square.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Processing multipart/form-data
 
Similar Threads
upload an avatar or other file
Redirect back to portlet from servlet keeping same parameters
Java Mail Question...
jsp request and form's enctype="multipart/form-data" problem
BufferedWriter for Mulitple file type