java - Android and servlet communication and displaying -
I have the name of an Android app that model and String
which sends Java Servlet it Adds Weblet's combo box for servlets this is not happening yet, the following exception is seen in Logcat.
10-28 14: 25: 05.733: D / Exception (7518) ): java.io.FileNotFoundException: MyServletProject / Connection_Servlet
this is my app code
on public void (see V) {switch (V .getId ()) {case R.id.doubleme: new thread (New Runnable () {public void run () {try {uRL url = new URL ( "Http://l92kl68klk5:8080/MyServletProject/Connection_Servlet"); // URL Url = new URL ( "Http: // 10.0.2.2:8080/MyServletProject/DoubleMeServlet "); URLConnection connection = url.openConnection (); string inputString =" 11 ", the string model = getDeviceName (); // inputString = URLEncoder.encode (inputString," UTF-8 " ); Log D. ("InputString", InputString); Log D. ("Input String", Model); Connection.setDoOutput (true); / OutputStream Water Out = New OutputStream Water (connection.getOutputStream ()); Out.write (inputString); Out.close (); * / DataOutputStream Out1 = New DataOutputStream (connection.getOutputStream ()); Out1.writeUTF (model); Out1.writeUTF (inputString); Out1.flush (); Out1.close (); InputStream = connection.getInputStream (); DataInputStream dis = New DataInputStream (); While (dis.available () == 0); String WTF = dis.readUTF (); Dis.close (); Log.d ("Message", WTF); } Hold (exception e) {log d. ("Exception", e.ostustring ()); }}
This is my servlet code
protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setIntHeader ( "Refresh Do ", 5); Request.setAttribute ("item", list); Request.getServletContext (). GetRequestDispatcher ("/ BarcodeScannerTest.jsp") Forwarded (request, response); } Boolean daton = false; Boolean device_connected = false; Public string model; ArrayList & LT; String & gt; List = new array list & lt; String & gt; (Arrays.asList ("Buenos Aires", "Cordoba", "La Plata")); Protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stub InputStream = request.getInputStream (); DataInputStream dis = New DataInputStream (); While (dis.available () == 0); Model = disk.readUtf (); String input = dis.readUTF (); Dis.close (); Println ("model:" + model); List.add (model); OutputStreamout = response.GetOutputTream (); DataOutputStream Data = New Data Optical Stream (DUTA); Dat.writeUTF ("work"); Dat.flush (); Dat.close (); DoGet (request, feedback); }} url = new URL ("http: 8080 / MyServletProject / Connection_Servlet")
Comments
Post a Comment