Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

That @#$%!% codebase

  Asked By: Juana    Date: Aug 07    Category: Java    Views: 614

This confuses me darned near every time I do it, to my utter
frustration. Can't seem to find the applet.

JSP generates this HTML:

<applet id="Fetch"
codebase="classes/" height="50" width="200">
<param name="ModelName"

The applet is not in a jar, and is located at
classes/com/taylorlumberinc/applet/FetchDataFields.class relative to
the directory containing the JSP. It is in package

What, oh what, am I doing wrong? I've tried nearly every permutation
of codebase possible.



6 Answers Found

Answer #1    Answered By: Benjamin Simpson     Answered On: Aug 07

did u try to give the real path.

suppose your applet container,


then your code base will be /main/classes.

Answer #2    Answered By: Adalwen Fischer     Answered On: Aug 07

Well, this might be a server problem. I put the applet in a jar, and
it still didn't work. BUT ....

I'm running Apache 2 on port 80 and Tomcat on 8080. Now, If I take
the emitted HTML and drop it into a file and run it with Apache from
the same location, it works. But when running the JSP with Tomcat, it

Answer #3    Answered By: Dylan Evans     Answered On: Aug 07

then give full url as codebase


Answer #4    Answered By: Kerry Wright     Answered On: Aug 07

I have a JSP page containing a Applet & it works perfectly without any error.

1. I have a applet named MyApplet.class inside classj/com/applet
relative to my JSP page.

2. It's not inside contain a package (means i hv not used "package"
keyword in my applet, i just put it the sub-folders)

wht i have found is if you are not using package & using
CODE="com.applet.MyApplet", the Applet is not initializing. So try to
use the following syntax.

(or) put

package com.applet; // u put ur package name in first line of ur
applet,compile it & follow ur own system of initializing the applet.

even if it's not working plz tell me whether u r using package are not?


<APPLET code="MyApplet.class" codebase="classj/com/applet"
width="500" height="100"></APPLET>

Answer #5    Answered By: Miriam Green     Answered On: Aug 07

I thought I had this figured out, but maybe not. Might have been some
browser caching confusing me. Took it out of the package and it's
loading OK. I'll worry about the package later. Thanks for
everyone's advice. But now I have a new problem.

I can't access Java methods from my JavaScript. Relevant lines from
the HTML:

function lgoto(n){
var i;
for ( i=1 ; i<=guide_cols ; i++ ){
var hc=sel_row%2 ? 'rowh' : 'row';
document.DataLink.refreshData(""+n); <-- bad line


<applet id="DataLink" name="DataLink" code="RowDataLink.class">
<param name="ModelName"

The applet source is:

* RowDataLink.java
* Created on October 7, 2004, 9:17 AM

import HTTPClient.HTTPResponse;
import HTTPClient.HTTPConnection;
import HTTPClient.NVPair;
import java.util.HashMap;

* @author dcouchotvore
public class RowDataLink extends java.applet.Applet {

protected String model_name="";
protected HashMap Data=null;
protected HTTPConnection conn;

/** Initialization method that will be called after the applet is
* into the browser.

public void init()

try {
Data=new HashMap(50);
conn=new HTTPConnection(getCodeBase());
catch ( java.io.IOException E ){

/** Fetches the nth row of the ResultSet attached to the specified
* model, returning them in ColumnName=(String)value format,
* by newlines. */

public void refreshData(String _n)
NVPair fdata[]={
new NVPair("modelname", model_name),
new NVPair("index", _n)
try {
HTTPResponse resp=conn.Post("FetchDataFields", fdata);
String rdata=new String(resp.getData());
String[] lines=rdata.split("\n");
for ( int i=0 ; i<lines.length ; i++ ){
String[] pair=lines[i].split("=");
Data.put(pair[0], pair[1]);
catch ( java.io.IOException E ){
// @@@ to be continued...
catch ( HTTPClient.ModuleException E ){
// @@@ to be continued...

public String getField(String _name)
return (String)Data.get(_name);

public void putField(String _name, String _value)
Data.put(_name, _value);

Firefox says, "Error: document.DataLink.refreshData is not a function".
IE says something like "Object does not support this propery or method".

Any thoughts on this? What's really frustrating is that I did an
almost identical applet before and didn't run into all this trouble.
Maybe there's a curse...

Answer #6    Answered By: Alberta Miller     Answered On: Aug 07

It wasn't really a problem with codebase, after all. Seems
to be a factor of that port 8080, and also works on IE. (I was
developing with FireFox.) Guess I'll zip a note off to the Firefox
folks to check on that.

Didn't find what you were looking for? Find more on That @#$%!% codebase Or get search suggestion and latest updates.

Related Topics:



Related Post