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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:05:18+00:00 2026-06-03T22:05:18+00:00

I am using JSP form to upload and Servlet to store a large-sized file

  • 0

I am using JSP form to upload and Servlet to store a large-sized file in a MySQL database. and because i am new to Java in general, i need a really urgent help.
I tried to store the file in a String value but i got error that string index is out of boundary.

I have the database table Files which has (varchar File_Name, Blob File_data, Varchar File_Date) .
And i need to store the uploaded file inside the

I had this code in servlet:
** BTW : i have no idea why “DiskFileUpload, parseRequest ” have strikethrough line ?

 try {
         InputStream uploadedFile = null;

         <strike>DiskFileUpload</strike> fu = new </strike>DiskFileUpload</strike>();
        // If file size exceeds, a FileUploadException will be thrown
        fu.setSizeMax(10000000);

        List fileItems = fu.<strike>parseRequest</strike>(request);
        Iterator itr = fileItems.iterator();

        while (itr.hasNext()) {
            FileItem fi = (FileItem) itr.next();

            //Check if not form field so as to only handle the file inputs
            //else condition handles the submit button input
            if (!fi.isFormField()) {  // If the form fiel is a file
                uploadedFile = fi.getInputStream();
            } 

What type of data should I convert uploadFile cvariable to be able to store it in a Blob attribute ?

  • 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-06-03T22:05:20+00:00Added an answer on June 3, 2026 at 10:05 pm

    Strike through means API is deprecated and those classes/methods may not work as expected.

    Storing file to database, you need to store the content as bytes in blob filed. See this discussion. Even though it is related to some error, OP posted code on how to do this.

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

Sidebar

Related Questions

How can I upload files to server using JSP/Servlet? I tried this: <form action="upload"
I need to upload a file in a database using an input form in
I am using dojox.form.FileUploader to upload a file. I am sending username alongwith the
I am developing a java webapp, using jsp/jquery/ejb/jboss. I have a web-form that enables
I'm just experiencing JSP form Java, I'm using a Java *.java class, within this
I have a working Action and JSP form that I'm using for creating new
I'm using a Webphere server. I am performing a file upload through a servlet
In a web project using jsp, I have following requirement Upload a file (say
I am creating an user registration form using jsp,in which there is an option
Using IE 7, JDK 1.6 and Sun Web server 7. Inside the jsp form,

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.