package com.radinks.tests; import java.awt.*; import java.awt.event.*; import javax.swing.JApplet; import java.net.*; import java.security.*; /** *
Title: UnsignedApplet
*Description: Demo of an Unsigned applet's unsuccessfull attempt to retrieve * an image stored on a remote server
*Copyright: Copyright (c) 2003 Raditha Dissanayake
*Company: Raditha Dissanayake
* @author Raditha Dissanayake * @version 1.0 */ public class ProxyApplet extends JApplet { Image img; public ProxyApplet() { this.setSize(200,200); } public void init() { try { /* * in a production env, this variable could be loaded from a * property file. */ String proxyScript = "http://raditha/java/sandbox/test.php"; /* * The actual URL would be what the user inputs. */ String target = URLEncoder.encode( "http://radinks.com/images/drop-logo100.jpg","UTF-8"); URL u = new URL(proxyScript + "?url=" + target); img = getToolkit().createImage(u); } catch (MalformedURLException ex) { System.err.println("err: malformed url"); } catch (java.io.UnsupportedEncodingException ex){ System.err.println("Your JVM is nuts"); } } public void paint(Graphics g) { try { g.drawImage(img,10,10,50,50,this); } catch (Exception ex) { ex.printStackTrace(); } } }