title: Passing String parameter and object in Post request to a RESTful service
body: <p>I have a client side method:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public static void main(String[] args){
      mediaTracker = new MediaTracker(frame);
  
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      frame.setSize(dim.width, dim.height);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
  
      setFullScreen();
  
      RSACipher rsaCipher = new RSACipher();
      // client side code
      RSAKeyPair keyPair;
      try {
          keyPair = new RSAKeyPair(2048);
  
          String servletURL = "http://localhost:8080/AesRsaEncryptionServiceRest/aesrsarest/doc/encryptionservice?pkey=pkey&amp;skey=skey";
  
          Gson gson = new GsonBuilder().create();
  
          URL servlet = null;
          try {
  
              servlet = new URL(servletURL);
              System.out.println("Sending request to " + servletURL);
              HttpURLConnection servletConnection = (HttpURLConnection) servlet.openConnection();
              servletConnection.setRequestMethod("POST");
              servletConnection.setDoOutput(true);
              servletConnection.setDoInput(true);
  
  
              //send the keys to the server
              ObjectOutputStream objOut = new ObjectOutputStream(servletConnection.getOutputStream());
  
              objOut.writeObject(keyPair.getPublicKey());
  
              objOut.flush();
              objOut.close();
  </code></pre>
  
  <p>In line <code>ObjectOutputStream objout</code>, I passed the publickey needed for encryption. I want to know, if it's possible to pass a String parameter with object to post method?</p>
  
  <p>I tried to create a new object, then I put the String parameters and the public key object and passed to an object stream, but it did not work. I needed the String parameters for passing the filename to be encrypted using the RESTful service</p>