• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question about jpegs/gifs in jsps

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm using an image-map in my jsp page for the purpose of selecting the column you want in a connect 4 game.
I'm using a GIF file at the moment for the image-map.
The jsp page calls a sevlet to update the board.
What I want to do (not sure if its possible) is (in the jsp) create a
BufferedImage object inside a scriptlet, then construct a GIF from this, and then again, use this GIF in the image-map.

Again, I'm not sure if its this simply, currently I just have 1 GIF in the same directory as the jsp page.

Does anyone know how I can do this?
Thanks very much
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you cannot generate an image in the same request as the JSP. The JSP page should contain an img tag that references a servlet that produces the image.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Bear: colin, I accidentally removed your post. Sorry about that! Some of it is quoted in my reply. My bad!]
[ December 27, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<hr></blockquote>

You would replace the src attribute value with the servlet reference.

can you show me how to create an image in a servlet



This is not an appropriate venue for image generation discussion. Search the other forums and the web for examples. For simple images you can probably use AWT; more advanced images might require JAI.
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a rather dated article that could get you started.

More up-to-date examples using JAI should also be available on the web.
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An example image-generation servlet.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I've pretty much got it working.
Using the code in the previous link... my jsp page contains:


instead of src="gifFile.gif"

The code in the program, puts a text label onto a gif.
I don't infact need a gif, I just need to draw some circles, and
a board.

I think I've covered the 2 main problems (this problem with creating new images, and the image-map problem), now I just need to write the program.

I'll keep you posted if I have any further difficulties.
Thanks
[ December 27, 2005: Message edited by: colin shuker ]
 
Fire me boy! Cool, soothing, shameless self promotion:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic