Hello,
I have a problem with applet to servlet communication. I try to get
information from a Acces database.

I get this message :
java.io.FileNotFoundException: localhost:80//servlet/DbServlet
 at com/ms/net/wininet/http/HttpInputStream.connect (HttpInputStream.java)
 at com/ms/net/wininet/http/HttpInputStream.<init> (HttpInputStream.java)
 at com/ms/net/wininet/http/HttpURLConnection.createInputStream
(HttpURLConnection.java)
 at com/ms/net/wininet/WininetURLConnection.getInputStream
(WininetURLConnection.java)
 at com/ms/net/wininet/http/HttpPostBufferStream.close
(HttpPostBufferStream.java)
 at java/io/FilterOutputStream.close (FilterOutputStream.java)
 at DbApplet.executeQuery (DbApplet.java:56)
 at DbApplet.actionPerformed (DbApplet.java:74)
 at java/awt/Button.processActionEvent (Button.java)
 at java/awt/Button.processEvent (Button.java)
 at java/awt/Component.dispatchEventImpl (Component.java)
 at java/awt/Component.dispatchEvent (Component.java)
 at java/awt/EventDispatchThread.run (EventDispatchThread.java)

The problem is probably this statement in the applet
 InputStreamReader in = new InputStreamReader(uc.getInputStream());

This is the Applet code:
       URL url = new URL("http://localhost/servlet/DbServlet");
         String qry = URLEncoder.encode("qry") + "=" +
                             URLEncoder.encode(qryString);

         URLConnection uc = url.openConnection();
         uc.setDoOutput(true);
         uc.setDoInput(true);
         uc.setUseCaches(false);
         uc.setRequestProperty("Content-type",
                             "application/x-www-form-urlencoded");

         DataOutputStream dos = new DataOutputStream(uc.getOutputStream());
         dos.writeBytes(qry);
         dos.flush();
         dos.close();

        InputStreamReader in = new InputStreamReader(uc.getInputStream());

         int chr = in.read();
         while (chr != -1) {
            taResults.append(String.valueOf((char) chr));
            chr = in.read();
         }
         in.close();

This is the Servlet code:
   public void doGet(HttpServletRequest req, HttpServletResponse res)
                              throws ServletException, IOException {
      PrintWriter out = res.getWriter();
      res.setContentType("text/html");

      if (initfault != null && initfault != " ")
        out.println(initfault);

     String qry = req.getParameter("qry");

    try {
         Statement s = dbCon.createStatement();
         ResultSet rs = s.executeQuery(qry);
         while (rs.next()) {
            out.println(rs.getString(1) + " -  " + rs.getString(2));
            out.println(rs.getString(3));
            out.println ("");
         }
      } catch (SQLException e) {
         out.println(e.toString());
         return;
      }
      out.println();
      out.close();
   }

Thanks in advance
Marjon

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to