Hi,
I have a problem.
The problem is that i want to pass the parameter from the java class to a servlet. Hence i am using URLConnection object
When was trying with only sending parameter i.e. having
setDoOutput(true);
setDoInput(false);
, the servlet was not getting called.
And when i tried with setDoInput(true); and using an InputStream object it gives me an error:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.0.63:8080/Examples/TestServlet
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
String myUrl = "http://192.168.0.63:8080/Examples/TestServlet";
System.out.println("Url : "+myUrl);
URL u = new URL(myUrl);
URLConnection uc = u.openConnection();
System.out.println("URLConnection");
uc.setDoOutput(true);
System.out.println("setDoOutput");
uc.connect();
System.out.println("connect");
OutputStream out = uc.getOutputStream();
System.out.println("OutputStream");
System.out.println("Data is : "+"action=performtask&message="+Data).toString());
out.write(("action=performtask&message="+Data).getBytes());
InputStream stream = uc.getInputStream();
BufferedInputStream in = new BufferedInputStream(stream);
int i = 0;
while ((i = in.read()) != -1) {
System.out.write(i);
}
in.close();
out.close();