Test 1 - GET Method - Failed

This section provides a tutorial example of testing file upload with the HTTP GET method. The test failed, because file upload only works with the POST method, not the GET method.

Before looking the Part 4, UploadSave.jspx, let's test the first 3 parts now on my Tomcat 7 server by copying all 3 pages to \local\apache-tomcat-7.0.32\webapps\ROOT.

Then I run IE (Internet Explorer) 8.0 with http://localhost:8080/UploadInit.html. I got the form for changing file upload options:

File Upload Test Settings:

File upload handler: [UploadDump.jspx]
Submit method: [get ]
Encryption type: [application/x-www-form-urlencoded]

Without changing any values in the form, I clicked the submit button. I got the file upload form:

File Upload Form:

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

Observe that:

To continue the test, I used the "Browse..." button, and selected two local files, C:\hello.txt and C:\dot.gif, into "File 1" and "File 2" input fields. Then clicked the Submit button, I got a blank page.

Why? Because the submit method was set to "get". As you remember, the "get" method requires the browser to submit all input fields in the HTTP request header. In fact, if you look at the address field of the browser, you would see the URL encoded input fields appended at the end of the URL:


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