Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying Graphics in browser

 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a charting applet to display a line trend chart in a browser window, however the user cannot right click on the chart and save it as a gif image. I have the acme gif encoder, however the examples i have only work for writing the encoded gif to a file on the server (using a servlet). I would like to know if using an applet only, the image can be displayed directly in the browser window for the user to save.
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff,
You say you are able to write the gif file to the server. Is it possible to also write an html file to the same directory on the server? This html file could contain just the gif image (using the <IMG> tag). If so, all you would have to do is add a View Image button to your applet to link to that html page. Once the user is on the page, they could right-click to save the gif image.
Here is some code to link to a new page:

I hope this helps.
If not, please let us know.
Stephanie
 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply...
I guess i was hoping i could do this entirely in an applet since if i create a file on the server and then display it, i would need to delete it from the server when the user was finished. I could have many users creating files on the server. I was trying to figure out how to use a BufferedOutputStream instead of a FileOutputStream and then display the buffer in the applet window.
 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I love the idea of using a mouse listener to see if they click one the image. Thank you very much. I will check out the links.
 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Stephanie. I checked the links you gave and they all seem to create a .gif file on the server before dislaying it. I was hoping there was a way to store the image in a buffer in memory on the client and display it as an image without actually creating a file on a server. I thought it might store the buffered in the cients Temporary Internet Files directory on their local C: drive.
Thanks again... You have been most helpful.
By the way... I really am a greenhorn.
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff,
Thanks for the clarification. I guess I didn't fully
understand your original question. And your concerns
about the server are very valid.
So you want to use only the applet to save the gif representation
of your chart. Unfortunately (and I'm sure you don't want to
hear this) I don't think there's any simple, pre-built way to
do so. I think it can be done however. I would approach it
like this:
(1) Make your applet a mouse listener so it can handle the
right mouse click.
(2) Make a method to write the gif file to the applet user's
machine when they right-click.
Here are a couple of links I found that supposedly
do this:
http://forum.java.sun.com/read/16800583/q_2OS6i923tQAAZRk#LR]http://forum.java.sun.com/read/16800583/q_2OS6i923tQAAZRk#LR
http://forum.java.sun.com/read/16801159/q_LY5EyHdPjAAAYec#LR]http://forum.java.sun.com/read/16801159/q_LY5EyHdPjAAAYec#LR
If neither of these pan out for you, I think Java Advanced
Imaging package has some image file writing capabilities.
Just look at Sun's site for documentation.
(3) Attempting to save a file on a user's machine gets you into
security issues. Here is a link to tell you how to handle this:
http://developer.java.sun.com/developer/onlineTraining/Security/Fundamentals/Security.html#secExtendingBrowserPrivs
I hope this is helpful.
If you are still having problems, please let us know.
Thanks for posting.
Stephanie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic