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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:57:42+00:00 2026-06-02T00:57:42+00:00

This was a question about testing file upload functionality using a local java server

  • 0

This was a question about testing file upload functionality using a local java server on Windows 7 platform. Since the question evolved with Marko’s input, I have edited it, so that those who run into the same challenge do not waste time on evolution details and reach conclusions sooner.

The challenge was to direct uploaded file to a folder outside of the WAR structure and successfully read it from there. For example: upload an image into c:/tmp/ and then redirect to a confirmation page that displays the image <img src="c:/tmp/test.jpg" />. The upload worked but image would not be displayed. And based on Marko’s input, this makes sense because browser sitting at localhost will refuse to load anything from local disk structure using c:. Maybe these are security considerations similar to those with file input control where we cannot set a default path…

The following tag will work in a locally created .html file but when pasted into a jsp, it won’t work. And the difference is that browser uses localhost to get to the jsp.

<img src="c:/tmp/test.jpg" />

Solutions

I think that Marko’s answer pretty much defines what needs to be done. While I didn’t go with that approach, it clearly is the better way to do it and I will accept that as the answer. Thanks, Marko!

For those who don’t want to bother installing a Web server and are willing to live with a bit of a hack, here’s what I have done. Again, I didn’t want to upload files into my WAR structure because I would then need to remember about clearing that folder before deploying to the server. But that upload folder still needs to be accessible, so I simply created another dummy project and put that upload folder under its WebContent. This works for the purposes of my local testing. The only nuisance is that after uploading a file, I need to refresh the dummy project’s WebContent in Eclipse.

config.properties

#for uploading files
fileUploadDirectory=C:/javawork/modelsite/tmp/WebContent

#for building html links
publicFileServicePrefix=http://localhost:8080/tmp

<img src="http://localhost:8080/tmp/test.jpg" />  // this works - tmp is the name of my dummy project.
  • 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-02T00:57:43+00:00Added an answer on June 2, 2026 at 12:57 am

    If you are citing literally the HTML that goes to the browser (the one that you access via “vieew source”) then this has nothing to do with Java. The browser is the one who interprets these links. If they fail to load, the problem is in the browser/file system.

    UPDATE

    According to the results of your additional diagnostics, I conclude that the browser (sensibly!) refuses to load anything from your local disk if it is referenced from an HTML file coming from an internet URL, even when that URL is localhost.

    UPDATE 2

    (Deleted, irrelevant)

    UPDATE 3

    However you handle the files uploaded to the server, it’s definitely not going to look like your solution — the file is on the server’s local filesystem, not client’s. This sort of thing can be handled at the Apache HTTP server level — reserve an URL section for static content and configure Apache with a base directory from which to serve the static content. Even if you run the server locally, on the same machine where you test it, you still need to go through the network interface.

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

Sidebar

Related Questions

I asked a question about different testing frameworks yesterday. This question can be found
This question about Timers for windows services got me thinking: Say I have (and
I have seen this question about deploying to WebSphere using the WAS ant tasks.
This is sort of the Java analogue of this question about C# . Suppose
Followed this question about delayed_job and monit Its working on my development machine. But
Follow up to this question about GNU make : I've got a directory, flac
JD Long helped me with this: question about manual annotation . But is it
A few days ago I asked this question about jquery ajax function invoking action
This question is about programming small microcontrollers without an OS. In particular, I'm interested
This question is about a data structure I thought of. It is a dynamic

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.