The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Thanks, and a follow-on question

Posted by Rich Sorensen on December 10, 2001 at 11:25 PM


Thank you very much for the help. I am using Forte v3.0 as my IDE and had tried creating a jar file with their built-in Jar tool (it creates a file named "xxx.jarContent"). However, when I tried using on the web site (and inserting the "archive" lines in the calling web page), it failed with an "unable to find class xxxx" error. However, I just tried using JAR32.exe, and that worked properly. I guess the Forte tool is N/G.

The current syntax I'm using for getting the icon file is:

URL hURL = AppletObject.getClass().getResource("name.gif");
IconObject = new ImageIcon(hURL);

According to the documentation I've looked up, the format of the auth header is:

"Authorization: Basic username:password"

where the "username:password" string is Base64-encoded as you indicated. But the question is, how would I add this header to the URL object above?

Rich Sorensen

> 1. How can I get the applet authentication turned off? (the credentials supplied in the login are sufficient to read the icon files from the web server).

> With basic authentication, the server expects to find an HTTP header entry called "Authorization". The value of this header is created in this way:

  1. Concatenate the username with a colon and the password. Example: "webuser:webpassword".
  2. Base64-encode this value. The result should be something like "d2VidXNlcjp3ZWJwYXNzd29yZA==".
  3. Prepend the value with "Basic ". Example: "Basic d2VidXNlcjp3ZWJwYXNzd29yZA==".

> Every time you make a request to the server to get an image, include this header value.

> 2. Is there a way to include and compile graphic files as resources within a Java app so you don't have to read them from external files? (like you can do with VB and C++).

> You can't compile them in, but you can include the applet and the resources within the same jar file. Access the resources with getClass().getResource().


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us