I am about at my wits' end here with Tomcat on Debian.  I have an app called
Project.java, and all it should do is grab a file from the file system, and
output that on the browser window.  On my windows box, this works perfectly. 
I'm using jdk6 on the windows box, and gcj4.3 on the debian box.  My other
apps work fine, none of them working with ImageIO.  I will post the code for
the servlet below here.

The BOLDED line below is the one that, if uncommented, totally breaks my
server.  Like, if I travel to the URL, I get a server connection error, and
my entire Tomcat server shuts down.  If I leave out the ImageIO write line,
the application obviously doesn't do anything, but it does provide me a nice
blank browser window without crashing my entire server.  Why the hell is
this happening?

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.HttpURLConnection;
import java.lang.*;
import java.net.*;
import java.awt.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;


public class Project extends HttpServlet {
        public void doGet(HttpServletRequest request,HttpServletResponse 
response)
throws IOException, ServletException {

//              PrintWriter out = response.getWriter();

                try {

                        File myGifFile = new 
File("../webapps/geosim/WEB-INF/images/test.jpg");
                        if(!myGifFile.exists())
                                return;
                        BufferedImage bufi = ImageIO.read(myGifFile);
                        response.setContentType("image/bmp"); 
                        ImageIO.write(bufi,"bmp",response.getOutputStream());

/*

                        file = new 
File("../webapps/examples/servlets/images/android_new.jpg");
                        fis = new FileInputStream(file);

                        raw = new byte[(int)file.length() + 1];
                        fis.read(raw);
                        for(int i = 0; i<(int) file.length(); i++) {
                                out.println(raw[i]);
                        }

                        String imageData = new 
sun.misc.BASE64Encoder().encode(raw);

                        xml += imageData.length();
                        xml += "</imageSize><imageData>";

                        xml += imageData + "</imageData></image></status>";
                        out.println(xml);
*/
//                      out.println(raw);
//                      os.write(raw, 0, len);
                }
                catch(Exception e) {
//                      response.getOutputStream().println("error: " + 
e.getMessage());
//                      os.writeBytes("error: " + e.getMessage());
                }

        }
}
-- 
View this message in context: 
http://www.nabble.com/Debian-Tomcat-Fail-tp23734947p23734947.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to