This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Dertermine Image Width & Height Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dertermine Image Width & Height" Watch "Dertermine Image Width & Height" New topic
Author

Dertermine Image Width & Height

hasan wasif2k1
Greenhorn

Joined: Jan 13, 2001
Posts: 26
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);
%>
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dertermine Image Width & Height