Good to hear.  One of the more common/recommended things to do in
webapps is to generate server relative paths to resources so context and
server names can change dynamically.  One way to do this with EL
expressions in jsps is:

<script type="text/javascript"
src="${pageContext.request.contextPath}/webapp/relpath_to/resources.js">
</script>

or in your case:

<script type="text/javascript">
  var so = new
SWFObject('${pageContext.request.contextPath}/swf_resource_path/mediaplayer.swf','jstest','400','220','8');
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addVariable('width','400');
  so.addVariable('height','220');
 
so.addVariable('file','http://content.longtailvideo.com/videos/flvplayer.flv');
  so.addVariable('javascriptid','jstest');
  so.addVariable('enablejs','true');
  so.write('container');
</script>

It's rock solid stable even through forwarding.

--David

Adrian Matei wrote:
> Hi David,
>
> Thank you very much for your useful advice. Indeed with Firebug I've realized 
> that the files .swf and .js were were being searched in the root of the 
> application and not where I hold my jsp. Now they are loaded.
>
> Thanks again,
> Adrian
>
>
>
>
> ________________________________
> From: David Smith <d...@cornell.edu>
> To: Tomcat Users List <users@tomcat.apache.org>
> Sent: Tuesday, September 8, 2009 9:06:06 PM
> Subject: Re: problem displaying .swf file in generated html from jsp file
>
> Have you used a plugin like Firebug for Firefox to verify the url of the
> .swf file as requested by the browser?  What url does the browser try to
> use to get the .swf file and what is the status code on the response
> (200, 404, 500, etc., ....)?
>
> --David
>
> Adrian Matei wrote:
>   
>> Hi everyone,
>>
>> I've been having a frustrating problem for almost a week now and I couldn't 
>> find an answer so far, just open questions on most of the forums - and i've 
>> searched a lot. 
>>
>> I am trying to embed a simple flash file .swf within a .jsp but when running 
>> it on the server (tomcat 6.0.20 tried also 5.0.22 and 6.0.16) it won't 
>> display the .swf. But if I take the html source and put it another file and 
>> run it directly in the browser it will run. Do you have any ideea what the 
>> proble might be? Should I place something in the configuration files? (the 
>> .swf and the .jsp are in the same directory)
>>
>> Here is the code for my page:
>>
>> <div id="container">This text will be replaced</div>
>> <script type="text/javascript">
>>   var so = new SWFObject('mediaplayer.swf','jstest','400','220','8');
>>   so.addParam('allowscriptaccess','always');
>>   so.addParam('allowfullscreen','true');
>>   so.addVariable('width','400');
>>   so.addVariable('height','220');
>>   
>> so.addVariable('file','http://content.longtailvideo.com/videos/flvplayer.flv');
>>   so.addVariable('javascriptid','jstest');
>>   so.addVariable('enablejs','true');
>>   so.write('container');
>> </script>
>>
>> I tried without the SWFObject the same result. 
>>
>> Thank you for your consideration.
>>
>> Best regards,
>> Adrian 
>>
>>     


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to