登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> 程序员学前班[不再更新,只读] >> 主题: [jsp做代理] JSP Proxy code for sourcing cross-domain Images[zt]     [回主站]     [分站链接]
标题
[jsp做代理] JSP Proxy code for sourcing cross-domain Images[zt]
clq
浏览(0) + 2009-03-18 09:00:55 发表 编辑

关键字:

[jsp 做代理] JSP Proxy code for sourcing cross-domain Images

Sudheer and some guys from IITB were building some UI in Flex. They had a case where they were getting some photos from a server in another domain and then giving it to the DisplayShelf component by Ely to display in a cool UI. But when they tried to flip through the pictures using the interface, it threw an error as below.

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: http:///.swf cannot access http://.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::BitmapData/draw()

As the above error says, the operation is trying to read the bitmap data of the image using the flash.display::BitmapData/draw() method and this is allowed only in 2 cases…

1. When you have a policy file on the cross-domain server which allows you full access
2. When the content is in the same domain

You may not be able to do (1) since the server you are getting data from may not belong to you. The other alternative is to have the image on your server (or same domain) which is where proxy-ing comes in. So you have to write a server code to proxy the data (in this case image) onto your server and then access it. Here’s the JSP script that lets you do it. If you are a PHP guy you can take this script that Abdul has written.
Download JSP Proxy Script

How to use it?

You need to pass the source of your image as below:

img.source = “testProxy1.jsp? url= http://www.theflexshow.com/blog/images/ the_flex_show.jpg &mimeType= image/jpg”;

As you see, you need to pass 2 GET variables, which are url & mimeType. Click here if you don’t know the mime type of your content. Here is an example mxml code to test the above script. I’m using Distortion Effects by Alex Uhlmann in this example. So be sure to compile the source code with the SWC (check this post if you don’t know how to compile in an external swc into your app).

Also, feel free to edit the script/code and use it at your will… Hope this helps :)

This entry was posted on Th


总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1