Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing a servlet's input stream from an Applet



Jim Solderitsch <email@hidden> wrote:

>I sent an earlier posting regarding the applet not being found (error
>was originally bad magic number) and I overcame this by removing the
>applet from the security pattern for the protected folder (defined in
>the web.xml config file).

Although that fixed things, I'm left wondering why it was a "bad magic
number" exception and not a SecurityException. Without knowing exactly
what the code was doing (or not doing) as it got to the point of throwing
the exception, it's hard to guess whether that little misbehavior is
significant or not. For example, it might be the same underlying problem
that your seeing with the InputStream, but manifested in a different way.
One correlation is that both problems had to do with InputStreams reading
data and not getting the correct data, or possibly any data at all. It
might be useful to know if "bad magic number" can be thrown if a
class-file's bytes contain no data at all. If so, then the InputStream is
empty in both your problem scenarios.


> StringBuffer sb = new StringBuffer();
> while (true) {
> int i = in.read();
> if (i < 0)
> break;
> sb.append((char) i);
> }

It may have nothing to do with the problem, but taking each byte as a char
is a latent bug. You should translate bytes to chars using a decoder.
Especially since the default text-encoding on Mac OS X is "MacRoman", which
is definitely not a direct mapping of bytes to Unicode chars.

I realize this may just be test code, but you didn't say, so I thought it
was safer to point it out.


>When this applet is run using the Java 1.4.1 plug-in on my Windows XP
>box (IE 6), it works -- the read logic gets the same string that I see
>when I run the servlet manually.
>
>When I run the applet using Safari which uses the Mac OS X 1.4.1
>plug-in, on the same box as the server is running on, I never get any
>bytes from the while loop. The StringBuffer is empty. The debug print
>statement shows a valid response is returned: HTTP/1.1 200 OK

Can you set it up so the XP box runs the server and the Mac OS X client
(applet) connects to it?

I'm wondering if there's something "special" about having client and server
running on the same Mac OS X box.

Can you run the applet using a browser other than Safari, say MSIE or iCab?
MSIE in particular always runs the 1.3 JVM, which might offer a clue.

Do you have firewall software running on Mac OS X?

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.