aspose file tools*
The moose likes Applets and the fly likes Why does getCodeBase return null? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Why does getCodeBase return null?" Watch "Why does getCodeBase return null?" New topic
Author

Why does getCodeBase return null?

Baijun Jiang
Greenhorn

Joined: Oct 13, 2005
Posts: 17
Hi. I have an applet invoked by a jsp page.

<APPLET height=500 width=900
code="applet/trend/trendchart">
</APPLET>

I got this this error:

java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Unknown Source)
at applet.trend.trendchart.getServletConnection(trendchart.java:212)
...

in what kind of situation getCodeBase() can return a null value?


SCEA, CISA.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
The javadocs don't mention that it could or should ever return null.

Are you running this on a web server, via appletviewer or are you opening a local HTML file?
Baijun Jiang
Greenhorn

Joined: Oct 13, 2005
Posts: 17
I am running it on a tomcat server.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
Loooking at it again I notice that it doesn't actually return null, it has an internal NPE. I'm surprised it works at all with the "applet/trend/trendchart"; that should contain dots, not slashes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does getCodeBase return null?