I have server running in JBOSS. there is a Filter which alistenes to all the requests i.e all the requests come to the Filter and are passed on to other Servlets from here. I have noticed this : 
 When I use the following code, only the filter is invoked but the control is not passed on to the respective Servlet(The filter prints the correct servlet when I print using request.getRequestURI(). It also prints correct value of the request headers username and password)
 HttpURLConnection connection=gs.getconnection("send_user_detail");
          connection.setRequestProperty("user", gs.get_login_id());
          connection.setRequestProperty("password", gs.get_pass());
        connection.setRequestProperty("timezone", TimeZone.getDefault().getDisplayName());
            connection.connect();
BUT when I use the following code, the control is passed on to the respective Servlet and works fine.
 HttpURLConnection connection=gs.getconnection("send_user_detail");
          connection.setRequestProperty("user", gs.get_login_id());
          connection.setRequestProperty("password", gs.get_pass());
        connection.setRequestProperty("timezone", TimeZone.getDefault().getDisplayName());
            //connection.connect();
 ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream());
          out.writeObject("string"); //some random string not used in the servlet
So the control is only passed on to the servlet when I write something on the OutputStream. But with connection.connect(), it still goes up to the filter and even prints the correct name of the requested Servlet. What is the reason?
 
     
     
    