Android WebView can ' t get vertx session

Source: Internet
Author: User

Android WebView can ' t get session when using target= "_blank" with <a> link.

# # # Version 3.5.1 (maybe 3.5.0 included,not sure)


* Vert.x Core:

* Vert.x Web:


# # Context


I used Android WebView to call a vertx url,when I switched from one page to another, the VERTX server would always Generat e A new session ID, so I lost session data set by previous page.

But,when I use iphone webview or PC Chrome to call the same VERTX server, the session can be remembered correctly. So the error was only subject to Android WebView


# # # Does you have a reproducer?

We can reproducer the error following the steps below.


# # Steps to Reproduce


1. Write a smiple verticle

Public class test1verticle  extends abstractverticle { router router1  ;    @Override   public void start ()  throws exception {     router1 = router.router (VERTX);          router1.route (). Handler (Cookiehandler.create ());     router1.route (). Handler ( Sessionhandler.create (Localsessionstore.create (VERTX)))     router1.route ("/h5/*"). Handler (Statichandler.create ("Web/h5"));     router1.route ("/hit"). Handler (This::hit);     vertx.createhttpserver (). RequestHandler (Router1::accept). Listen (8080)  ;       }    private void hit (Routingcontext routingcontext)  {  session session = routingcontext.session ();       integer cnt = session.get ("Hitcount");      cnt =  (cnt == null  ?  0 : cnt)  + 1;      session.put ("Hitcount",  cnt);   routingcontext.response (). Putheader ("Content-type",  "Application/json;charset=utf-8")           .end (New jsonobject (). Put ("Data",  "cnt=" +cnt)  ) ;    }   }

2.  Place 2 HTML files in the Web/h5 file folder,named test3.html and test4.html respectively. test3.html Source C Ode:

The source code of test4.html is similar to the Above,just replace the href to test3.html

3 .....

Start the Vertx verticle, and open an Android browser,input the URL (http://192.168.0.13:8080/h5/test3.html) in the Browse R,then Submit

4. You can-find, after-jump-to-the-other html,the hits count remains to 1, and if you call the URL in the iphone or PC browser The hit count would be found to increment correctly.

5,if We remove the target= "_blank" in the HTML file, the session would work properly



Android WebView can ' t get vertx session

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.