Forums Register Login

jsp and the Image object

+Pie Number of slices to send: Send
I have a jsp page that displays an image. Before I display the image I determine its height and width so I can scale it so it is not distorted.
Here is my code.
Image image = Toolkit.getDefaultToolkit().getImage(directPath + File.separator + SysConst.albumDirectory + File.separator + compName + File.separator + album.getName() + File.separator + p.getPhotoName());
height = image.getHeight(null);
width = image.getWidth(null);
It works on my local machine but not the web host. With the web host I get the following error.

exception
javax.servlet.ServletException: sun/awt/motif/MToolkit
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java)
+Pie Number of slices to send: Send
The server may not have X11 installed.
hth,
bear
+Pie Number of slices to send: Send
Yep, it might be a 'headless' install, meaning it has no UI installed. AWT requires native support, so without a UI installed there is nothing to support AWT.
There is a solution though. I've managed to get it working using the eTek 'Pure Java AWT' package. You can grab it here. Be aware that this means you can have Images and Graphics contexts, but you might not be able to use Fonts.
Dave
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 992 times.
Similar Threads
lagging on loading image
servlet response does not show ssl insignia
Displaying images dynamically from database
session problem in one of the jsp
image width and height
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:39:07.