You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tomcat <to...@unixplanet.biz> on 2007/03/25 09:57:59 UTC

Applet not initiated

Hello

When I am trying to open a very simple applet on my browser
it returns "applet not initiated" or "failed to load applet".

class file is located in tomcat WEB_INF/classes and I am calling it from
ROOT directory and through index.html file.

thanks for help

Adam


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


jsp-applet

Posted by Abdelmonaam Kallali <ak...@dragonwaveinc.com>.
Hi everyone
I have an applet called by a jsp file but the applet is not initiated the
jsp file contains
rs1=stmt.executeQuery("select status, sum(counter) as counterSum, allDates
from(select * from(select distinct status, count(status) as counter
,dateOpened as allDates from ncrreport where unitSerNum!='no unit' and
dateOpened between curdate()-5 and curdate() group by allDates, status)as
opened union select * from	(select distinct status,
count(status),dateClosed as allDates from ncrreport where unitSerNum!='no
unit' and  dateClosed between curdate()-5 and curdate() group by allDates,
status)as closed )as allNcrs group by allDates, status");
while(rs1.next())
{
status = rs1.getString("status");
if((status.equals("closed")&& i%2==0)||(status.equals("open")&& i%2==1))
{
	counter[i] = rs1.getString("counterSum");
	dateOpened[i] = rs1.getString("allDates");
}
else if(i%2==0)
{
 	counter[i] = "0";
	dateOpened[i] = rs1.getString("allDates");
	counter[i+1] = rs1.getString("counterSum");
	dateOpened[i+1] = dateOpened[i];
	i++;
}
else 
{
 	counter[i] = "0";
	dateOpened[i] = dateOpened[i-1];
	counter[i+1] = rs1.getString("counterSum");
	dateOpened[i+1] = rs1.getString("allDates");
	i++;
	}
i++;
}
	for (j=0; j<i; j++)
	{
		allDates+=","+dateOpened[j];
		allCounters+=","+counter[j];
	}

	con.close();
                   
%>
This is an applet template:<br>
<P><%=i%></P>
<P><%=allDates%></P>
<P><%=allCounters%></P>
<!--<applet code="Fluctuations3.class"  height="750" width="1000">
you need a java-enabled browser to see this</applet>-->
<jsp:plugin type="applet" code="Fluctuations6.class" height="750"
width="1000">	
   <jsp:params>	
   
      <jsp:param name="increment" value="<%=i%>" ></jsp:param>
      <jsp:param name="counter" value="<%=allDates%>" />	
      <jsp:param name="dateOpened" value="<%=allCounters%>" />
   </jsp:params>	
   <jsp:fallback>	
      <p>Unable to load applet</p>	
   </jsp:fallback>	
</jsp:plugin>

</body>
</html>

and a java file

import java.awt.*;
import java.applet.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.*;
import java.applet.Applet;
 class Fluctuations6 extends javax.swing.JApplet {
	int i;
	String[] dateOpened ;
	String[] counterString;
	String allDates;
	String allCounters;
	int[] counter;
	
	public void init() 
	{
		i=Integer.parseInt(getParameter("increment"));
		dateOpened=new String[100000];
		counterString=new String[100000];
		counter=new int[100000];
			for(int j=0;j<i/2; j++)
			{
				dateOpened[j]="";
				counterString[j]="";
				counter[j]=0;
			}
		
			
	}

	public void paint(Graphics g) {
			allCounters=getParameter("counter");
			counterString=allCounters.split(",");
			allDates=getParameter("dateOpened");
			dateOpened=allDates.split(",");
			for(int j=0;j<i/2; j++)
	
counter[j]=Integer.parseInt(counterString[j]);
		Graphics2D g2D =(Graphics2D)g ;
		g2D.drawLine( 10, getSize().height - 10, getSize().width -
10, getSize().height - 10);
		g2D.drawLine( 10, getSize().height - 10, 10, 10);
		g2D.drawString(allDates, 10+5*i, getSize().height - 5 );
		for(int j=0; j<i/2; j+=2)
		{
		g2D.drawString(dateOpened[j], 10+10*j, getSize().height - 5
);
			g2D.drawLine( 10+10*j, getSize().height-counter[j],
10+10*(j+2), getSize().height-counter[j+2]);
			g2D.drawLine( 10+10*(j+1),
getSize().height-counter[j+1], 10+10*(j+3), getSize().height-counter[j+3]);


		}
	}
	
}

can anybody tell me why it is not initiated (note that these two files are
in ROOT)

Abdelmonaam KALLALI
Test Specialist
DragonWave Inc
411 Legget Dr
Phone :613-599 9991 ext 275

-----Original Message-----
From: Rashmi Rubdi [mailto:rashmi.sub@gmail.com] 
Sent: Monday, March 26, 2007 2:41 PM
To: Tomcat Users List
Subject: Re: Applet not initiated

Also I don't know if you're using strict XHTML.

The applet tag is not supported in XHTML as mentioned here :
http://www.w3schools.com/tags/tag_applet.asp

they recommend using the HTML object tag
http://www.w3schools.com/tags/tag_object.asp instead of applet tag.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Applet not initiated

Posted by Rashmi Rubdi <ra...@gmail.com>.
Also I don't know if you're using strict XHTML.

The applet tag is not supported in XHTML as mentioned here :
http://www.w3schools.com/tags/tag_applet.asp

they recommend using the HTML object tag
http://www.w3schools.com/tags/tag_object.asp instead of applet tag.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Applet not initiated

Posted by Rashmi Rubdi <ra...@gmail.com>.
You're welcome.

> is it possible classpath should include that class location so
> computer's jvm
> recognize the place that class is exist ?

I recommend not setting the CLASSPATH at all.

I tested one Applet example with JSPs, and the applet loads fine on
Tomcat 6 / Windows XP without any explicit classpath settings.

Here's the code that works with JSP 2.0 if it helps you, the HTML
APPLET tag's syntax may be similar to the jsp:plugin tag's syntax as
shown below:

-----------------------------------------------------------------------------------------
C:\dev\projects\MyProject\appletTest.jsp
-----------------------------------------------------------------------------------------
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Applet Test</title></head>

<body>
<%--
http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158
--%>

<jsp:plugin type="applet" code="HelloWorld" codebase=".">
    <jsp:params>
        <jsp:param name="commaSeparatedValues" value="abc,xyz,123,888"/>
    </jsp:params>
</jsp:plugin>
<br/><br/><br/>

<%-- The following will not work, because HelloWorld2 is under WEB-INF --%>
<%--
<jsp:plugin type="applet" code="HelloWorld2" codebase="/WEB-INF/classes/test51">
</jsp:plugin>
--%>

</body>
</html>

--------------------------------------------------------------------------------------------------
I've placed the applet class in the same folder as the JSP file, but it could
be placed anywhere else under the project (except under WEB-INF)

C:\dev\projects\MyProject\HelloWorld.java
--------------------------------------------------------------------------------------------------

import javax.swing.JApplet;
import java.awt.Graphics;

public class HelloWorld extends JApplet {

    public void paint(Graphics g) {

	g.drawRect(0, 0,
		   getSize().width - 1,
		   getSize().height - 1);

        g.drawString("Hello world!", 5, 15);

    }
}

Cheers
-Rashmi

On 3/26/07, Tomcat <to...@unixplanet.biz> wrote:
> Hello Rashmi,
>
> Thanks for response,
>
> I put the class file in ROOT directory, the same place that my html file
> exist , but still the same problem.
>

> and also I found some document that it says
> codebase tag should cotnain the directory that class are located and
> code tag should contain
> the class name but without class.
>
> your help will be highly appreciated.
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Applet not initiated

Posted by Tomcat <to...@unixplanet.biz>.
Hello Rashmi,

Thanks for response,

I put the class file in ROOT directory, the same place that my html file
exist , but still the same problem.

is it possible classpath should include that class location so 
computer's jvm
recognize the place that class is exist ?
and also I found some document that it says
codebase tag should cotnain the directory that class are located and 
code tag should contain
the class name but without class.

your help will be highly appreciated.


Rashmi Rubdi wrote:
> Place your Applet's class file anywhere but the WEB-INF folder,
> because WEB-INF folder is protected from client/browser's access,
> applet classes can't be accessed if they are under WEB-INF.
>
> Also use jsp:plugin tag , if you are accessing the Applet from a JSP 
> file.
>
> -Rashmi
>
> On 3/25/07, Tomcat <to...@unixplanet.biz> wrote:
>> class file is located in tomcat WEB_INF/classes and I am calling it from
>> ROOT directory and through index.html file.
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Applet not initiated

Posted by Rashmi Rubdi <ra...@gmail.com>.
Place your Applet's class file anywhere but the WEB-INF folder,
because WEB-INF folder is protected from client/browser's access,
applet classes can't be accessed if they are under WEB-INF.

Also use jsp:plugin tag , if you are accessing the Applet from a JSP file.

-Rashmi

On 3/25/07, Tomcat <to...@unixplanet.biz> wrote:
> class file is located in tomcat WEB_INF/classes and I am calling it from
> ROOT directory and through index.html file.
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org