Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Image Creation

 
Thomas Andrewsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I want to dynamicaly create a image depending on the user logging in and is resource consumption, but i don't want to store the image in any temporary location, but it must be part of the dynamic html contetnt the user is viewing. The image won't be reused. Could anybody guide me on this.


regards,
Siva
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but I don't have any sample code on me.
Basicaly you write a servlet which accepts requests for images, dynamically generates one based on the user information, then encodes and streams it directly to the user. Nothing is stored locally.

Dave
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look for link to addressbook in my signature. You will find class Challengeimage in sources. This class dynamically produces an image and display it on page. I use a front controller pattern, but you can consider this class as a servlet.
 
Thomas Andrewsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I want to embeed the image with html text
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servers don't send text and images in one response.
Send the HTML with an image tag.
The browser will create a new request for the image and assemble the page.
 
Thomas Andrewsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the image is dynamically created, how to give link in the image tag
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Siva J"
Please change your display name back or your account will be deleted. Please don't play around with display names, we take them very seriously.

thanks,
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet will return the image, so just link to the servlet in the image tag. The browser will send a separate request to load the image from the Servlet.
 
Darren Edwards
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet A returns


Servlet DynamicImageServlet sets the content type to image/png and streams the image to the client.

As other people have pointed out - the key here is it happens with 2 http requests, not 1.
 
Thomas Andrewsen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks for ur help it sloved my problem.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm about to be in the trouble he's been through... Hehehe I'll post on another thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic