This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using servlet to generate png image file

 
Alan Yap
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the title suggest, could anyone give me hints and pointers to get me started?



I've tried yahoo and google search with no concrete tutorial/examples in sight.
[ August 29, 2006: Message edited by: Alan Yap ]
 
Ali Hussain
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link might be useful for you: Generating images with JSP/Servlet
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Alan Yap

There some links to generate image file with example of source code
it might be helpful for you..

Create dynamic images in Java servlets
Using Servlets to Generate JPEG Images
Creating a Buffered Image from an image
Images - BufferedImage
[ August 29, 2006: Message edited by: Saif Uddin ]
 
Alan Yap
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys,

going through those links now.

Found some tutorials earlier on this too, using JSP. Tweaked their code a bit and it works in my machine (Resin 2.1 + J2SDK1.4.0).

But when uploaded into my hosting server to be tested, this exception pops up:
java.security.AccessControlException: access denied (java.io.FilePermission
/tut/z.png delete)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkDelete(SecurityManager.java:990)
at java.io.File.delete(File.java:869)
at javax.imageio.ImageIO.write(ImageIO.java:1482)
at _pngwrite__jsp._jspService(/tut/pngwrite.jsp:19)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:595)

While waiting for the hosting to get back to me on this issue, I was wondering if this is caused by the restriction imposed by the hosting, or should I tweak my code a bit more to fix it ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a hosted environment you won't have access to the complete file system, just to your personal space or web app directory. That most likely does not include a top-level directory called "/tut". You'll need to save the image in a directory that's part of your environment there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic