I have a servlet as below.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
try {
String requestLine = br.readLine(); // getting null
....
and I invoke the servlet from my client as below.
HttpURLConnection httpConnection = null;
PrintWriter pwr = null;
ObjectInputStream ois = null;
try
{
String serverURL = "http://localhost:8080/app/servlet1?id=2";
httpConnection = (HttpURLConnection)(new URL(serverURL).openConnection()); //opening the connection
httpConnection.setRequestMethod("POST");
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
httpConnection.setUseCaches(false);
pwr = new PrintWriter(httpConnection.getOutputStream());
pwr.println("inputValString");
pwr.flush();
//getting the streams
ois = new ObjectInputStream(httpConnection.getInputStream());
...
But, when I run the client code I always get requestLine
as null in the servlet.