Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Generating HTML with JAVA script to add PARAMETER to Applet

Posted on 2001-06-25
3
Medium Priority
?
394 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:Ravindra76
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:daniel_c
ID: 6224986
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

^_^
0
 
LVL 7

Author Comment

by:Ravindra76
ID: 6225998
Still compilation errors;

Line 8: Unterminated String Constant

Line 32 : Object expected
0
 
LVL 12

Accepted Solution

by:
ahosang earned 1200 total points
ID: 6226143
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows
3.1") < 0);
is probably the unterminated String problem. Make SURE it is all on one line in the source code. If it overflows in your editor, break up the statement in a NON-STRING area, like press return where the '&&' is.

Also this is not the way to write to a document. More like:

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

<body>


<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\">");
   } 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\">");
   }
   document.writeln("<Applet width=700  height=500  id=Applet1>");
   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("</EMBED></OBJECT>");
   document.writeln("<noembed><xmp>message to browsers that can't use plugins</xmp></noembed>");
}
</Script>

</body>
</html>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question