How to access a servlet in Tomcat Contanier using Java
when you are sending any data to the servlet make sure it you send it via POST/GET depending on how sensitive the information is. In your case the user and password is sent through the get which is unsafe since it can be viewed by anyone. 

you can add.urlConnection.setRequestMethod("POST"); Also to get the response you have to send the request first , which in your case is missing.

dataInput= new DataOutputStream(urlConnection.getOutputStream());
String content = "param1=" + URLEncoder.encode("first parameter") 
         + "&amp;param2=" 
         + URLEncoder.encode("the second one...");

dataInput.writeBytes(content);
dataInput.flush();
dataInput.close();