Hello,
I am trying to simple data from an Android service to a GlassFish
webserver on netbeans. But when I run the Android program, it sends
data but the servlet doesnt pick it up. I have given the correct
ip(10.0.2.2), added the path of the servlet in the web.xml file. I am
not sure what is going wrong. Could somebody please help me.
Servlet
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, JSONException {
response.setContentType("text/html;charset=UTF-8");
System.out.println("Server Started Successfully");
PrintWriter out = response.getWriter();
try{
System.out.println(request.getParameterNames());
String param = request.getParameter("Hello");
System.out.println(param+"is the stuff recieved");
System.out.println("Recieved stuff:"+aList.toString());
RequestDispatcher rd = request.getRequestDispatcher("/
MapMatchingServlet");
rd.forward(request, response);
} finally {
out.close();
}
}
Android Service
Log.i(tag, "Started Get Coordinates");
URL url = new
URL("http://10.0.2.2:28503/PNSServer/MainServlet");//
this is the localhost address
conn = url.openConnection();
conn.setDoOutput(true);
writer = new
OutputStreamWriter(conn.getOutputStream());
scanner = new Scanner(new FileReader(new File("/sdcard/
inputdata.txt")));
Log.i(tag, "Read input data");
writer.write("Hello=yes");
Thanks,
raqz
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en