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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:42:24+00:00 2026-06-05T19:42:24+00:00

I have never saved and retrieved an image to and from the database before.

  • 0

I have never saved and retrieved an image to and from the database before. I wrote down what I guessed would be the process. I would just like to know if this is correct though:

Save image:

  1. Select & Upload image file from jsp (Struts 2) which will save it as a .tmp file.
  2. Convert the .tmp file to a byte[] array (Java Server-Side)
  3. Store the byte[] array as a blob in the database (Java Server-Side)

Get image:

  1. Get the byte[] array from the database (Java Server-Side)
  2. Convert the byte[] array to an image file (Java Server-Side)
  3. Create the file in a location (Java Server-Side)
  4. Use an img tag to display the file (JSP Client-Side)
  5. Delete the file after it’s finished being used? (Java Server-Side)

I’m aware of the fact that it is highly recommended to not save & retrieve images to and from the database. I would like to know how to do it anyway.

Thanks

  • 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-05T19:42:27+00:00Added an answer on June 5, 2026 at 7:42 pm

    Almost correct.

    It’s expensive and not so great to create the file on the fly and then delete it.

    Yes, you store it as the raw bytes in the database, but the way to retrieve it and display it to a client machine is to implement a web handler that sets the content-type of the response to the appropriate MIME type and then dumps the bytes out to the response stream.

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

Sidebar

Related Questions

I have never done any Windows coding and I would like to give it
I have never programmed a gadget for Vista or Seven, but I would like
I have never programed in bash before. I am reading all the files that
I have never used Foxpro before. Can you convert the following Foxpro code into
I have never made a blog before. I am proficient with html and css.
I have never come across this issue but most recently I noticed that a
I have never thought about until recently, but I'm not sure why we call
I have never used Perl, but I am really impressed by the ack ,
I have never really done much C but am starting to play around with
I'm trying to create a temporary file from an entry in my database. I

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.