Mozilla 1.7.x  hangs in applet code on RH Linux with JRE 1.5.0

Hi all,
From my applet code when an URLConnection.getInputStream() method is called the browser hangs, if authentication is turned on the webserver.
This works with jre 1.4.2 on linux, for the matter on windows with Jre1.5 also.
Also it works on 1.5 if suthentication is not set.
So it is this particular combination of (jre1.5/mozilla on linux/authentication) that doesnot work :):).
I tried to set the auth header, but nothing seem to help.
String login = "userid"+":"+"password";
String encodedLogin = new sun.misc.BASE64Encoder().encode(login.getBytes());
httpsCon.setRequestProperty("Authorization", "Basic " + encodedLogin);
Searched on the sun/mozilla sites to see if any known issues, couldn't find any.
Thanks
RT

Just to add upon that a simple code like this will hang
String str = "https://ppp.qqq.com/admin/50_splash.gif";
try {
URL url = new URL(str);
URLConnection con = url.openConnection();
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
con.setDoInput(true);
try {
con.connect(); //-->hangs here
It looks to me like at this point plugin tries to popup the authentication dialog box but it cannot.
Thanks
RT

Similar Messages

  • How do I update a file in an Applet's JAR file from the Applet code

    Here's my problem.
    My applet is using a serializable history data in which I am storing in the applet's JAR file. When I run the applet, I read the file with "getResourceAsStream()" and run my program with that hist data. When my applet is closed, I need to update this file from my Applet's code and I dumfounded about how to do that.
    Is there any way to update a file in the Applet's JAR file through the Java Applet code? (i.e. OutputStream?).
    Would appreciate any advice people have.

    Just place a copy of the file on the local hard disk and update that. When you start the Applet you try to read from the hard disk. If the file exists then no problem otherwise copy it from the jar to the hard disk.

  • Urgent help needed in two clarifictions of applet code

    Hi,
    I have an applet code where I have two buttons. Now, if button A is clicked it should pass a particular query string while if button B is clicked it should pass another particular query string.
    I would like to confirm
    1) Whether the query string passed is a valid statement(/approach) and
    2) Why there is an error in assigning qryString to qryString1.
    Thanks for any help/advise in advance.
    THE CODE:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    public class ReinApplet1 extends Applet implements ActionListener
    TextField text;
    Button button1;
    Button button2;
    TextArea taResults;
    public void init()
         button1 = new Button("A");
    button1.addActionListener(this);
    add(button1);
    button2 = new Button("B");
    button2.addActionListener(this);
    add(button2);
    taResults = new TextArea(2,30);
    add(taResults);
    // text = new TextField(20);
    // add(text);
    public void actionPerformed(ActionEvent e)
    Object obj = e.getSource();
    if(obj == button1)
    String qryString = "select name from test where letter = A";
    executeQuery();
    if(obj == button2)
    String qryString = "select name from test where letter = B";
    executeQuery();
    public void executeQuery()
    String qryString1 =qryString;
    try
    URL url=new URL("http://localhost:8080/examples/servlet/ReinServlet1");
    String qry=URLEncoder.encode("qry") + "=" +
    URLEncoder.encode(qryString1);
    URLConnection uc=url.openConnection();
    uc.setDoOutput(true);
    uc.setDoInput(true);
    uc.setUseCaches(false);
    uc.setRequestProperty("Content-type",
    "application/x-www-form-urlencoded");
    DataOutputStream dos=new DataOutputStream(uc.getOutputStream());
    dos.writeBytes(qry);
    dos.flush();
    dos.close();
    InputStreamReader in=new InputStreamReader(uc.getInputStream());
    int chr=in.read();
    while(chr != -1)
    taResults.append(String.valueOf((char) chr));
    chr = in.read();
    in.close();
    // br.close();
    catch(MalformedURLException e)
    taResults.setText(e.toString());
    catch(IOException e)
    taResults.setText(e.toString());

    String qryString = "select name from test where letter = A";
    ...this is a local variable ...local to your actionperformed method. The reason the assignment String qryString1 =qryString; doesn't work is because you have no scope to your actionperformed local variables from your executeQuery method. Either make qryString a class variable bty defining it outside any method ...ot, alternatively, pass the string into the executeQuery method.
    if(obj == button1)
      String qryString = "select name from test where letter = A";
      executeQuery(qryString);
    public void executeQuery(String query)
      String qryString1 = query;
    ...As for the sql statement, if you are going to refine the query through the letter column, you will need to pull it into the query when you select...
    ...such as: select name,letter from test where letter = B

  • IE hang (Freeze) if use applet/javascript with JRE 1.4.2_06

    When i run my applet on IE 6 with JRE 1.4.2_06 and try to close IE window it freezes the IE window, while if i run the same code in 1.4.1_05 it works fine.
    The OS is windows 2000 Professional and IE is 6.0.2800.1106.
    Also the same applet works fine on Windows XP with IE 6.0.2900.2180 SP2 with JRE 1.4.2_06
    Please help....

    I was having similar problem earlier. Check if you are closing all the open resources (threads etc etc)

  • I used to use SpeedBit Video Downloader with Mozilla Firefox, but suddenly a problem happened, I can not download with it now at all as there is an code error appears in the bar of SpeedBit like "XML Parsing Error: unclosed token Location: chrome://browse

    I used to use SpeedBit Video Downloader with Mozilla Firefox, but suddenly a problem happened, I can not download with it now at all as there is an code error appears in the bar of SpeedBit like "XML Parsing Error: unclosed token Location: chrome://browser/content/browser.xul Line Number 1, column 8702:....................."
    I did evrey thing, but the same problem
    reinstall SpeedBit, reinstall Mozilla Firefox.
    So what can I do!
    == This happened ==
    Every time Firefox opened
    == 4 days ago

    look people, i may have a solution for this. This happened to me a few times before and resolved alone, but last time it happened was when i turned off my router and back on while my comp was running and appeared when i tried opening firefox after that. so wat i did was i shutdown the computer and the router and tried turning both on again, and it resolved.
    Therefore, Summary: Shutdown computer then turnoff router then turn both back on
    Hope this helps anyone.

  • Need Applet code - pleae help

    Hi all, I'm relatively new to the Java applets technology and i apologise in advance if I am posting this in the wrong forum.
    I am trying to develop a applet base utility to perform database backups etc , to run within our network.
    I am looking for a applet code with following functionalities.
    1 - show unix directory to choose for backup
    2 - create script and run database commands.
    Please send this code to me, or point me to the url from where I can download, I have tried everywhere I could not find.
    Thanks in advance.
    my email [email protected]

    I would recomend that you first look into Servlets, I think this would a better solution.
    Check this link:
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/Servlets.html

  • Sign the Applet code using pfx certificate got Error?

    I use my existing certificate (.pfx) to sign my applet code as follows (without any key gen. before, directly sign by this certificate)
    jarsigner -storetype pkcs12 -keystore C:\mycert.pfx AppletCode.jar keyEntries
    Although the code can be signed, when i view this page, it prompts me "Certificate not verified" and with error:
    java.security.cert.CertificateException: Check leaf key usage failed in certificate.
    What is wrong? Any body can help me?
    * I try to geneate the self-certificate by keytool to sign my code, it can be viewed properly.

    1) Check if your .pfx certificate has the following purposes (read it using the venerable Internet Explorer):
    Ensures software came from software publisher
    Protects software from alteration after publication
    2) Put your certificate in the cacerts file

  • Jsp:plugin applet code

    Hi all, I've been wondering if applets can be dynamically called from a jsp or servlet using strings in the applet code section. would this be good if a database was used to store the paths of the applets?
    i've tried this with a small applet in different ways, just to see the effect in Apache Tomcat 4.1.24, but it didn't really work. could anyone help me out here?
    the coding i've been using is below :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    Here is the applet!
    <br>
    <jsp:plugin type="applet" code="ElecBill_a" codebase="." height="200" width="200" >
         <jsp:fallback>
              <p> Unable to use Java Plugin</p>
         </jsp:fallback>     
         </jsp:plugin>
    <br>
    <applet code = "ElecBill_a.class" height="200" width="200"></applet>
    //up to here it works fine, both applets appear. but below, the string is read directly and causes an error
    <%! String myapplet = new String("ElecBill_a"); %>
    <%! public String getName() {return myapplet; } %>
    <br> The name of the class file is <%= getName() %>
    <br>
    <jsp:plugin type="applet" code="<%= "myapplet" %>" codebase="." height="200" width="200" >
         <jsp:fallback>
              <p> Unable to use Java Plugin</p>
         </jsp:fallback>     
         </jsp:plugin>
    </body>
    </html>

    yes, i suppose it doesn't. i've tried to insert it using the original way with the applet tag like this
    <APPLET code = <%= getName() %> width=300 height=300>
    </APPLET>
    and this works...so i might go with this for a short term solution until i can figure out a better way...thanks!

  • What's wrong in my applet code?

    Hi!
    I' ve a big problem with my applet. It doesn't works with some pc. For example: two same operative systems, same browsers and versions; one of that display applet without problems. The other pc (even if a jre is manually installed) doesn't show the applet, and it doesn't show me any errors.
    The page who not show my applet, has this code (the applet code is commented!! Why???):
    <!-- ct classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width=770 height=313 codebase="/ols/html/plugin/jinstall-1_4_2-windows-i586.cab">
    <param name="codebase" value=".">
    <param name="archive" value="Esiti.jar">
    <param name="code" value="esiti.AppletNew.class">
    <param name="type" value="application/x-java-applet;jpi-version=1.4.2">
    <param name="scriptable" value="false">
    <param name="requestURL" value="http://[...........]">
    <param name="sid" value="2185266:0">
    <comment>
    <embed type="application/x-java-applet;jpi-version=1.4.2" codebase="." archive="Esiti.jar" code="esiti.AppletNew.class" width=770 height=313 scriptable="false" pluginspage="/ols/html/plugin/jinstall-1_4_2-windows-i586.cab" sid="2185266:0" requestURL="http://[....]">
    <noembed>
    No Java 2 SDK, Standard Edition v 1.4.1 support for APPLET!!
    </noembed>
    </embed>
    </comment>
    </obje-->
    Help me please!!!
    Thanks a lot, Francesca

    and it doesn't show me any errorsMore important: is the plugin that should run the applet started? In ie you can set security in such a way
    that active x controls are not started. You can install the jre but IE security will not allowe you to run it.
    Can you try to get a full trace from a machine where the applet doesn't run?
    To turn the full trace on you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log

  • There is anyone can convert applet code to application code?

    i got this applet code and would like to convert it to application code but don't know how.Anybody convert this please?
    thanks in advance.
    [email protected]
    //This program was completely written by Peter Wetsel.
    //If there are any questions about this code you
    //can email me at [email protected]
    //To get it to compile using jdk type "javac -nowarn battle.java".
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.lang.*;
    public class battle extends java.applet.Applet implements Runnable {
         Color col;
         String message= new String("");//holds the message placed in the upper left
         String Status = new String("");
         String message2[]= new String[5];//holds the destroyed messages in order for repainting.
         int hits=0;//the total number of hits by the player
         int numDestroyed=0;//the number of ships destroyed by the player
         int battlepos[]=new int[4];//the 4 positions of the battleship
    int carrierpos[]=new int[5];//the 5 positions of the carrier
         int subpos[]=new int[3];//the 3 positions of the submarine
         int patrolpos[]=new int[2];//the 2 positions of the patrol boat
         int destroyerpos[]=new int[3]; //the 3 positions of the destroyer
         int guesses=0;// the number of guesses by the player
         int player[][]=new int[10][10]; //to hold the positions of the player.(not until version 2)
         int guessed[][]=new int[10][10]; //hold the places that have been guessed by the player
         int computer[][]=new int[10][10]; //holds where the computers ships are
         int battleshipHitCt, destroyerHitCt, subHitCt, patrolHitCt, carrierHitCt;//keeps the hit count for each of the ships
         boolean init=false;//false until play is pushed.
         boolean ok=false;//boolean that is true if current boat position chosen by random is ok(getcarrier(), etc.)
         boolean battleOK=true;//false when the type of ship is destroyed
         boolean patrolOK=true;//...
         boolean subOK=true;//...
         boolean destroyerOK=true;//...
         boolean carrierOK=true;//...
         boolean won=false;//true when the player has won
         int o;
    public static void main (String args [])
    Frame frame = new Frame () ;
    battle applet = new battle () ;
    frame.add (applet) ;
    applet.init () ;
    applet.paint(g);
    applet.start () ;
         public void getCarrier(){
              int x, y, dir; //will hold a random x & y coordinate(0-9), and a random direction(0-1)(N,E,S,W)
              x=(int)(10*Math.random());
              y=(int)(10*Math.random());
              dir=(int)(100*Math.random()/25);
              if(dir==0)
                   while(y<4){
                        y=(int)(10*Math.random());
                   for (int i=0; i<5; i++){
                        computer[x][y-i]=1;
                        carrierpos=x*10+y-i;
              if (dir==1)
                   while(x>5){
                        x=(int)(10*Math.random());
                   for (int i=0; i<5; i++){
                        computer[x+i][y]=1;
                        carrierpos[i]=(x+i)*10+y;
              if (dir==2)
                   while(y>5){
                        y=(int)(10*Math.random());
                   for (int i=0; i<5; i++){
                        computer[x][y+i]=1;
                        carrierpos[i]=x*10+y+i;
              if (dir==3)
                   while(x<4){
                        x=(int)(10*Math.random());
                   for (int i=0; i<5; i++){
                        computer[x-i][y]=1;
                        carrierpos[i]=(x-i)*10+y;
         public void getBattle(){
              int x, y, dir;
              x=(int)(10*Math.random());
              y=(int)(10*Math.random());
              dir=(int)(100*Math.random()/25);
              while(!ok){
                   ok=true;
                   x=(int)(10*Math.random());
                   y=(int)(10*Math.random());
                   dir=(int)(100*Math.random()/25);
                   if(dir==0)
                        while(y<3){
                             y=(int)(10*Math.random());
                        for (int i=0; i<4; i++){
                             o=computer[x][y-i];
                             if (o==1){
                                  ok=false;
                   if (dir==1)
                        while(x>6){
                             x=(int)(10*Math.random());
                        for (int i=0; i<4; i++){
                             o=computer[x+i][y];
                             if (o==1){
                                  ok=false;
                   if (dir==2)
                        while(y>6){
                             y=(int)(10*Math.random());
                        for (int i=0; i<4; i++){
                             o=computer[x][y+i];
                             if (o==1){
                                  ok=false;
                   if (dir==3)
                        while(x<3){
                             x=(int)(10*Math.random());
                        for (int i=0; i<4; i++){
                             o=computer[x-i][y];
                             if (o==1){
                                  ok=false;
              if(dir==0)
                   for (int i=0; i<4; i++){
                        computer[x][y-i]=1;
                        battlepos[i]=x*10+y-i;
              if (dir==1)
                   for (int i=0; i<4; i++){
                        computer[x+i][y]=1;
                        battlepos[i]=(x+i)*10+y;
              if (dir==2)
                   for (int i=0; i<4; i++){
                        computer[x][y+i]=1;
                        battlepos[i]=x*10+y+i;
              if (dir==3)
                   for (int i=0; i<4; i++){
                        computer[x-i][y]=1;
                        battlepos[i]=(x-i)*10+y;
         public void getSub(){
              int x, y, dir;
              x=(int)(10*Math.random());
              y=(int)(10*Math.random());
              dir=(int)(100*Math.random()/25);
              while(!ok){
                   ok=true;
                   x=(int)(10*Math.random());
                   y=(int)(10*Math.random());
                   dir=(int)(100*Math.random()/25);
                   if(dir==0)
                        while(y<2){
                             y=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x][y-i];
                             if (o==1){
                                  ok=false;
                   if (dir==1)
                        while(x>7){
                             x=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x+i][y];
                             if (o==1){
                                  ok=false;
                   if (dir==2)
                        while(y>7){
                             y=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x][y+i];
                             if (o==1){
                                  ok=false;
                   if (dir==3)
                        while(x<2){
                             x=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x-i][y];
                             if (o==1){
                                  ok=false;
              if(dir==0)
                   for (int i=0; i<3; i++){
                        computer[x][y-i]=1;
                        subpos[i]=x*10+y-i;
              if (dir==1)
                   for (int i=0; i<3; i++){
                        computer[x+i][y]=1;
                        subpos[i]=(x+i)*10+y;
              if (dir==2)
                   for (int i=0; i<3; i++){
                        computer[x][y+i]=1;
                        subpos[i]=x*10+y+i;
              if (dir==3)
                   for (int i=0; i<3; i++){
                        computer[x-i][y]=1;
                        subpos[i]=(x-i)*10+y;
         public void getDestroyer(){
              int x, y, dir;
              x=(int)(10*Math.random());
              y=(int)(10*Math.random());
              dir=(int)(100*Math.random()/25);
              while(!ok){
                   ok=true;
                   x=(int)(10*Math.random());
                   y=(int)(10*Math.random());
                   dir=(int)(100*Math.random()/25);
                   if(dir==0)
                        while(y<2){
                             y=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x][y-i];
                             if (o==1){
                                  ok=false;
                   if (dir==1)
                        while(x>7){
                             x=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x+i][y];
                             if (o==1){
                                  ok=false;
                   if (dir==2)
                        while(y>7){
                             y=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x][y+i];
                             if (o==1){
                                  ok=false;
                   if (dir==3)
                        while(x<2){
                             x=(int)(10*Math.random());
                        for (int i=0; i<3; i++){
                             o=computer[x-i][y];
                             if (o==1){
                                  ok=false;
              if(dir==0)
                   for (int i=0; i<3; i++){
                        computer[x][y-i]=1;
                        destroyerpos[i]=x*10+y-i;
              if (dir==1)
                   for (int i=0; i<3; i++){
                        computer[x+i][y]=1;
                        destroyerpos[i]=(x+i)*10+y;
              if (dir==2)
                   for (int i=0; i<3; i++){
                        computer[x][y+i]=1;
                        destroyerpos[i]=x*10+y+i;
              if (dir==3)
                   for (int i=0; i<3; i++){
                        computer[x-i][y]=1;
                        destroyerpos[i]=(x-i)*10+y;
         public void getPatrol(){
              int x, y, dir;
              x=(int)(10*Math.random());
              y=(int)(10*Math.random());
              dir=(int)(100*Math.random()/25);
              while(!ok){
                   ok=true;
                   x=(int)(10*Math.random());
                   y=(int)(10*Math.random());
                   dir=(int)(100*Math.random()/25);
                   if(dir==0)
                        while(y<1){
                             y=(int)(10*Math.random());
                        for (int i=0; i<2; i++){
                             o=computer[x][y-i];
                             if (o==1){
                                  ok=false;
                   if (dir==1)
                        while(x>8){
                             x=(int)(10*Math.random());
                        for (int i=0; i<2; i++){
                             o=computer[x+i][y];
                             if (o==1){
                                  ok=false;
                   if (dir==2)
                        while(y>8){
                             y=(int)(10*Math.random());
                        for (int i=0; i<2; i++){
                             o=computer[x][y+i];
                             if (o==1){
                                  ok=false;
                   if (dir==3)
                        while(x<1){
                             x=(int)(10*Math.random());
                        for (int i=0; i<2; i++){
                             o=computer[x-i][y];
                             if (o==1){
                                  ok=false;
              if(dir==0)
                   for (int i=0; i<2; i++){
                        computer[x][y-i]=1;
                        patrolpos[i]=x*10+y-i;
              if (dir==1)
                   for (int i=0; i<2; i++){
                        computer[x+i][y]=1;
                        patrolpos[i]=(x+i)*10+y;
              if (dir==2)
                   for (int i=0; i<2; i++){
                        computer[x][y+i]=1;
                        patrolpos[i]=x*10+y+i;
              if (dir==3)
                   for (int i=0; i<2; i++){
                        computer[x-i][y]=1;
                        patrolpos[i]=(x-i)*10+y;
         public void run(){// to be in here so can compile
         public void init() {
              for (int i=0; i<10; i++){//initializes the guessed matrix to be all 2's(not been guessed)
                   for (int j=0;j<10; j++){
                        guessed[i][j]=2;
              for (int i=0; i<2; i++){//initializes array to be all zeros
                   patrolpos[i]=0;
              for (int i=0; i<2; i++){
                   destroyerpos[i]=0;
              for (int i=0; i<2; i++){
                   subpos[i]=0;
              for (int i=0; i<2; i++){
                   carrierpos[i]=0;
              for (int i=0; i<2; i++){
                   battlepos[i]=0;
              battleshipHitCt=0;//initialize all hit counts
              destroyerHitCt=0;
              subHitCt=0;
              patrolHitCt=0;
              carrierHitCt=0;
         //get all boat positions
              getCarrier();
              ok=false;
              getBattle();
              ok=false;
              getDestroyer();
              ok=false;
              getSub();
              ok=false;
              getPatrol();
         public void paint(Graphics g) { //this is the shots paint method... draws a line from its last position to its current position, basically
         if (!init && !won){//draws screen before play is pushed
                   g.setColor(col.white);
                   g.fillRect(0,0,600,320);
                   g.setColor(col.black);
                   g.fillRect(20,20,30,25);
                   g.setColor(col.white);
                   g.drawString("PLAY", 23,30);
                   g.setColor(col.black);
                   g.drawString("This is different that usual battleship, here the goal is",23,65);
                   g.drawString("to find all of the computers ships in the least number of guesses.",23,85);
                   g.drawString("<30 turns --- You have too much luck!", 23, 105);
                   g.drawString("31-50 turns --- Excellent!", 23, 125);
                   g.drawString(">=51 turns --- You have no skills!", 23, 145);
                   g.drawString("PRESS PLAY TO BEGIN", 23, 165);
              if (init && !won){//draws grid and messages
                   g.setColor(col.black);
                   g.fillRect(0,0,600,320); //makes big, black rectangle washover
                   g.setColor(col.white);
                   g.drawString("# of Guesses = " + guesses,500, 280);
                   for (int i=0; i<11; i++)
                        g.drawLine(20,20+i*28, 300, 20+i*28);
                   for (int i=0; i<11; i++)
                        g.drawLine(20+i*28,20,20+i*28,300);
                   char ch='A';
                   for (int i=0; i<10; i++){//draws letter accross the top
                        g.drawString(ch+" ",30+28*i,13);
                        ch++;
                   ch='1';
                   for (int i=0; i<9; i++){//draws numbers down the side
                        g.drawString(ch+" ",10,40+28*i);
                        ch++;
                   g.drawString("10", 6,290);
                   g.drawString(message,420,40);
                   for (int i=0; i<numDestroyed; i++){
                        g.drawString(message2[i], 305, 40+(i+1)*20);
                   g.setColor(col.black);
                   //next puts in any circles already guessed
                   for (int i=0; i<10; i++)
                        for (int j=0; j<10;j++){
                             if (guessed[i][j]==1)     {
                                  g.setColor(col.red);
                                  g.fillOval(i*28+30, j*28+30, 10,10);
                             if (guessed[i][j]==0)     {
                                  g.setColor(col.white);
                                  g.fillOval(i*28+30, j*28+30, 10,10);
         public boolean seeifahit(int x, int y){//sees if the shot was a hit or not
              if(computer[x][y]==1)
                   return true;
              return false;
         public String getshiptype(int x, int y){//returns the name of the ship that was hit
              for (int i=0;i<4; i++)
                   if (battlepos[i]==x*10+y){
                        battleshipHitCt++;
                        return "Battleship";
              for (int i=0;i<3; i++)
                   if (subpos[i]==x*10+y){
                        subHitCt++;
                        return "Submarine";
              for (int i=0;i<2; i++)
                   if (patrolpos[i]==x*10+y){
                        patrolHitCt++;
                        return "Patrol Boat";
              for (int i=0;i<5; i++)
                   if (carrierpos[i]==x*10+y){
                        carrierHitCt++;
                        return "Carrier";
              for (int i=0;i<3; i++)
                   if (destroyerpos[i]==x*10+y){
                        destroyerHitCt++;
                        return "Destroyer";
              return " ";
         public void gameOver(){//displays guesses and ends
              if (!won){
                   Graphics g = getGraphics() ;
                   g.setColor(col.black);
                   g.fillRect(0,0,600,320); //makes big, black rectangle washover
                   g.setColor(col.white);
                   g.drawString("YOU WIN!!", 200,100);
                   String out=new String("It took you "+guesses+" tries!");
                   g.drawString(out, 200,120);
                   g.drawString("Press refresh on your browser to play again", 200, 150);
                   won=true;
         public boolean destroyed(){
              if(battleshipHitCt==4 && battleOK)
                   battleOK=false;
                   return true;
              if(carrierHitCt==5 && carrierOK)
                   carrierOK=false;
                   return true;
              if(subHitCt==3 && subOK)
                   subOK=false;
                   return true;
              if(patrolHitCt==2 && patrolOK)
                   patrolOK=false;
                   return true;
              if(destroyerHitCt==3 && destroyerOK)
                   destroyerOK=false;
                   return true;
              return false;
         public boolean mouseDown(Event e, int x, int y) {//handles when a mouse key is pressed(either key)
              String type= new String("");
              if (!won){
                   message="";
                   Graphics g = getGraphics() ;
                   g.setColor(col.white);
                   int xindex, yindex, val;
                   if (x>20 && y>20 && y<300 && x<300 && init){
                        guesses++;
                        g.setColor(col.black);
                        g.fillRect(490,260, 550, 285);
                        g.setColor(col.white);
                        g.drawString("# of Guesses = " + guesses,500, 280);
                        g.setColor(col.black);
                        g.fillRect(419,30,580,95);
                        g.setColor(col.white);
                        xindex=(x-20)/28;//converts x coordinate into index(A-J) in form of (0-9)
                        yindex=(y-20)/28;//converst y coordinate into index(0-9)
                        val=guessed[xindex][yindex];
                        if (val==2){
                             if (seeifahit(xindex,yindex)){
                                  type=getshiptype(xindex, yindex);
                                  hits++;
                                  g.setColor(col.white);
                                  guessed[xindex][yindex]=1;
                                  if (!destroyed()){
                                       message=type + " Hit";
                                       g.drawString(message, 420, 40);
                                  else{
                                       g.setColor(col.white);
                                       message2[numDestroyed]=new String("");
                                       message2[numDestroyed]=type + "Destroyed";
                                       numDestroyed++;
                                       g.drawString(message2[numDestroyed-1] , 305, 40+(numDestroyed)*20);
                                  g.setColor(col.red);
                             else guessed[xindex][yindex]=0;
                             g.fillOval(xindex*28+30, yindex*28+30, 10,10);
    else {
                             g.setColor(col.white);
                             message="That has already been guessed";
                             g.drawString(message,420,40);
                   if (x>20 && x<40 && y>20 && y<40 && !init){
                        init=true;
                        paint(g);
                   if (hits>=17){
                        gameOver();
                        System.exit(0);
              return true;

    replace following in main method
    applet.paint(g); by
    repaint(); and
    applet.start() by
    // applet.start() at least compile your source code and if all runs the normal way it shoul be an application
    PS: i think there is a way in javac to tell it your source is an applicat. and not an applet

  • applet code multiple classes help :(

    Ok, i made an applet which have 2 .class files one is AppTs.class and other is MyPot.class, what I need to write to lets say index.html
    to make that applet viewable in browser. Thx.
    I try this but it say Applet failed to load...
    <HTML>
    <BODY>
    <APPLET CODE=AppTs.class WIDTH=200 HEIGHT=100>
    <APPLET CODE=MyPot.class WIDTH=200 HEIGHT=100>
    </APPLET>
    </BODY>
    </HTML>

    Are you sure, could be because, I am using Pirc bot Framework, which isn't in standard Java libraries, is maybe that causing problem, because, applet works perfectly when i run it from Eclipse IDE.
    And that your HTML code that you write, it makes 2 applets, but i need only one because GUI is only in AppTs, why is that happening neither?
    Edited by: systat on Mar 28, 2008 11:35 AM

  • Don't want to re-execute applet code, when refresh browser

    Hi,
    I am developing online exam project, here my issue is in timer, I am creating timer in thread.sleep(1000); (ie) 1000 mili sec = 1 sec. once exam started, i am started reducing timer value. While moving to next question, I want previous Applet timer value in next page. Here i am getting initial value of each time refreshing,
    example:
    suppose timer running in browser like this : 00:00:46 ----> when refresh same page i need value reduce from 00:00:46, But its reload from initial value (ie): 00:00:59 in below example code.
    Here is my Applet code :
    import java.awt.*;
    import java.util.*;
    import java.applet.*;
    import java.net.*;
    public class myclock1 extends Applet implements Runnable
    Thread t,t1;
    int hour=0,minute=0,second=0;
    URL targetURL;
    String URLString = "http://localhost:8080/testing/examresult.jsp";
    AppletContext context;
    public void start()
    minute = Integer.parseInt(getParameter("min"));
    second = Integer.parseInt(getParameter("sec"));
    context = getAppletContext();
    t = new Thread(this);
    t.start();
    public void run()
    t1 = Thread.currentThread();
    repaint();
    public void paint(Graphics g)
    if(hour==0 && minute==0 && second==0)
    try
    targetURL = new URL(URLString);
    catch (MalformedURLException e)
    // Code for recover from the exception
    context.showDocument(targetURL);
    t.destroy();
    t1.destroy();
    this.destroy();
    second--;
    if(second==-1)
    second = 59;
    minute = minute-1;
    if(minute==0)
    if(hour>=1)
    hour = hour - 1;
    minute = 59;
    g.drawString(hour + ":" + minute + ":" + second, 20, 30);
    repaint();
    try{
    t1.sleep(1000); /// 1000 mili sec = 1 sec
    catch(InterruptedException e)
    In JSP Page Code:
    <jsp:plugin type="applet" code="myclock1.class" height="150" width="300">
    <jsp:params>
    <jsp:param name="min" value="0" />
    <jsp:param name="sec" value="60" />
    </jsp:params>
    </jsp:plugin>
    How to do that, Urgent Plz help me.
    Thanks in Advance,
    S.Shyam.

    Is it SAX, Dom, JAXB or something else you are talking about?

  • Help with simple applet code

    i wanted to write a applet that would display a image,(this is my first program) i wrote the code shown below,but image space is emptly when i load it up with any browser.....i ran the code in netbeans,,, i am a novice, any piece of advice also wud be helpful.........
    <applet code="imagereadingapplet" width=500 height=500>
    <param name="img" value="kollam.gif">
    </applet>
    import java.applet.*;
    import java.awt.*;
    * @author raman
    public class imagereadingapplet extends Applet {
    * Initialization method that will be called after the applet is loaded
    * into the browser.
    Image img;
    @Override
    public void init() {
    img = getImage(getDocumentBase(),"kollam.gif");
    @Override
    public void paint(Graphics g){
    g.drawImage(img,0,0,this);
    // TODO overwrite start(), stop() and destroy() methods
    }

    Hi,
    First advice imagereadingapplet -> ImageReadingApplet (Java name convention).
    Second image file name is hard coded so you don't have to set param for the applet (Best would be not to hard code this name).
    Finally maybe the most interesting, It seems that image kollam.gif is not at root folder.
    I don't really know netbeans but your image must be in bin folder, the same as imagereadingapplet.class.

  • Applet code protection

    Hi
    I'm developing a commercial web application, and I'd like some advices about applet code protection.
    This applet we need will allow the visual design of some hardware. The parameters that are used in its creation are all visible and user supplied, and those are the same that are communicated to the server to store the design data, so this is not the security issue.
    The main point is about mathematical formula, some static parameters (data tables) and a few algorithms used to turn the parameters into a visual representation (drawn in the applet) and discover a few more advanced hardware design data (like weight, volume, area) based on those input parameters. It is a quite complicated calculation, will be created for a dozens of different hardware types, we are putting a lot of effort into this, and don't want it to be stolen, once the application goes into production.
    Legal notices will be in place, but if someone steals the code, even legal actions will not undo the damage. Code techniques I know are checking the host (easy to bypass) and code obfuscation (makes the job harder, but thiefs are people with a lot of patience), and I'm not entirely happy with them, and I couldn't find any more good alternatives around.
    A very secure option is making all this sensitive code server side, request parameters and just send an image back to the user, but that would cripple the server with too much math processing and image generation, and much less responsive for the end user (a major issue as well)... those are the reasons I thought about applets in the first place.
    Another way that came to my mind was providing an applet just with drawing capabilities, and making it request the needed formula at runtime (our communication is HTTPS), but that does not avoid interception at code level.
    I'd appreciate any advice or suggestion you could give, protection approachs or changes.
    Many thanks!

    dev@java wrote:
    The main point is about mathematical formula, some static parameters (data tables) and a few algorithms used to turn the parameters into a visual representation (drawn in the applet) and discover a few more advanced hardware design data (like weight, volume, area) based on those input parameters. It is a quite complicated calculation, will be created for a dozens of different hardware types, we are putting a lot of effort into this, and don't want it to be stolen, once the application goes into production.
    Legal notices will be in place, but if someone steals the code, even legal actions will not undo the damage.In terms of risk analysis: exactly what damage could be done by somebody with your code? For example what could I do if I had a copy of your applet which would cause you harm? And what harm would that be?

  • APPLET CODE WITH PACKAGE

    Hello,
    I have o code in a package and I do not know how to write the html file the code parameter is not enough I think. Do I have to add package=myapplication?
    Thanks in advance
    This is my html file
    <applet code="myapplication.class" >
    </applet>

    Let's assume that your Package is named package1 and your applet class file is named applet1.
    Now you must place your applet1 in a folder package1.
    Now, the html file looks like this
    <applet code="package1.applet1" width=300 height=200>
    </applet>
    You don't need to use codebase if you are in the root directory of the package.
    Get Your Java apps rated - http://www.thejavahub.com
    Find Great Java Applets, Applications & Servlets - http://www.thejavahub.com

Maybe you are looking for

  • Can two frames use the same SessionInfo object?

    Hi, I have some questions on using InfoBus Frame. Do parent frame and child frame HAVE TO make use the same SessionInfo object? I tried to show Master table and Detailed table in seperate frame without login twice. I am lucky it works since I happene

  • Need to insert into a table 1 of the fields (CLOB)with more than 4000 chars

    Dear Gurus, As far I understood, I need to write a function which get as parameter the large text and using bind variables I can return a CLOB containing more than 4000 chars. I tried all I can do and feel I want to died. Please, can I get specified

  • Does Global Temporary Table help in performance?

    I have a large database table that is growing daily. The application I have has a page for the past day data and another for some chosen period of time. Since I'm looking at a very large amount of data for each page (~100k rows) and having charts bas

  • Convert spool output of ABAP list into excel and send email

    Hello All,   I have a requirement where we need to 1. schedule a background job programtically 2. moniter backround job (if complete or not) 3. once its complete take spool output ,convert into excel and email. I have following difficulties.   1. i h

  • Convert BIGINT Timestamp to a Datetime???

    I have the following date in  Bigint 130234176000000000     how to convert it to a proper date? The command below gave me an error select dateadd(second,  (Convert(bigINT,convert(varchar,[Time])))/1000 + 8*60*60, '19700101') I did the command below b