Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using javax.imageio in JSP

843836May 17 2004 — edited May 17 2004
Hi

I have a simple code snippet that I use to read in JPG/GIF image from a file and create a new image that is upside down . Here is my snippet.
//create upside down image
try {
String imgPath = "\\images\\AINCC.gif";
File fImg = new File(imgPath);
BufferedImage imgREG = ImageIO.read(fImg);

int iW = imgREG.getWidth(null);
int iH = imgREG.getHeight(null);

// Flip the image vertically and horizontally (equivalent to rotating the image 180 degrees)
AffineTransform tx = AffineTransform.getScaleInstance(-1.0,-1.0);
tx.translate(-iW, -iH);
//tx.scale(0.8,0.8);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
BufferedImage imgUSD = op.filter(imgREG, null);
// write flipped image to a file
File fUSD = new File("images\\USD_image.tmp");
ImageIO.write(imgUSD,"jpg",fUSD);
}
catch (Exception e) {
e.printStackTrace();
}

If I use this in a stand alone Java app it works fine but it will not work from the JSP page....
I have updated my server.policy file to give /images directory read, write, delete priviledges and I tried all the variations of the path (relative, absolute, direct....)...

I get the following error from the server log:
[#|2004-05-17T13:47:56.173-0400|WARNING|sun-appserver-pe8.0|javax.enterprise.system.stream.err|_ThreadID=11;|
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(ImageIO.java:1263)
at org.apache.jsp.ecards.mailcard_jsp._jspService(mailcard_jsp.java:125)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:141)


Can someone tell me what am I missing....
My JSP page is mailcard.jsp and images are under it in the images subdirectory....


Thanks
Amir
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2004
Added on May 17 2004
1 comment
254 views