开发者

Can I embed a Silverlight applet in my JSP (java server page)?

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 t开发者_如何学运维his, 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.


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" />


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜