I am new in handling servlets and was trying to send data to my Servlet from android app,but dont know the exact way to read it in my servlet? In android i have used these to send data:
            URL url = new URL("http://example.appspot.com/testservlet");
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setReadTimeout(10000);
            conn.setConnectTimeout(15000);
            conn.setRequestMethod("POST");
            conn.setDoInput(true);
            conn.setDoOutput(true);
            Uri.Builder builder = new Uri.Builder()
                    .appendQueryParameter("firstParam", "Rahul")
                    .appendQueryParameter("secondParam", "Anil")
                    .appendQueryParameter("thirdParam", "Rohan");
            String query = builder.build().getEncodedQuery();
            OutputStream os = conn.getOutputStream();
            BufferedWriter writer = new BufferedWriter(
                    new OutputStreamWriter(os, "UTF-8"));
            writer.write(query);
            writer.flush();
            writer.close();
            os.close();
            conn.connect();
        }catch(Exception e){
           Exception exep= e;
            Log.d("Test",exep+"");
            return false;
        }
        Log.d("Test","Succesfully")
        return true;
After in servlet i wrote as:
@Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("text/plain");
            resp.setContentType("text/plain");
               String request=req.getParameter("firstParam");
               resp.getWriter().println("firstParam ::::::::::"+request);
    }
Is this correct if not please provide me some examples like sending a string and getting it in servlet?. Thanx in advance
 
     
    