This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes GetDocumentBase always returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "GetDocumentBase always returning null" Watch "GetDocumentBase always returning null" New topic
Author

GetDocumentBase always returning null

Ricardo Prado
Greenhorn

Joined: Oct 01, 2010
Posts: 13
Hello everyone,

I'm using the method "getDocumentBase()" to get the url where my applet is deployed, but this method ALWAYS returns null!

I've already tried using it inside the init or start method. It always returns null, I have no idea why.


If I use it inside the start method, the Applet draws itself and then it broke(nullpointer exception because I tried to use the URL returned by getDocumentBase)

What can I do?
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi,

You use the following code

URL base = getDocumentBase();

in your init() method. It shoul return the applet document value.

If still with issue kindly post your code

Binu
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GetDocumentBase always returning null
 
Similar Threads
where to put image jar files
url problem
getDocumentBase() not working???
Read xml file placed on localhost
how to use getDocBase() in Java