We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Java Applet produces a Blank screen in HTML

Hello!
1st let me apologize if I have duplicated a post. I am a newbie to DaniWeb (and to Java and HTML) and have searched your forum for a few hours now and not found and answer to my problem. I was hoping someone could help.

I have a simple Java program that reads a MS Access Database and displays selected fields from each record on the screen until the end-of-file. It works wonderful in Eclipse!

I then have a HTML file which implements the java .class file created "TechServices.class".

==============================================================================================================
Here is the code for the Java program:

import java.sql.*;
import java.applet.*;
import java.awt.*;


public class TechServices extends Applet { public static void main(String[] args) {
    try {          
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");          
        String accessFileName = "C:/TEST/Tech ServicesCOPY";          
        String connURL="jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+accessFileName+".accdb;";          
        Connection con = DriverManager.getConnection(connURL, "","");          
        Statement stmt = con.createStatement();          
        stmt.execute("select * from tblProblemInformation"); 
        // execute query in table student 
        ResultSet rs = stmt.getResultSet(); 
        // get any Result that came from our query  
        if (rs != null)  while ( rs.next() ){
            String pdate = rs.getString("dtmProblemDate");
            if (pdate != null) pdate = pdate.substring(0,10); // strip off time of 0's
            String cdate = rs.getString("dtmClosedDate");
            if (cdate != null) cdate = cdate.substring(0,10); // strip off time of 0's
            System.out.println("#" + rs.getString("strProblemNumber") 
                                + " Problem-Date: " + pdate
                                + " Close-Date: " + cdate
                                + " AssignedTo: "+rs.getString("strAssignedTo"));
//          System.out.println("0---------1---------2---------3---------4---------5---------6---------7---------8");
        }   
        stmt.close();             
        con.close();         
    }         
    catch (Exception err) {             
        System.out.println("ERROR: " + err);         
    } 
} 
}

==============================================================================================================

Here is the code for the HTML:

<html>
<head>
</head>
<body bgcolor="pink">
<applet code="TechServices.class" width=1000 height=500>
</applet>
</body>
</html>

==============================================================================================================

Can anyone tell me why this produces nothing but a blank screen when I run the HTML file?

Thanks in advance for your attention to this matter!

3
Contributors
9
Replies
3 Hours
Discussion Span
1 Year Ago
Last Updated
11
Views
TakinANapster
Newbie Poster
5 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Look in the browser's java console for any error messages.
You should call the printStackTrace() method in the catch block to get better error messages.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

Thanks for the fast response!

I'm not sure how to use my Java Console yet. I have went thru lots of tutorials so far, but none have touched on that.

I tried putting the printStackTrace() method, and it forced me to actually write a method, which I did ... which simply statet "System.out.println("ERROR!!!");".

This this did fix the problem, nor did I get the message "ERROR!!!".

Any other ideas? I'm at a total loss. I will start studying the Java Console immediately!

ThanX in advance!

TakinANapster
Newbie Poster
5 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Sorry....I meant to say, this did "NOT" fix the problem...

TakinANapster
Newbie Poster
5 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Printing out the full text of error messages helps you find the problem, It will not fix the problem.

You must find the browser's java console to see if it has any error messages. Go to th control panel, open the Java icon and make sure the java console is set to be displayed.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

Looking at your code I can't see code that would display anything on the screen/in the browser window. You just print things to System.out, which is the java console.
To display things on the screen/in the browser window you will need to useSwing components such as JLabel or JTextArea

JamesCherrill
... trying to help
Moderator
8,494 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29

I clicked on "Show Console" and exited Control Panel, and refreshed my webpage and the console did not pop up. Shouldn't it have?

The only time I have seen it is when I had an error in my Java code that HTML did not like and I had a red mark ... that if I clicked the Java Console would come up; but I knew nothing of what to do with the console.

I'm searching on Youtube and Google for a tutorial on the Java Console but no luck so far. Can anyone recommend any links or good books?

TakinANapster
Newbie Poster
5 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Some browsers require you select a menu item. They all seem different. Keep poking at it until you find it.

what to do with the console.

About all you do is read info from it.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

I'm not having any luck making my Java Console visible. The service is started.

How do I bring up the Java Console? I know this must be a stupid question to most of you out there :(

TakinANapster
Newbie Poster
5 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Try rebooting the PC. Maybe the change you made in the Control panel needs a boot to take effect.

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0880 seconds using 2.81MB