Can start() method access applet parameters?  
Author Message
teresni





PostPosted: 2003-9-10 23:44:00 Top

java-programmer, Can start() method access applet parameters? I have a signed applet that needs to read in data passed from HTML
page
via PARAM elements defined in EMBED tag. Since I cannot launch a
method
directly via JavaScript (bug), I thought I'd try to see if I could get
the
code to run as needed via the start() method by reloading the page.
But my
applet is not recognizing the parameter values being passed in (when
output
for debugging, they show up as null). Can parameters be passed like
this to
the start() method??

Test HTML page:

<html>
<head><title>
Test a Signed Applet
</title></head>
<body>
<EMBED type="application/x-java-applet;jpi-version=1.4.2"
name="Launch" code="LaunchHSDXPlugIn.class"
archive="LaunchHSDXPlugIn.jar" WIDTH=120 HEIGHT=75
<PARAM NAME="ImageFile"
VALUE="\\ain-www06.devsrv\output\mapfile.jpg">
<PARAM NAME="VBCodeLocation"
VALUE="\\ain-www06.devsrv\RivCopy\CopytoClipboard.exe">
</EMBED>
<br><br>
<img name="copy" src="copy.png" onMouseDown="location.reload(true);">
</body>
</html>


Test JAVA code:

import java.applet.*;
import java.io.*;

public class LaunchHSDXPlugIn extends Applet
{
public void start()
{
System.out.println("\n** In start method.\n");

try
{
String getval = null;
getval = getParameter("ImageFile");
System.out.println("the imagefile is " + getval);

Runtime.getRuntime().exec("w:\\hyperionics\\hypersnap\\hsdx.exe -
fixed_title " + getval);

Thread.sleep(2500);
getval = getParameter("VBCodeLocation");
System.out.println("the vbcodelocation is " + getval);
Runtime.getRuntime().exec(getval);
}

catch (SecurityException e1)
{
System.out.println("\n** An access control error occurred
attempting to run LaunchHSDXPlugIn applet.\n");
e1.printStackTrace();
}

catch (IOException e2)
{
System.out.println("\n** Error attempting to execute HyperSnap or
copy to clipboard.\n");
e2.printStackTrace();
}

catch (Exception e3)
{
System.out.println("\n** An error occurred attempting to run
LaunchHSDXPlugIn applet.\n");
e3.printStackTrace();
}
}
}
 
Erwin Moller





PostPosted: 2003-9-11 18:41:00 Top

java-programmer >> Can start() method access applet parameters? Terri I. wrote:

Hi Terry

> I have a signed applet that needs to read in data passed from HTML
> page
> via PARAM elements defined in EMBED tag. Since I cannot launch a
> method
> directly via JavaScript (bug), I thought I'd try to see if I could get
> the
> code to run as needed via the start() method by reloading the page.
> But my
> applet is not recognizing the parameter values being passed in (when
> output
> for debugging, they show up as null). Can parameters be passed like
> this to
> the start() method??
>
> Test HTML page:
>
> <html>
> <head><title>
> Test a Signed Applet
> </title></head>
> <body>
> <EMBED type="application/x-java-applet;jpi-version=1.4.2"
> name="Launch" code="LaunchHSDXPlugIn.class"
> archive="LaunchHSDXPlugIn.jar" WIDTH=120 HEIGHT=75

Didn't you forget to close the embedtag here??

> <PARAM NAME="ImageFile"
> VALUE="\\ain-www06.devsrv\output\mapfile.jpg">
> <PARAM NAME="VBCodeLocation"
> VALUE="\\ain-www06.devsrv\RivCopy\CopytoClipboard.exe">
> </EMBED>
> <br><br>
> <img name="copy" src="copy.png" onMouseDown="location.reload(true);">
> </body>
> </html>
>
>
> Test JAVA code:
>
> import java.applet.*;
> import java.io.*;
>
> public class LaunchHSDXPlugIn extends Applet
> {
> public void start()
> {
> System.out.println("\n** In start method.\n");
>
> try
> {
> String getval = null;
> getval = getParameter("ImageFile");
> System.out.println("the imagefile is " + getval);

should work....

>
> Runtime.getRuntime().exec("w:\\hyperionics\\hypersnap\\hsdx.exe -
> fixed_title " + getval);
>
> Thread.sleep(2500);
> getval = getParameter("VBCodeLocation");
> System.out.println("the vbcodelocation is " + getval);
> Runtime.getRuntime().exec(getval);
> }
>
> catch (SecurityException e1)
> {
> System.out.println("\n** An access control error occurred
> attempting to run LaunchHSDXPlugIn applet.\n");
> e1.printStackTrace();
> }
>
> catch (IOException e2)
> {
> System.out.println("\n** Error attempting to execute HyperSnap or
> copy to clipboard.\n");
> e2.printStackTrace();
> }
>
> catch (Exception e3)
> {
> System.out.println("\n** An error occurred attempting to run
> LaunchHSDXPlugIn applet.\n");
> e3.printStackTrace();
> }
> }
> }

 
teresni





PostPosted: 2003-9-11 21:16:00 Top

java-programmer >> Can start() method access applet parameters? The EMBED tag was closed after the PARAM tag.
I changed my code to use the APPLET tag instead of EMBED and it is working now.

Erwin Moller <email***@***.com> wrote in message news:<3f605112$0$58705$email***@***.com>...
> Terri I. wrote:
>
> Hi Terry
>
> > I have a signed applet that needs to read in data passed from HTML
> > page
> > via PARAM elements defined in EMBED tag. Since I cannot launch a
> > method
> > directly via JavaScript (bug), I thought I'd try to see if I could get
> > the
> > code to run as needed via the start() method by reloading the page.
> > But my
> > applet is not recognizing the parameter values being passed in (when
> > output
> > for debugging, they show up as null). Can parameters be passed like
> > this to
> > the start() method??
> >
> > Test HTML page:
> >
> > <html>
> > <head><title>
> > Test a Signed Applet
> > </title></head>
> > <body>
> > <EMBED type="application/x-java-applet;jpi-version=1.4.2"
> > name="Launch" code="LaunchHSDXPlugIn.class"
> > archive="LaunchHSDXPlugIn.jar" WIDTH=120 HEIGHT=75
>
> Didn't you forget to close the embedtag here??
>
> > <PARAM NAME="ImageFile"
> > VALUE="\\ain-www06.devsrv\output\mapfile.jpg">
> > <PARAM NAME="VBCodeLocation"
> > VALUE="\\ain-www06.devsrv\RivCopy\CopytoClipboard.exe">
> > </EMBED>
> > <br><br>
> > <img name="copy" src="copy.png" onMouseDown="location.reload(true);">
> > </body>
> > </html>
> >
> >
> > Test JAVA code:
> >
> > import java.applet.*;
> > import java.io.*;
> >
> > public class LaunchHSDXPlugIn extends Applet
> > {
> > public void start()
> > {
> > System.out.println("\n** In start method.\n");
> >
> > try
> > {
> > String getval = null;
> > getval = getParameter("ImageFile");
> > System.out.println("the imagefile is " + getval);
>
> should work....
>
> >
> > Runtime.getRuntime().exec("w:\\hyperionics\\hypersnap\\hsdx.exe -
> > fixed_title " + getval);
> >
> > Thread.sleep(2500);
> > getval = getParameter("VBCodeLocation");
> > System.out.println("the vbcodelocation is " + getval);
> > Runtime.getRuntime().exec(getval);
> > }
> >
> > catch (SecurityException e1)
> > {
> > System.out.println("\n** An access control error occurred
> > attempting to run LaunchHSDXPlugIn applet.\n");
> > e1.printStackTrace();
> > }
> >
> > catch (IOException e2)
> > {
> > System.out.println("\n** Error attempting to execute HyperSnap or
> > copy to clipboard.\n");
> > e2.printStackTrace();
> > }
> >
> > catch (Exception e3)
> > {
> > System.out.println("\n** An error occurred attempting to run
> > LaunchHSDXPlugIn applet.\n");
> > e3.printStackTrace();
> > }
> > }
> > }