Here we are using URLConnection class to open a connection.
System.err.println("@@W@Calling Test Servlet:: Called");
URLConnection uc = new URL("http://www.example.com/Test").openConnection();
uc.setDoInput(false);
uc.setDoOutput(true);
uc.setUseCaches(false);
uc.setDefaultUseCaches(false);
uc.setRequestProperty("Content-Type", "application/octet-stream");
ObjectOutputStream out = new ObjectOutputStream(uc.getOutputStream());
HashMap
hm.put("Key1", "Val1");
out.writeObject(hm);
out.flush();
out.close();