• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dertermine Image Width & Height

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Showing blank when executing this code
<%@ page import="java.awt.*" %>
<%@ page import="java.awt.Image.*" %>
<%
Frame frame=new Frame();
Image img=Toolkit.getDefaultToolkit().getImage("collage.gif");
MediaTracker tracker=new MediaTracker(frame);
tracker.addImage(img,0);
int clientwidth=img.getWidth(frame);
int clientheight=img.getHeight(frame);
out.println("Width is "+clientwidth);
out.println("Height is "+clientheight);
%>
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You forgot tracker.waitForID( 0 );
You can not use the simple "collage.gif" form because you don't know what the JVM's current directory is - use a complete file address.
If you didn't see the Width= message, I bet you threw an IOException and didn't catch it.
Declaring an errorPage is your friend when debugging JSP.
Bill

------------------
author of:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic