Test 3 - Save File - 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. Uploaded files are saved on the Web server correctly.

I repeated my previous upload test with UploadSave.jspx by using the UploadInit.html page:

File Upload Test Settings:

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

On UploadForm page, I selected the same files:

File Upload Form:

Your email: [herong_yang@yahoo.com    ] 
Your comments: [I am uploading two files:     ]
               [   hello.txt                  ]
               [   dot.gif                    ]
File 1: [C:\hello.txt                  ] Browse...
File 2: [C:\dot.gif          ] Browse...

After clicking the submit button, I got the following result on the returning page:

disposition: null: Content-Disposition: form-data; name="email"
blank: null: 
data: null: herong_yang@yahoo.com
boundary: null: -----------------------------7d59ec3031a
disposition: null: Content-Disposition: form-data; name="comment"
blank: null: 
data: null:  I am uploading two files:
data: null:    hello.txt
data: null:    dot.gif
boundary: null: -----------------------------7d59ec3031a
disposition: hello.txt: Content-Disposition: form-data; name="file...
type: hello.txt: Content-Type: text/plain
blank: hello.txt: 
boundary: null: -----------------------------7d59ec3031a
disposition: dot.gif: Content-Disposition: form-data; name="file2"...
type: dot.gif: Content-Type: image/gif
blank: dot.gif: 
boundary: null: -----------------------------7d59ec3031a
disposition: null: Content-Disposition: form-data; name="submit"
blank: null: 
data: null: Submit
boundary: null: -----------------------------7d59ec3031a--

To make sure that the uploaded files are saved correctly, I used the following commands in a command window:

C:\>comp \hello.txt 

Comparing \hello.txt and \local\apache-tomcat-7.0.32\webapps\ROOT\u...
Files compare OK

C:\>comp \dot.gif 

Comparing \dot.gif and \local\apache-tomcat-7.0.32\webapps\ROOT\upl...
Files compare OK

Beautiful, my UploadSave.jspx page worked perfectly.

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


 PDF Printing Version