File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to write dynamic images to web server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to write dynamic images to web server?" Watch "How to write dynamic images to web server?" New topic
Author

How to write dynamic images to web server?

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
I have a module for creating images dynamically, which is not a servlet. I'm trying to store the images on web server and return their URLs back to client. My question is how can I get to know the path of WebContent from my module. I hold a reference to the HTTPRequest, does it help? Or should I treat it a same process as client uploading images to server?

Thanks.


To be or not to be. It's a question.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Louis Wang wrote:I have a module for creating images dynamically, which is not a servlet. I'm trying to store the images on web server

Exactly how are they being stored?

My question is how can I get to know the path of WebContent from my module

What is "WebContent"? A folder? TellTheDetails please.

I hold a reference to the HTTPRequest, does it help?

After the request is over? I hope not! Never hold a reference to a container object.

Essentially you treat it like any other image. The <ing> tag references a URL that serves the image data. That URL is usually to a static file or a servlet that streams the image data.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
Thank you Bear.

I intend to save images as files to the WebContent folder. The WebContent folder is where the static html pages located. It's supposed to be accessed by client through URLs.

For now I do it as below:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

OK, so if the file is being created on disk, how is it any different from any other image file? Just use an tag with a URL that addresses the file.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to write dynamic images to web server?