Content:
In this document I'll try to answer some common questions and discuss some important Internet techniques.

What are Java applets?
What is a Java plug-in and do I need it?
My Java applet doesn't work what should I do?
What's PHP and ASP and how useful are they?
What's CGI and how useful is it?
What are Java servlets and how useful are they?
What are cookies and how useful are they?
What's JavaScript and how useful is it?
JavaScript to Java Applet communication and visa versa is that possible?
Java applet to Java Applet communication is that possible?
What's cascading style sheets (CSS)?
Are Password applets reliable?


Applets ?: To top
Applets are small programs that run on an html page.
They are automatically downloaded by the browser and executed on the visitors computer.
They are visible inside a square on the html page.
Because they are executed on the visitor's computers many security restrictions are applied.
For example when downloaded from the Internet then applets don't have access to your hard disk.
Also they can only connect back to the host they originated from.

Java plug in ?: To top
I often get questions about Java plug ins.
Something like my computer doesn't display Java do I need a plug in ?
Almost every browser is capable of displaying Java applets without a plug-in!
Java applets written for Java version 1.02 should not be a problem.
A plug in is often used to install a higher version of Java to your browser.
This new Java version does have a lot of advantages.
The downfall: the Java plug in is quite large some 2Mb!
So it doesn't make sense to use the new Java version on pages for the general public.

A very few browsers seem to be shipped without any Java at all.
Then we are talking about 1% or less.
In my opinion a browser should have Java enabled.
The use of Java applets is widely spread on the Internet.
All modern browsers Netscape and Explorer seem to be shipped with Java.

Mac OS Runtime for Java (MRJ) http://www.apple.com/java/
SUN Java Plug-in (also for Windows platform)
If I did read the instructions right:
It forces the browser to use the Sun Java Runtime Envierment (JRE) instead of the browsers one.
Instead of the <applet...> you need to use the <object...> tags to use the plug in.
So this one should work for Netscape and Ms Explorer.
New Java Virtual Machine from Microsoft.
Think this one is mainly a bug fix.
I don't think it will increase your Java version.
It's NOT possible to uninstall this one!
This version does implement Microsoft's Windows Foundation Classes (WFC).
It makes it easer to access Win32 functions.

My applet doesn't work ?: To top
There could be a lot of reasons for this.
First thing to do is to open the browsers Java console.
Netscape users: It's located somewhere at one of the pull down menus.
Ms Explorer 5.x users: By default there is no Java console enabled.
You need to enable it first.
Tools, Internet options, advanced, enable java console.
Then restart your browser.
After this you will see a Java console somewhere at one of the pull down menus.

Most likely it will display some Java Exceptions.
These at least should give a developer some clue of what is going wrong.
Most common exceptions are ClassNotFoundException, some SecurityException, NullPointerException.

ClassNotFoundException means that the browser couldn't get the Java program for some reason.
One of the most common causes: the Webmaster did forget to upload it to the Internet.
Try to type the url to it on the browser http://.....
If its there the browser will respond with a question download or open it.
If not it will respond with a 404 error (File Not Found).
Please not that its case sensitive.
Also if used check the codebase attribute of the <applet..> tag.
Second omit any reference to codebase, remove the codebase attribute and then put all files in the same directory.

Security Exceptions:
They are a real pain in the ass.
As I told earlier applets are downloaded by the browser and executed on the visitors computer.
There are some differences on how the security mechanism is implemented.
There are some general rules that all browser brands seem to follow.
Also it differs from operating system to operating system.
Security is a good thing but it limits the use of applets.

It is possible to sign an applet.
This way the browser knows from whom this applet is.
It will most likely pop up a dialog asking if you trust this thing.
It's possible to install a certificate of someone at your browser.
This means that you tell the browser to trust applets from this person.
The downfall is: There are a lot of different browser brands, Java vendors, and Java versions.
They all seem to implement their own security mechanism.
So it's very hard to write a single code that implements them all.
In my opinion it's ONE BIG MESS.
Also a certificate is quite expensive.
Think US $200.-- is way to much.

NullPointerException:
This is a very general Exception.
It means that the Browsers Java Virtual Machine tries to do something with an object that isn't there.
For example: g.drawImage(myPicure,x,y);
If myPicture isn't there (its null not defined) this will throw a NullPOinterException.

PHP, ASP ?: To top
PHP and ASP are code that you insert in your html source.
It's a scripting language, which is executed by the provider's server before it's sent to the browser.

When you ask for an html page you can send information to it.
Mostly it is done by adding query string at the end of the URL.
The query string is the thing after the question mark.
For example: http://www.myweb.com/dir/page.htm?myName=rob&myAge=200.
The PHP and ASP script can access the variables myName and myAge directly.
Depending on their value they can insert html code to the page.
For example "Hello rob are you not feeling a little old ?"

Its also possible to let PHP and ASP read data from a Database.
Or even read/write files on the providers server.
ASP and PHP are also great tools to work with cookies.

CGI : To top
CGI means Common Gateway Interface.
It works a lot like PHP and ASP.

CGI is stored in a separate file.
The script itself isn't stored at the html source.
It's stored in a separate file.

There are two ways to use a CGI script
One way is to call it directly. http://myServer.com/cgi-bin/myScript.pl
The output of the script is sent to the browser.
The other way is to implement some calls to the script into the html page.
The call is then replaced by the output of the script.

CGI is older then PHP and ASP.
With CGI you need to have a special configured directory to place your scripts in.
Most things you can do with CGI can be accomplished with PHP and ASP more easily.
The advantage of CGI is that you can call system processes directly.

Mostly CGI script are written in the Perl language.
But other languages are also possible.
The C language is also often used because it's faster.

Servlets ?: To top
Servlets are a kind of Java applets that are executed on the providers' side.
Although this description isn't quite accurate.

Servlets are written in the Java language.
They are often used to handle the page request of a browser.
Normally the handling is done by the providers' http software.
But with servlets it's redirected to the servlet engine.
Servlets can be called by the browser in a variaty of ways.

The providers' server must be enabled for servlets.
Servlets are quite useful and powerful things but they are not widely used jet.

Cookies ?: To top
Cookies where invented by Netscape.
When you visit a site your browser can store a small data file on your computer.
This is called a cookie.
This file can be retrieved back when you revisit.

To protect your privacy this cookie file can only be red from the place that set it.
Cookies also don't last forever.
They have an expiration date.
When the date is passed the cookie is removed automatically.

The number of cookies and the size of each cookie is limited.

Cookies are very useful to give a visitor an identity.
This identity can be used to grant or deny access to a page.
It also is a great tool for statistics.
It makes it possible to answer questions like how many times does the average visitor return.

JavaScript ?: To top
JavaScript is added to the source of a html page.
Its main purpose is to control the layout of a page.
It's also possible to let it check a form input before its transmitted.

Java Script is used very often at html pages.
It looks a lot like the Java language.
It also was invented by Netscape.
In the very early days it was called LiveScript

There is a big difference between Java Applets and JavaScript.
Java applets are displayed on a square on the html page.
Java applets generally aren't used to control the layout of a page.

JavaScript to Java Applet communication. To top
It's possible to write generic code that allows a Java Applet to call JavaScript routines.
Also the other way around is possible.

However this will not work with all browser and operating system combinations.
Although I couldn't verify this.
It seems that the Java to JavaScript bridge is missing on the Macintosh.
Also its told to me that Ms Explorer 4.x on Windows couldn't do it.
But test show that it works there.
Think it depends on the browsers service pack installed
Anyway it will work with most browsers.

Applet to applet communication : To top
Yes it is possible.
Mostly it is done by sharing a static object or variable.
Although you can't test if the other applet has loaded and already initialized.

Cascading Style Sheets (CSS). To top
CSS makes it possible to better lay out your html page.
Unfortunately not all browsers do support it or partly support it.
So you must be careful with CSS.
But it's getting better.

With cascading style sheets you can tell how a <HR> must look like.
Or how it should display <H1>
CSS is a very useful tool to layout html pages.

There are some very nice things you can do with JavaScript in combination with CSS.
For example move some pictures around the browsers screen.
This also is called dynamic html.

Password applets: To top
Password applets are not a secure way to protect a site.
They work by trying to hide the link to the protected site.
The browser is forwarded to the site when the correct password is entered.
By using this link directly you bypass the applet.
So when the http://... of the site is known you can bypass the applet.

Better is to use PHP or ASP in combination of a cookie. Cookies are discusses earlier.

Another way is to use the .htpasswd method.
This method only works if the provider uses apache software.
Also this apache software must be enables for it.
Most providers use apache software to server their http pages.

 
 
 
 
 
 
 
 
 
 


© RJHM van den Bergh/Comweb, webmaster