This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Trying to retreive image width and height but no success. A Code is here but with errors. Pls help soon. <%@ page import="java.awt.*" %> <%@ page import="java.awt.image.*" %> <% Image img=Toolkit.getDefaultToolkit().getImage("a.jpg"); int w=img.getWidth(); %>
Images are loaded by a separate Thread so you can not immediately get the width and height. A MediaTracker will help you there. You can NOT put an image into a page from inside a JSP, all you can do is write the code that makes the browser load the image - look at the html tag for <img> - it takes a URL because the browser starts a separate Thread to load the image. Bill