Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp and the Image object  RSS feed

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server may not have X11 installed.
hth,
bear
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!