This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write dynamic images to web server?

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic