JSP generating OBJECT tag for inserting Windows Media Player

Discussions

Web tier: servlets, JSP, Web frameworks: JSP generating OBJECT tag for inserting Windows Media Player

  1. Hi

    I am writing JSP which creates object tag for embedding window media player.
    this JSP page is called from html page

    Following tag in the HTML is responsible for generating object tag

    <script language="JavaScript" src="http://localhost:8080/SecondJSP/SampleJSP2"?Height=150&width=120>
    </script>


    ***My JSP is

    <%@ page language="java" errorPage="/SampleJSP/Error.jsp" %>
    <jsp:useBean id="CountBeanId" scope="session" class="SampleJSP.CountBean" />
    <jsp:setProperty name="sample" property="*" />
    <%
     String url="http://STREAM3.IIMS.INTELONLINE.COM/ViewWeb/Thundercrack/File/mobil_launch_whole_2001_56_2.asx";
     String height=request.getParameter("Height");
     String width=request.getParameter("Width");
     String showControls=request.getParameter("ShowControls");
     String animationatStart=request.getParameter("AnimationatStart");
     String transparentAtStart=request.getParameter("TransparentAtStart");
     String clipControls=request.getParameter("ClipControls");
     String showStatusBar=request.getParameter("ShowStatusBar");
     response.setContentType("text/html");
     out.print("document.write(\"<OBJECT ID='MediaPlayer1' width="+width+" height="+height+" \");" );
     out.print("document.write(\"classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' \"); ");
     out.print("document.write(\"codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' \" );");
     out.print("document.write(\"standby='Loading Microsoft® Windows® Media Player components...' \"); ");
     out.print("document.write(\"type='application/x-oleobject' > \"); ");
     out.print("document.write(\"<PARAM NAME='AutoStart' VALUE='true'>\");");
     out.print("document.write(\"<PARAM NAME='FileName' VALUE=" + url + " >\");");
     out.print("document.write(\"<PARAM NAME='ShowControls' VALUE='True'>\");");
     out.print("document.write(\"<PARAM NAME='AnimationatStart' VALUE='FALSE'>\");");
     out.print("document.write(\"<PARAM NAME='TransparentAtStart' VALUE='FALSE'>\");");
     out.print("document.write(\"<PARAM NAME='ClipControls' VALUE='TRUE'>\");");
     out.print("document.write(\"<PARAM NAME='ShowStatusBar' VALUE='TRUE'>\");");
     out.print("document.write(\"</OBJECT>\");");
      %>

    I want to change various properties of this tag(height,width,showControls...)according to what client wants.
    This script is working fine with all the parameters passed directly.
    When i am trying to use request.getParameter() it's not working.It can't fetch those values.


    I don't want to use any kind of FORM.I want that my script tag above should call the JSP page
    and pass all the parameters as well.


    Any suggestions?Please let me know.

    Thanks
    Medha
  2. Hi Medha,

    I just saw jsp name as "SampleJSP2"?Height=150&width=120>.

    I think you should put whole thing in double quote like :
    "SampleJSP2?Height=150&width=120">

    Tell me if this solves the problem !

    Sachin
  3. Hi Sachin

    Thanks for the reply.

    Well you know typing mistakes.It clicked to me yesterday only.But still it wasn't working.Then i realised that my JSP is generating all the errors because of escape sequences and quotes.
    Now it's working fine.Here is the script

    <%@ page language="java" import="javax.servlet.http.*,javax.servlet.*" errorPage="/SampleJSP/Error.jsp" %>
    <%--<jsp:useBean id="CountBeanId" scope="session" class="SampleJSP.CountBean" />
    <jsp:setProperty name="sample" property="*" />--%>
    <%
     String url="http://STREAM3.IIMS.INTELONLINE.COM/ViewWeb/Thundercrack/File/mobil_launch_whole_2001_56_2.asx";
     response.setContentType("application/x-javascript");
    String height=request.getParameter("Height");
    String width=request.getParameter("Width");
     out.println("document.write(\"<OBJECT ID=MediaPlayer1 \");");
     out.println("document.write('width=');");
     out.println("document.write('"+width+" ') ;" );
     out.println("document.write('height=');");
     out.println("document.write('"+height+" ') ;" );
     out.println("document.write('classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" '); ");
     out.println("document.write(\"codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' \" );");
     out.println("document.write(\"standby='Loading Microsoft® Windows® Media Player components...' \"); ");
     out.println("document.write(\"type='application/x-oleobject' > \"); ");
     out.println("document.write(\"<PARAM NAME='AutoStart' VALUE='true'>\");");
     out.println("document.write(\"<PARAM NAME='FileName' VALUE=" + url + " >\");");
     out.println("document.write(\"<PARAM NAME='ShowControls' VALUE='True'>\");");
     out.println("document.write(\"<PARAM NAME='AnimationatStart' VALUE='FALSE'>\");");
     out.println("document.write(\"<PARAM NAME='TransparentAtStart' VALUE='FALSE'>\");");
     out.println("document.write(\"<PARAM NAME='ClipControls' VALUE='TRUE'>\");");
     out.println("document.write(\"<PARAM NAME='ShowStatusBar' VALUE='TRUE'>\");");
     out.print("document.write(\"</OBJECT>\");");
      %>

    Thanks

    Medha
  4. Oh ! That was...

    I will suggest using something like Textpad/Vi which does syntax highlighting ! That makes spoting such mistakes very easy as u see literal strings in one colour !

    Sachin
  5. Hi medha,
    Do you have any idea if we could integrate jsp pages with activex components like ole or com.
  6. I want to add songs to windows media player kind of playlist. what is the code for that??