• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about jpegs/gifs in jsps  RSS feed

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!