Link to home
Start Free TrialLog in
Avatar of Ravindra76
Ravindra76

asked on

Generating HTML with JAVA script to add PARAMETER to Applet

History of problem.

Pass a Parameter to the Applet from server 1 to server 2 without any CGI PROGRAM

For example,

http://ip1/someCGI  ( SERVER 1) program will call

http://ip2/index.html ( SERVER 2) with a parameter to applet names as SESSIONID

So index.html on SERVER2 to be  modified on the fly so that
<PARAM name=SESSIONID value=?12345> if i call the URL

http://ip2/index.html?12345 from SERVER1.



Good Example:

Assume the test.html as follows.

<Script language=JavaScript>
function setParam(){    
     document.writeln("<param name=\"sessionkey\" value=\""+document.location.search+"\">");    
</Script>
<body onLoad="setParam();" >


IF You execute this code in your browser

http://yourip/test.html?12345

the output in the View Source in the IE Browser is

<param name="sessionkey" value="?12345">


CURRENT PROBBLEM:-

So to achieve my problem, Entire .html page to be written in  Java Script as mentioned in the example.
It is the following page. ( It has Swing Enabled Code ).

Name it as index.html

<Script language=JavaScript>
     function setParam(){    
          document.writeln("<HTML><HEAD>");    
          document.writeln("<SCRIPT LANGUAGE=JavaScript><!--");
              document.writeln("var _info = navigator.userAgent; var _ns = false;");
              document.writeln("var _ie = (_info.indexOf(\"MSIE\") > 0 && _info.indexOf(\"Win\") > 0 && _info.indexOf(\"Windows 3.1\") < 0);");
          document.writeln("--></SCRIPT>");

          document.writeln("<SCRIPT LANGUAGE=JavaScript><!--");
              document.writeln("if (_ie == true) document.writeln('<OBJECT classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" WIDTH = 700  HEIGHT = 500  codebase=\"http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Version=1,1,2,0\"><NOEMBED><XMP>');");
              document.writeln("else if (_ns == true) document.writeln('<EMBED type=\"application/x-java-applet;version=1.1.2\" java_CODE = \"App.class\" java_codebase = \"http://101.10.22.171/WEB-INF/classes\" WIDTH = 700  HEIGHT =500   pluginspage=\"http://java.sun.com/products/plugin/1.1.2/plugin-install.html\"><NOEMBED><XMP>');");
          document.writeln("--></SCRIPT>");
          document.writeln("<Applet width=700  height=500  id=Applet1></XMP>");
          document.writeln("<PARAM NAME = CODE VALUE = App.class>");
          document.writeln("<ParaM Name = CODEBASE VALUE = \"http://101.10.12.171/WEB-INF/classes/\">");
          document.writeln("<PARAM NAME = logPort VALUE = 8000 />");
          document.writeln("<PARAM NAME= type VALUE=application/x-java-applet;version=1.1.2>");
          document.writeln("<param name=\"sessionkey\" value=\""+document.location.search+"\">");
          document.writeln("</Applet>");
          document.writeln("</NOEMBED></EMBED></OBJECT>");
          document.writeln("</HEAD>");
     }
</Script>
<body onLoad="setParam();">


I need error free version of above html page.

The errors i am facing:

1.Unterminated String in the line
   A.  document.writeln("var _ie = (_info.indexOf(\"MSIE\") > 0 && _info.indexOf(\"Win\") > 0 && _info.indexOf(\"Windows 3.1\") < 0);");

  B.               document.writeln("else if (_ns == true) document.writeln('<EMBED type=\"application/x-java-applet;version=1.1.2\" java_CODE = \"App.class\" java_codebase = \"http://101.10.22.171/WEB-INF/classes\" WIDTH = 700  HEIGHT =500   pluginspage=\"http://java.sun.com/products/plugin/1.1.2/plugin-install.html\"><NOEMBED><XMP>');");


2. Object expected in the line
<body onLoad="setParam();">

Please fix these three bugs.

NOTE: NO LIVE CONNECT . ONLY SIMPLE  JAVA SCRIPT ...............
Advanced Thanks
Avatar of daniel_c
daniel_c

How about this?

<html>
<head>
<title>Untitled Document</title>
</head>

<Script language=JavaScript>
    function setParam(){          
         var _info = navigator.userAgent;
         var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
         var _ns = !_ie;
         if (_ie == true) {
               document.writeln("<OBJECT classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" WIDTH = 700  HEIGHT = 500  codebase=\"http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Version=1,1,2,0\"><NOEMBED><XMP>");
          }
          else if (_ns == true) {
               document.writeln("<EMBED type=\"application/x-java-applet;version=1.1.2\" java_CODE = \"App.class\" java_codebase = \"http://101.10.22.171/WEB-INF/classes\" WIDTH = 700  HEIGHT =500   pluginspage=\"http://java.sun.com/products/plugin/1.1.2/plugin-install.html\"><NOEMBED><XMP>");
          }
         document.writeln("<Applet width=700  height=500  id=Applet1></XMP>");
         document.writeln("<PARAM NAME = CODE VALUE = App.class>");
         document.writeln("<ParaM Name = CODEBASE VALUE = \"http://101.10.12.171/WEB-INF/classes/\">");
         document.writeln("<PARAM NAME = logPort VALUE = 8000 />");
         document.writeln("<PARAM NAME= type VALUE=application/x-java-applet;version=1.1.2>");
         document.writeln("<param name=\"sessionkey\" value=\"" + document.location.search + "\">");
         document.writeln("</Applet>");
         document.writeln("</NOEMBED></EMBED></OBJECT>");
         document.writeln("</HEAD>");
         return true;
    }
</Script>
<body onLoad="return setParam();">
</body>
</html>

Hope this helps

^_^
Avatar of Ravindra76

ASKER

Still compilation errors;

Line 8: Unterminated String Constant

Line 32 : Object expected
ASKER CERTIFIED SOLUTION
Avatar of ahosang
ahosang
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial