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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:41:26+00:00 2026-06-15T19:41:26+00:00

I am trying to display an image stored at local file system outside my

  • 0

I am trying to display an image stored at local file system outside my webapp.
following question: Simplest way to serve static data from outside the application server in a Java web application

EDIT: I want file to be outside the webapp cause these images are uploaded by user, If I put them inside webapp, I might loose them when I redeploy the web app

but the file is not being displayed on the webpage. When I try opening the file through: localhost:8080/images/imageName.jpg it gives me a resource not available error.

I have added the context in my server.xml (traversing throug Servers->Config->server.xml) :

 ........
 <Context docBase="DMSystemV1.0" path="/DMSystemV1.0" reloadable="true" source="org.eclipse.jst.jee.server:DMSystemV1.0"/>
      <Context docBase="/Projects/SpringExample/Images" path="/images"/>
      </Host>

Also my web.xml looks like this:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/static/*</url-pattern>
   </servlet-mapping>
   <servlet>
    <servlet-name>DMSystem</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>DMSystem</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

The place where I want it to get displayed: <img src="/images/${imagePath}" alt="Item's image">

Mytomcat is in: F:\Software\Servers\tomcat7\tomcat7
While the image folder is: F:\Projects\SpringExample\Images

Is the image path is taken relative to the tomcat folder?

Also,write now I am hard-coding the upload path (in my upload servlet) and download path in server.xml, is there a way to provide them as confign or set up info?

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

    Simplest solution would be to copy the image and serve it on your web-app root. However if this solution doesn’t suit you for whatever reason, you can always create a servlet to ‘proxy’ your image:

    Create a servlet, map it to a path, for example:

    <servlet-mapping>
      <servlet-name>imageProxyServlet</servlet-name>
      <url-pattern>/imagesproxy/*</url-pattern>
    </servlet-mapping>
    

    Then on your servlet class, do a file IO to read your picture, and then write it to the response. Don’t forget to set appropriate content type, and use buffered read/write to avoid blowing your memory if the image is large.

    Then you can serve your image as http://mydomain.com/myapp/imagesproxy/something.jpg. Request to that URL will be dispatched into the images proxy servlet

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

Sidebar

Related Questions

I'm trying to display image data read in from a binary file (I have
I am trying to display an image in a gridview, however, the columns that
I am trying to display an image in NSImageView. However when I place an
I'm trying to display an image in a WebView in an Android app. The
So I'm trying to display an image that is ouside the path of my
I'm a beginner to the iOS development, and I'm trying to display an image
I am trying to display a GIF image in my GUI, and it doesn't
I am trying to display a Loading Image in a new JFrame when the
Im trying to hide a specific image in mouse over and display another image.
I am trying to display a bytearray as a resized image. The Image is

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.