Test 2 - POST Method - Successful

This section provides a tutorial example of testing file upload with the HTTP POST method and multipart/form-data encryption type. The test worked. All input values, including uploaded files, are dumped back on the browser.

The previous test of using the HTTP GET method was not very interesting. In the next test, I changed settings on the UploadInit.html page: Submit method = Post and Encryption type = multipart/form-data.

File Upload Test Settings:

File upload handler: [UploadDump.jspx]
Submit method: [post]
Encryption type: [multipart/form-data              ]
Submit

Then I selected the same files on the UploadForm.jsp page, and I got the following dump:

-----------------------------7d53495100260
Content-Disposition: form-data; name="email"

herong_yang@yahoo.com
-----------------------------7d53495100260
Content-Disposition: form-data; name="comment"

 I am uploading two files:
   hello.txt
   dot.gif
-----------------------------7d53495100260
Content-Disposition: form-data; name="file1"; filename="C:\hello.txt"
Content-Type: text/plain

Hello world!
-----------------------------7d53495100260
Content-Disposition: form-data; name="file2"; filename="C:\dot.gif"
Content-Type: image/gif

GIF89a   333    !?   ,        D  ;
-----------------------------7d53495100260
Content-Disposition: form-data; name="submit"

Submit
-----------------------------7d53495100260--

The output looks very interesting now:

Last update: 2012.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

File Upload Test Application

 RFC 1867 - Form-based File Upload in HTML

 Code 1 - Display Options - UploadInit.html

 Code 2 - Display Form - UploadForm.jspx

 Code 3 - Dump File - UploadDump.jspx

 Test 1 - GET Method - Failed

Test 2 - POST Method - Successful

 Code 4 - Save File - UploadSave.jspx

 Test 3 - Save File - Successful

 Code Review - UploadSave.jspx

 Outdated Tutorials

 References

 PDF Printing Version