aspose file tools*
The moose likes Servlets and the fly likes need to upload a file in server path using servlets and retrieve that path in url format? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "need to upload a file in server path using servlets and retrieve that path in url format? " Watch "need to upload a file in server path using servlets and retrieve that path in url format? " New topic
Author

need to upload a file in server path using servlets and retrieve that path in url format?

Suresh Entropy
Greenhorn

Joined: Nov 29, 2012
Posts: 3
hi all... I need to upload a file in server path and again i need to retrieve that file path into URL so that i show the file in jsp page using that converted URL... Suggestions and examples please..

regards,
Suresh
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1778
    
    7

You can upload an image (or any file really) using an HTTP POST request with a multipart/form-data content type. Handling such a request on the server-side can be made easier by using a library like Apache Commons FileUpload. Once you've extracted the image data from the request you can store it in anyway you like. You could for instance place it in a shared image folder as a file and serve it to incoming HTTP requests from that location.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Suresh Entropy
Greenhorn

Joined: Nov 29, 2012
Posts: 3
I am already done with uploading the file in my local location, i need to have it in my server location is one thing, and another i need to fetch that server location to get converted to URL. I need this conversion in order to view that uploaded file via URL.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Suresh Entropy wrote:I am already done with uploading the file in my local location, i need to have it in my server location is one thing, and another i need to fetch that server location to get converted to URL. I need this conversion in order to view that uploaded file via URL.

I think you should place your uploaded files somewhere on your server so that the files can be accessed through HTTP.


PM Me If You Want to get Urgent Help on Java Programming
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
As a matter of security, servers are restricted in terms of the file paths they are allowed to access and URLs never reflect the absolute file location on the server but are always translated.

It would be a huge security hole if a URL could access an arbitrary file path.

this subject is frequently addressed in this forum.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: need to upload a file in server path using servlets and retrieve that path in url format?