Solution to Security Sandbox conflicts during screenshot Printing

Source: Internet
Author: User

After the application that uses the flex API to call the National Map of heaven and earth is published to the server, it is found that the "Security Sandbox conflict" error message appears during printing and screenshots.

In fact, this is a flex security policy.

I am familiar with the following two methods to solve such conflicts:

1) Place the crossdomain. xml cross-domain file under the root directory of the Map Server

2) Write proxy

Because the national map server is far away from the capital, basically method 1 is not implemented at present, so it can only be implemented through method 2) Write proxy

I wrote a servlet to implement the proxy map tile service function.

String type = request. getparameter ("T ");
String x = request. getparameter ("X ");
String y = request. getparameter ("Y ");
String L = request. getparameter ("L ");

Long Index = math. Round (math. Random () * 7 );
/*
* A complete image URL has the following format: http://tile0.tianditu.com/DataServer? T = siwei0608 & X = 6666 & Y = 1406 & l = 13
*/
String spec = "http: // tile" + index + ".tianditu.com/dataserver? T = "+ Type +" & X = "+ x +" & Y = "+ Y +" & l = "+ L;
URL url = new URL (SPEC );
Urlconnection = URL. openconnection ();
Urlconnection. Connect ();
Inputstream = urlconnection. getinputstream ();

Response. setcontenttype ("image/PNG ");
Outputstream = response. getoutputstream ();
Byte B [] = new byte [1];
While (-1! = Inputstream. Read (B, 0, 1 ))
Outputstream. Write (B, 0, 1 );
Inputstream. Close ();
Outputstream. Close ();

After the servlet is published, browse the map in the flex API and use the fire bug tracking to find that the tile address obtained by the client is the proxy address released by the local machine.

For example

Http: // localhost: 8080/xtgeomaps_app/gjtianditu? T = siwei0608 & X = 6666 & Y = 1406 & l = 13

Instead

Http://tile0.tianditu.com/DataServer? T = siwei0608 & X = 6666 & Y = 1406 & l = 13

With this proxy method, you can print and print as you like.

It must be noted that, in this proxy method, the client needs to obtain the tiles and pass through two servers, one is the map server of the national World, and the other is the local server, the response speed will certainly be affected.

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.