Skip to Content
0
Former Member
Jan 18, 2006 at 07:10 PM

How to access request content using MultipartMessage Object

56 Views

I want to take a file from the Client and upload it as a FileInputStream on the server.

I have a simple form as follows:

<form action="scan" name="scan_files" method="post"
 enctype="multipart/form-data">
<input type="file" name="file1">
<input type="file" name"file2"/>
<input type="Submit" name="insert_scaned" value="Upload"/>
</form>

In my servlet I tried to use the com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage

class to parse the form information.

protected void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
		
MultipartMessage multipartMsg = 
(MultipartMessage)request.getAttribute("com.sap.servlet.multipart.body");	

if (multipartMsg != null) {
	multipartMsg.addFormParametersToRequest();
}

The help said that once this is done the form information should be accessible via the

request getParameter() method. However, I can't seem to get it working?

How can I access the file so that I can parse it into a FileInputStream?

Thanks.