Discussions

Web tier: servlets, JSP, Web frameworks: applet-servlet communication with persistent connection?

  1. In my application(applet-servlet) I am using Http connection to communicate between applet & servlet
    (object based) & I have to open and close the connection for every request.
      Is there any way to re-use the http connection without closing the connection & Is it possible to maintain session
    in this applet-servlet communication.
         thanks in advance
  2. Hi,
    The answer is: yes, you can mainiant the connection open. But I would not recommend this because mainianing an open connection for every client might need a many resources on yur server. I imagine that you want to keep the connection open so that the server could notify the client about some events. A simmillar behaviour can be obtained by periodically polling the server for new events.
    Best regards, Mircea
  3. thanks Mircea Crisan
     
     I want to use persistent connection only because
    the no. of Users of my application are less & number of
    request's by each User are more, so how can I use a
    persistent between applet & servlet, please help
    me in this regard
        thanks in advance
     
      krishna kishore
  4. applet-servlet communication[ Go to top ]

    Hi,

    I also need to make a connection to communicate between applet & servlet.
    Can you send me some source code about how you are doing this communication?

    Tks in adv,
    Paulo Benfatti
  5. In My Application , i need to open a connection between Applet And Servlet using URlConnection

    So in the Applet when the user press on the button , i want just to open a coonection with the servlet which just print ant statement , by using the following code

    private void Send_actionPerformed(ActionEvent e)
      {
        try{
            URL url_base = getCodeBase();
            String strHost = url_base.getHost();
            String strPath = url_base.getPath();
            int inPort = url_base.getPort();
            URL ServletURL = new URL("http://"+strHost+":"+inPort+strPath+"servlet/ServletServer");
               
            URLConnection conn = ServletURL.openConnection();
            conn.setUseCaches(false);
            conn.setDoOutput(true);
            OutputStream out = conn.getOutputStream();
            ObjectOutputStream objOut = new ObjectOutputStream(out);
            objOut.writeObject(new String("Just Test"));
            objOut.flush();
            objOut.close();
        }
        catch(MalformedURLException mue){
        mue.printStackTrace();
          System.out.println(mue.toString());
        }
        catch(IOException ioe){
        ioe.printStackTrace();
         }
        
      }



    so when i execute the prev code no action happen in the servlet , i print the url and it return the right servlet url but i don't know why the servlet didn't response so please help me