Hi all,
I'am not sure what i am up against here. In my application ( three tier)
the applet communicates with the sevlet using the URLConnection. In the
applet the user invokes a JDialog on the click of a button, enters a
query and clicks on 'OK'.
within the JDialog i handle this event. I connect to the servlet using
the URLConnection and object streams.
This invokes the servlet's doPost method. The servlet reads the object
from the applet makes a connection to the database and sends the vector
of object stream to the applet. The applet receives this and displays.
Everything works fine till here. I can keep querying any number of
times.

Now the user does some changes (update, delete, insert) These changes
are stored within the vector. In the applet on click of save button I am
again establishing
a connection to the servlet and sending the vector. The vector is being
sent.
But at the servlet end their is no response. Servlet is not receiving
it. The dopost is not being invoked.
How do I overcome this problem.

My do post code looks like this:

 public void doPost(HttpServletRequest request,
                        HttpServletResponse response)
           throws ServletException, IOException
    {
log(" Entering servlet do post method ");
        ObjectInputStream inputFromApplet = null;
        PrintWriter out = null;
        BufferedReader inTest = null;
        boolean didit = false;

        ObjectOutputStream outputToApplet;

        try
        {
            // get an input stream from the applet
         inputFromApplet = new
ObjectInputStream(request.getInputStream());
         log("Connected to the servlet");

         // read the serialized student data from applet
         log("Reading data...");
         Vector reqMainVect = (Vector)inputFromApplet.readObject();
          log(" The main vector from applet received, size = " +
reqMainVect.size());
          log(" The main vector first element = " +
reqMainVect.firstElement());
          log(" The main vector first element = " +
reqMainVect.lastElement());

          Vector commandVect = (Vector)reqMainVect.elementAt(0);
          Command = (String)commandVect.elementAt(0);
          log(" the string read from the applet " + Command);

         Vector reqSelectVect = (Vector)reqMainVect.elementAt(1);
          log(" The vector read from the applet " + reqSelectVect);
         show("Finished reading from the applet.");

         inputFromApplet.close();

          if(Command.equals("QUERY"))
          {
           log(" command is query , calling data accessor function");
           Vector reqtRows =
myDataAccessor.executeSelect(reqSelectVect);
           show("selected the req rows.");

                  try
                  {
                   outputToApplet = new
ObjectOutputStream(response.getOutputStream());
                   System.out.println("Sending requests record vector to
applet...");
                   outputToApplet.writeObject(reqtRows);
                   outputToApplet.flush();
                   outputToApplet.close();
                   System.out.println("Data transmission complete.");
                  }
                   catch (IOException e)
                   {
                  e.printStackTrace();
                   }


           log(" Returned back to do post after sending the requests
query records");
           Command = " ";
          }
          if(Command.equals("SAVE"))
          {
           log(" command is save , calling data accessor function");
           didit= myDataAccessor.executeSave(reqSelectVect);
          }
         log(" End of do post function, still working");
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
    }

I am closing all the streams. what am I missing in the dopost menthod.
Does the dopost method work this way. What happens at the servlet when a
a URLConnection is established from the applet each time. This is the
last stage of my project and I can't believe i got stuck. Please help,
my time is running out.

Thank You all in advance.
Bye.
-Kiran.

___________________________________________________________________________
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