jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes using servlet to generate png image file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "using servlet to generate png image file " Watch "using servlet to generate png image file " New topic
Author

using servlet to generate png image file

Alan Yap
Ranch Hand

Joined: Feb 24, 2006
Posts: 32
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 ]

When I'm not coding.. I do THIS
Ali Hussain
Ranch Hand

Joined: Jun 19, 2005
Posts: 211
This link might be useful for you: Generating images with JSP/Servlet


- SCEA, SCJD, SCBCD, SCWCD, SCMAD, SCJP, ICAD (WebSphere), Lotus Principal CLP, Lotus CLP, Lotus CLS
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

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 ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Alan Yap
Ranch Hand

Joined: Feb 24, 2006
Posts: 32
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
Marshal

Joined: Mar 22, 2005
Posts: 41129
    
  45
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.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using servlet to generate png image file
 
Similar Threads
A Challenge!
Google India CodeJam
acronym atrocity
13 Nov Riddle
How many Brits and Europeans on this board?