OK, I tried this thing out & got the strangest exception Ive ever seen. Here's the exception:
500 Servlet Exception
java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.Toolkit$2.run(Toolkit.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:503)
at javax.swing.ImageIcon.<init>(ImageIcon.java:77)
at javax.swing.ImageIcon.<init>(ImageIcon.java:103)
at thumbTest.doPost(thumbTest.java:19)
at thumbTest.doGet(thumbTest.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
at com.caucho.server.http.Invocation.service(Invocation.java:325)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:333)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:266)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
AND here's the code I used:
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.swing.*;
public class thumbTest extends HttpServlet{
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType ("text/html");
PrintWriter out = res.getWriter();
String photoName = "testPho.jpg";
ImageIcon ii = new ImageIcon("/adPics/"+photoName);
int height = ii.getIconHeight();
int width = ii.getIconWidth();
double imagePercentage = 0.0;
if (height > width){
imagePercentage = 125 / height;
}
else{
imagePercentage = 125 / width;
}
out.println("<img border='0' src='/adPics/"+photoName+"' WIDTH='"+width * imagePercentage+"' height='"+height * imagePercentage+"'>");
out.println("<br>�<br>");
out.println("<img border='0' src='/adPics/"+photoName+"'>");
}
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
doPost(req, res);
}
};
Unfortunately I am not very good with swing so Im at a loss to see what is wrong here. It seems to be complaining about the intitialization of the percentage variable OR it's not finding the image & thats blowing it up because the variable is still 0.0. Should i use a ServletContext to get the path to the images??
[This message has been edited by DC Dalton (edited October 01, 2001).]