如何通過 HttpRequest 從連接的 Android 設備訪問本地 tomcat (How to access local tomcat via HttpRequest from connected Android device)


問題描述

如何通過 HttpRequest 從連接的 Android 設備訪問本地 tomcat (How to access local tomcat via HttpRequest from connected Android device)

While accessing from emulator works fine with:

  response = CustomHttpClient.executeHttpPost(
                "http://10.0.2.2:8080/DWAP/SERVLET", postParameters);

when I write from my Android device

 response = CustomHttpClient.executeHttpPost(
                "http://XX.XX.XX.XX:8080/DWAP/SERVLET", postParameters);

Where xx.xx.xx.xx is my public IP I do not get access to the local server.

Is there an easy way to test the app from an Android device to access the local Tomcat or do I need to test with emulator only?

Do need to go through port-fprwarding on my router or is there another way to connect "internally" on my WLAN. (Android mobile phone <-> MAC with local Tomcat)?


參考解法

方法 1:

Try setting your computer as the DMZ of the router. This way, communication with your router (public ip) leads directly to your computer (local ip).

(by user387184Moshe Bixenshpaner)

參考文件

  1. How to access local tomcat via HttpRequest from connected Android device (CC BY-SA 3.0/4.0)

#HTTP #tomcat #Android






相關問題

POST 和 PUT HTTP 請求有什麼區別? (What's the difference between a POST and a PUT HTTP REQUEST?)

發出原始 HTTP 請求時如何輕鬆解碼 HTTP 分塊編碼字符串? (How to easily decode HTTP-chunked encoded string when making raw HTTP request?)

如何通過 HttpRequest 從連接的 Android 設備訪問本地 tomcat (How to access local tomcat via HttpRequest from connected Android device)

Python 3, http.client HTTP памылка 400 (Python 3, http.client HTTP error 400)

Tập lệnh PHP có thể tiếp tục sau khi chuyển hướng không? (Is it possible for PHP script to continue after redirect?)

兩個進程使用同一個端口? (Two processes using the same port?)

Javascript HTTP 函數 (Javascript HTTP Function)

如何通過powershell獲取請求的authtoken (How to obtain authtoken for request via powershell)

我在哪裡將 REST 客戶端身份驗證數據放在查詢中? (Where do I put the REST Client Authentication Data in the Query?)

jquery get / post請求的Apache url替換 (Apache url replacement for jquery get / post request)

在 MATLAB 中通過 HTTP 接收數據 (Receive data via HTTP in MATLAB)

在 python 中開發時,如何在 post 請求中使用“format=json&data=”? (How do I use "format=json&data=" in post requests when developing in python?)







留言討論