This example shows how to create a JSP proxy for XML request Server-Side Scripting. When you write a Flex application, and when you are accessing remote hosts for services you have no control of (ex: RSS Feed), then you find out there is no cross domain file ( crossdomain.xml) and Flex app will complain. Using a proxy (JSP or PHP page for example ) can help you by pass this problem.

The JSP code using Tomcat 6.0 and JDK 1.6


<%@ page language = "java" import = "java.net.*" import = "java.io.*" %>
<%
String search,mime;
HttpSession ses = request.getSession(true);
if(request.getParameter("url") == null)
search = "http://www.theflexshow.com/blog/images/the_flex_show.jpg";
else
search =request.getParameter("url");

if(request.getParameter("mimeType") == null)
mime = "application/xml";
else
mime =request.getParameter("url");
mime = mime.trim();
InputStream resultInStream = null;
OutputStream resultOutStream = response.getOutputStream();
%>
<% response.setContentType(mime); %>
<%
try
{
URL url = new URL(search);
resultInStream = url.openStream();
byte[] buffer = new byte[4096];
int bytes_read;
while((bytes_read=resultInStream.read(buffer)) != -1)
{
resultOutStream.write(buffer, 0, bytes_read);
}
resultOutStream.flush();
resultOutStream.close();
resultInStream.close();
} catch (Exception e) {%><%= e%><%}
finally{ try { resultOutStream.flush(); resultOutStream.close(); resultInStream.close(); } catch (Exception e) {%><%= e%><%}
}%>

This is the Flex code using Flex Builder 3



        
        DataGrid {
           alternatingItemColors: #cccccc, #eff1f2;
           rollOverColor: #999999;
           textRollOverColor: #ffffff;
           selectionColor: #666666;
           color: #000000;
           textSelectedColor: #ffffff;
        }

        Button {
           color: #ffffff;
           themeColor: #333333;
        }