views:

149

answers:

3

I suspect the answer is yes, you can embed a Silverlight applet in a JSP, but I'm having a very difficult time finding any examples of this. Seems to me that I can just use the HTML that would go in a strict HTML file...

<object width="300" height="300"
    data="data:application/x-silverlight-2," 
    type="application/x-silverlight-2" >
    <param name="source" value="SomeSilverlightApplet.xap"/>
</object>

... and it would just work.

I would test this, but finding a .xap file that I can download and test with is more difficult than I would like. Perhaps it is just because a Java programmer like myself doesn't know where to look.

A: 

You won't find a XAP, you'll have to create one or find someone with at least Visual Studio 2008 Standard to create you a test XAP.

Dave Swersky
+2  A: 

Yes, you can just stick that HTML in jsp or php and it should work.

For getting it to work you will need to make sure the .xap file extension can be served up by your server. Setting that up will depend on the server platform you're running on.

BTW - here is a xap file you can test it with. Just add a twitter username in the initParams and it should run.

<param name="initParams" value="username=[YourTwitterUsername],count=10" />
Bryant
A: 

That should work, or if you'd rather

<script type="text/javascript" src="Silverlight.js"></script>

(Silverlight.js outputed by a silverlight project)

and

function createSilverlight(source, parent, id)
{
   Silverlight.createObjectEx({
      source: source,
      parentElement: document.getElementById(parent),
      id: id,
      properties: {
         width: "100%",
         height: "100%",
         version: "1.1",
         enableHtmlAccess: "true" },
      events: {} });
}

where "source" is the name of a XAML file, not XAP file.

divitiae