Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 545187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:44:05+00:00 2026-05-13T10:44:05+00:00

I use Apache Commons FileUpload to receive uploaded files in a Servlet, as described

  • 0

I use Apache Commons FileUpload to receive uploaded files in a Servlet, as described at http://code.google.com/appengine/kb/java.html#fileforms

        ServletFileUpload upload = new ServletFileUpload();

        FileItemIterator iterator = upload.getItemIterator(request);

        while (iterator.hasNext()) {
            FileItemStream item = iterator.next();
            InputStream stream = item.openStream();

            if (!item.isFormField()) {
              System.out.println("Got an uploaded file: " + item.getFieldName()
                        + ", name = " + item.getName() + " type = " +               item.getContentType());

            }

I am not sure if item.getContentType() also will coutain the file encoding for text files which could be different from the request encoding, (for example ISO-8859-1), or if it always only contains the file type only. In my tests I received only “text/plain” but I was expecting “text/plain; Encoding=ISO-8859-1” which has been sent from the client.

Is my understanding correct that the item.getContentType() should include the encoding (if it is sent from client)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:44:06+00:00Added an answer on May 13, 2026 at 10:44 am

    FileItemStream.getContentType() returns whatever was passed from the browser’s POST. It could be “text/plain” or it could be “text/plain; Encoding=ISO-8859-1” OR it could be complete garbage. The content type is just a string value you are trusting the browser to give you properly (in other words, don’t trust it at all).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use Amazon-SDK(Java) sample code S3TransferProgressSample.java to upload large files to Amazon-S3
I have some Java projects that use Apache Commons Configuration and they get deployed
I have some Java projects that use Apache Commons Configuration and they get deployed
I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang... There are two versions of
is there a chance to use different location for apache's config files (on Windows)?
I tried to use the file upload using Apache Commons but the following exception
I have a seam app and would like to use the MultiPowUploader ( http://www.element-it.com/multiple-file-upload/flash-uploader.aspx
I want to use the apache commons configuration jars in my Maven project. When
I am trying to use the Apache Java library SystemUtils to determine the operating
I use apache-commons-beanutils DynaBean class in order to fetch rows from a database and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.