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 7025009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:55:06+00:00 2026-05-27T23:55:06+00:00

I need a single page with a file upload and a text area where

  • 0

I need a single page with a file upload and a text area where the contents of the file are printed in this page.

At the moment I have a jsp file and a servlet:

Part of index.jsp :

 <form action="FileReader" ENCTYPE="multipart/form-data" method="POST">
 <textarea name="textinputarea" rows="14" cols="130" readonly>
  Some text 
 </textarea>
 <br> <br><tr>


  <td valign="top" align="left" height="200" width="33%">
  <img class="start_img" src="file_Selections.jpg"> <br> 

  <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  <input type="file" name="user_file" accept="text/xml">   
  <input type="submit" value="Validate" /> <br>
   </form>

Part of the servlet:

public void doPost(HttpServletRequest request, HttpServletResponse response)      
String name = request.getParameter("textinputarea");
(...)
}else {
String otherFieldName = item.getFieldName();
String otherFieldValue = item.getString();}}

(...)

out.println("<html>");
out.println("<head>");
out.println("<title>Processing get requests with data</title>");
out.println("</head>");

// body section of document
out.println("<body>");
while ((strLine = br.readLine()) != null) {

// Print the content on the console
out.println(strLine + "</br>");
 }
 out.println("</body>");

 // end of html document
 out.println("</html>");
  out.close();

  } catch (Exception e) {
 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
 };
 }

This actually prints the content of file in a new page. I tried to give the same name of text area and the “String name = request.getParameter(“textinputarea”); “..

Thanks for your time!

  • 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-27T23:55:06+00:00Added an answer on May 27, 2026 at 11:55 pm

    All form fields are available in this else block which you completely ignored in the postprocessing.

    } else {
        String otherFieldName = item.getFieldName();
        String otherFieldValue = item.getString();
    }
    

    Don’t ignore it. Those values represent the name=value pairs of regular form fields.

    Note that you cannot use getParameter() on a multipart/form-data encoded request. That’s exactly why you were using Apache Commons FileUpload to extract the file. You should use the same API to extract the other parts of a multipart/form-data request.

    See also:

    • How to upload files to server using JSP/Servlet?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a single instance application (as per this answer ), but
I have a multi-page ascii file, and I need to be able to separate
In my jsp page, I need to upload files, images, Word Documents, Excel sheets,
I need a way to limit the meta box to a single page (ID=84)
i need to implement two different stylesheets in a single master page. one style
i need single file wsdl, how to build single file wsdl? Thanks.
I need to create a single trace file that spans several days for one
I have a very basic ASP.NET web site. It has a single page (TestPage.aspx)
I have a simple page with a single rendered iFrame. There's a link called
I have an ASP.NET Site that has a single Master Page. On one of

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.