tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mantri, Mr Ramesh" <>
Subject FileNotFoundException from servlet
Date Thu, 06 Jul 2000 15:24:39 GMT
Dear all,

When we try to send an image file from servlet to applet, for some
reason it is throwing a FileNotFoundException. Do we need to configure
images separately in tomcat? The documentation doesn't say so.

In any case I am appending below a few lines of code. Please take a
look at it and try to identify the source of the problem. All the files
(including image files) are in the proper locations.

public class testImage extends JApplet {
   public void init() {
      try {
         URL url = new URL("http://host:port/WEBAPP/servlet/testImage");
         URLConnection con = url.openConnection();
         ObjectInputStream objStr = 
                new ObjectInputStream(con.getInputStream());
         ImageIcon img = (ImageIcon) objStr.readObject();
         Container cp = getContentPane();
         JLabel lbl = new JLabel(img);
      } catch (Exception e) {

public class testImage extends HttpServlet {
   public void doGet(HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException {
      URL url = new URL("http://host:port/WEBAPP/images/someImage.gif");
      ImageIcon img = new ImageIcon(url);
      ObjectOutputStream out = new

Exception Stack Trace
===================== http://host:port/WEBAPP/servlet/testImage
at<init>(Compiled Code)
at<init>(Compiled Code)
at Code)

Also, allow me to add that another test applet and servlet which pass only
String data are working fine. That causes us to suspect that it could be a 
problem caused due to the transmission of image data from servlet to applet.

Ramesh Mantri

View raw message