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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:42:27+00:00 2026-06-13T07:42:27+00:00

I upload an image from hard drive and then store it in some folder

  • 0

I upload an image from hard drive and then store it in some folder in my app.
But the image isn’t displayed immediately on my JSP, it is displayed only after I restart the app.
I guess that’s because when the app resources are loaded, required image file doesn’t exist in the destination folder yet.
So, I think that reloading app resources programmaticaly immediately after storing the image file into the destination folder will solve my problem, but I don’t have a clue how to do it.

Update 1:
Part of jsp were the image is asked for:

<img src="${pageContext.servletContext.contextPath}/img/${imageUrl}" />

where imageUrl is the image file name with it’s extension.

The images are stored in MyProject/src/main/webapp/img/

Could anyone help me?
Thanks in advance.

  • 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-13T07:42:28+00:00Added an answer on June 13, 2026 at 7:42 am

    I see.. Thanks.

    Here is what happens (IMHO 🙂 ) :

    During the JSP processing the variable gets resolved to some static path and gets passed to the browser.

    Browses renders the static content here, once it sees the path it issues additional http request to the server, but it seems like your server can’t find your image statically.
    Its due to the fact that you Can’t change the war physical structure once it gets deployed.
    Think just like you work with a file based representation of WAR and not with exploded directory.

    Now what you can do?

    Try to create a resource servlet that will get the request to bring the binary image and will return it.

    Register this servlet in your web.xml with path like,say, /resource and make it get the get parameter imgName

    Example

    <img src="resource?imageName=${imageNameYouWant}" />

    In your jsp instead of static content in img src tag call the servlet with image as a parameter.
    When browser sees this it issues a regular request like before but this time it gets processed by your resource servlet and it will bring the image.

    Another thing I would try is just to move the images folder outside the webapp directory.
    This directory is tracked by your web container automatically but there is no reason to store the images there as well.

    You do like this:

    1. Create a directory like: /myapp/images

    2. You’ll still need to create some component on the server side. But this time it can probably be done by creating some configuration on the web server side (no custom servlet).
      I’m not sure this will work when you use the first approach…

    3. In JSP point on the server as I’ve already explained above.

    It its an enterprise serious application I would recommend the first approach in conjunction with storing the images in the database but its a different story 🙂

    Hope this helps

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

Sidebar

Related Questions

i am trying to upload an image from a jsp page using servlet. but
I want to upload an image from my hard drive, using an html form:
It would be great if I could upload an image from my hard drive
I upload an image from my site and it loads in a folder debatepic
i want to upload an image from the client's system, through javascript and store
I am basically tring to upload image from android and upload it to php
Are there any existing add-ons which would provide the functionality Upload image from local
I am trying to upload an image from inside a JQuery modal. The form
I'm using PHP to upload an image from a form to the server and
Im struggling here for a lot, Im trying to upload an image from iphone

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.