We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

OBJECT TAG

fpoyavo
fpoyavo asked
on
Medium Priority
278 Views
Last Modified: 2010-04-01
Hi Experts,

Can I and How to replace code within JSP to run applet using <OBJECT> tag with the applet using <APPLET> or anything else
to be able to access class from this applet ?

Thank you.
Comment
Watch Question

Author

Commented:
The reason is that with this tag I was not able to access anything and was given message that applet object does not exist but
in the IE status bar I see it is initiated, started, loaded.

Thank you.
rrzstudent
CERTIFIED EXPERT

Commented:
What did the Java Console report ?  
Please show us your code ?
Can't figure out what you are trying to do here... can you post your code and point us what its not doing??

Author

Commented:
I am trying to access class defined within applet via Javascript. It is a simple Applet.

Author

Commented:
I mean simple simple just for learning but it uses <OBJECT> tag . How to replace this <OBJECT> tag with <APPLET> but to
keep same functionality ?

Thank you.
<APPLET NAME='screenCapture' Code='ScreenCaptureApplet'  CODEBASE='../classes' width=100 height=100></APPLET>

and in the java script

document.screenCapture.captureImage(00,100,100,100,imgdescription);
                        

here captureImage is a method written inside the Applet..

I know it works

Author

Commented:
I will try it today and get back. Thank you.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
does your applet require the java plugin?  If it does then the <applet> tag will not work unless the user has the plugin setup as their default vm.

> and was given message that applet object does not exist

where are you getting this message.

Author

Commented:
So... here is the code :

<%
String someID = request.getParameter( "id" );
if ( someID == null ) someID = "-1";
%>
<html>
<head>
<title>MyApplet</title>
 

<script language="javascript">

function getmyid()
{

alert("started");

// I was trying too
//var appObj = document.getElementById('myapplet');
//var myid = appObj.getId();


// message that does not exist


var myid = document.myapplet.getID();


alert("here it is : " + myid);

}

</script>

</head>
<body bgcolor="#002341">
<img src="Submit.gif" onClick="getmyid()"></img>

<center>
 
<OBJECT classid = "clsid:CAFEEFAC-0014-0001-0000-ABCDEFFEDCBA" codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_1-windows-i586.cab#Version=1,4,1,0" WIDTH="100%" HEIGHT="100%">
      <param name="NAME" value="myapplet" MAYSCRIPT>
      <param name="CODE" value="com.sample.mybrowser.samplemybrowserApplet.class" width="50" height="50" MAYSCRIPT>
      <param name="ARCHIVE" value="sample.jar, nanoxml-2.1.1.jar, Browserutil.jar, Myutility.jar, dom.jar" MAYSCRIPT>
      <param name="type" value="application/x-java-applet;jpi-version=1.4.1">
      <param name="scriptable" value="true">
      <param name="browser" value="false">
      <param name="focusID" value="<%=someID%>">
      <param name="bgImage" value="background.gif">
      <param name="apachePort" value="8081">
      <param name="tomcatPort" value="8080">
     

    <COMMENT>
      <EMBED type = "application/x-java-applet;jpi-version=1.4.1" CODE="com.sample.mybrowser.samplemybrowserApplet.class" WIDTH="50%" HEIGHT="50%" scriptable="true" pluginspage="http://java.sun.com/products/plugin/index.html#download" MAYSCRIPT>
          <NOEMBED>
            alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
                    Your browser is completely ignoring the &lt;APPLET&gt; tag!
            </NOEMBED>
      </EMBED>
    </COMMENT>
</OBJECT>
</body>
</html>


It returns onclick that : "document.myapplet   is null or not an object"

How to make it work ?.

Please help.
Are you sure that your applet is getting loaded???
with the code given here, it looks like you are trying to load a applet from Sun site and not your own applet...

If your applet is getting loaded then you shd see a little coffee cup in your taskbar area ....

Author

Commented:
i DO see that cup and message in status bar "myapplet is loaded" and it is working fine.

The problem is that I need to access class from this applet. I was thing that the problem was due to <OBJECT> tag use.

When use <APPLET> tag instead it does not load and I see "red cross" image in the left upper conner.


Please help.

Author

Commented:
correction: I was thinking that the problem was due to <OBJECT> tag use.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Is there any way to get it WORKING in <APPLET> ?
Not if the class is not an APPLET

Author

Commented:
Kuldeep,

Would you please look at another question I have :

https://www.experts-exchange.com/Web/Web_Languages/JSP/Q_20947874.html

Author

Commented:
Do you think its possibly to download this class and make it APPLET ?
you can defenitly try that...
I am willing to help you with that once you get the code of that class....
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Let me try. I will get back.
Since you're using JSP, why don't you use the <jsp:plugin > action tag?.  In using it, you have to define the classname, among other things.  The beauty of this action tag is that the HTML code for the applet will be created to fit the browser you're working with, i.e., it will use the OBJECT tag or APPLET tag depending on the browser you're using.

You can also define parameters within the tag using the <jsp:params> tag.

Hope this helps.
Anthony
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
>  i.e., it will use the OBJECT tag or APPLET tag depending on the browser you're using.

Its more what vm's are being used that dictates which tag to use.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.