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

  • SEARCH
  • Home
  • 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 458095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:38:13+00:00 2026-05-12T22:38:13+00:00

I am tring to retrieve a filename or the file itself for use in

  • 0

I am tring to retrieve a filename or the file itself for use in a java servlet (from a web form).

I have a file form field:

<form enctype="multipart/form-data" method="post" action="SaveDictionary.do">
    <label>
        <input type="file" name="dictionary_file" id="dictionary_file" />
        <br />
    </label>
    <label>
        <br />     
        <input type="submit" name="saveDic" id="saveDic" value="Save Dictionary" />
    </label>
 </form>

I wanto then process it in my servlet, what do I do to process this – for a normal text field I would use something like

String myValue = (String) request.getParameter(“parameter_name”);

Assuming I have this class, what do I put in the doPost() method to get either the file path or the actual file contents.

@SuppressWarnings("serial")
public class SaveDictionary extends HttpServlet {

    public void doPost(HttpServletRequest request,
  HttpServletResponse response) throws IOException, ServletException {

     // I can't work out what goes here, the same
     // String myValue = (String) request.getParameter("parameter_name"); doesn't work

        response.sendRedirect("dictionary.jsp");
    }

}
  • 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-12T22:38:14+00:00Added an answer on May 12, 2026 at 10:38 pm

    Multipart/form-data encoded requests are not supported by the default servlet API. You basically need to parse the request body yourself based on the HttpServletRequest#getInputStream(). But that’s a precious and tedious work. You don’t want to do that if you’re already asking this question here at SO. Fortunately there’s already a robust, thoroughly developed and maintained API out for that, the Apache Commons FileUpload API. It’s in fact easy to use. You can find examples in their User Guide and tips&tricks in their FAQ.

    You can also wrap it in a Filter which does all the parsing work and puts all the parameters back in the request, so that it’s all transparent in the servlet code and you can continue using HttpServletRequest#getParameter() and consorts the usual way. Uploaded files can then be obtained as request attributes. Here‘s a basic example.

    Hope this helps.

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

Sidebar

Related Questions

I have set the enctype to: multipart/form-data yet whenever I submit this form, the
Hi I am trying to retrieve values from database. I have a row which
I'm trying to retrieve product information from magento by calling its web service using
I'm trying to retrieve the attribute value from an xsl:param and use it in
I am trying to retrieve particular data from a txt file and would like
I'm trying to save a file (pdf or image) uploaded from a form into
I am trying to download a file I have uploaded to an image field
I am trying to retrieve and stream a file to the browser from an
I am trying to retrieve a file name from one page where the php
I am trying retrieve user name from the code through graph api, the below

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.