Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Android POST data to local server using webview error

I have a local server with a static IP 192.168.1.3:8080 hosted geoserver using appach tomcat, I want to send a gps data from my phone to Geoserver, which also has a static IP "192.168.1.233:8080", The android application side is a simple webview, I use loadURL function to load html and java script that using 'POST' to push data to server.

The webpage and Js code work perfect (no syntax error or throw..etc)

String JSCODE = "<!DOCTYPE html><html> <head> TEST <script>"+JSCODE_nonhtml+ "</script> </head> </html>";

WebView _wbv = (WebView)findViewById(R.id.mywebview);
                _wbv.getSettings().setJavaScriptEnabled(true);
                _wbv.getSettings().setAllowUniversalAccessFromFileURLs(true);
                _wbv.getSettings().setAllowFileAccessFromFileURLs(true);
                _wbv.getSettings().setGeolocationEnabled(true);

 _wbv.loadDataWithBaseURL("", JSCODE, "text/html", "utf-8", null);

When i launch the application I get this error:

I/chromium: [INFO:CONSOLE(0)] "Access to XMLHttpRequest at 'http://192.168.1.3:8080/geoserver/wfs' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.", source: about:blank (0)

I know there is CORS problem, so how i can fix this both on android and PC server. thanks in advance.

EDIT I Added the following command to

C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\web.xml

of the tomcat server configuration

  <filter>
        <filter-name>httpHeaderSecurity</filter-name>
        <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
        <async-supported>true</async-supported>
        <filter-name>CorsFilter</filter-name>
        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
        <url-pattern>/*</url-pattern>
        <init-param>
            <param-name>cors.allowed.origins</param-name>
            <param-value>*</param-value>
        </init-param>
    </filter>
 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!