wood burning stoves 2.0*
The moose likes Servlets and the fly likes Error in invoking a servlet from an applet (loaded in a browser) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Error in invoking a servlet from an applet (loaded in a browser)" Watch "Error in invoking a servlet from an applet (loaded in a browser)" New topic
Author

Error in invoking a servlet from an applet (loaded in a browser)

RoshanDawrani
Greenhorn

Joined: Jan 21, 2001
Posts: 16
Hi,
I am using an applet which invokes a servlet on the same machine for some processing. If I use AppletViewer to see this applet, the code works fine but if I use a browser (I am using IE5), I get the following error.
The applet is passing some data to the servelt and getting the result back from it using input and output streams. Could someone please tell me how do I give authority to the applet to do that.
I am using Java(tm) Servlet Development Kit Version 2.1(server) with JDK 1.2.2 on WinNT 4.
Thanks and Regards,
Roshan

com.ms.security.SecurityExceptionEx[BaseTunnelClient._invokeMethod]: cannot access "localhost":8080
at com/ms/security/permissions/NetIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.chkex
at com/ms/security/StandardSecurityManager.checkConnect
at com/ms/net/wininet/WininetURLConnection.connect
at com/ms/net/wininet/http/HttpURLConnection.getOutputStream
at BaseTunnelClient._invokeMethod
at BaseTunnelClient._initialize
at RemoteMathLiteClient.<init>
at MathLiteApplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"RoshanDawrani",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
RoshanDawrani
Greenhorn

Joined: Jan 21, 2001
Posts: 16
How do I modify my username to abide by the policies? I went to modify my profile but could not do it there?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You have to create a new ID.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
IE is a pain with security. Are you sure that the applet is coming from the same domain as the servlet?
Roshan Dawrani
Greenhorn

Joined: Feb 02, 2001
Posts: 3
Hi Paul,
yes both the applets and the servlets are coming from the same domain. I am trying something on my machine only. No other machine is involved in it right now.
Yesterday somebody told me that I should use a java plug-in to load such an applet which is passing and receiving data to the servlet. So I installed a java plug-in (version 1.2) and now I am using OBJECT tag to load the applet so that java plug-in gets loaded first to help the applet. Now I am getting this error - "protocol doesn't support output". Do you have any idea about this error message?
What else do I need to do to run this simple example?
I am JUST STUCK at this point.
I am going to try things again... hope to solve it soon. see if u can help...thanks a lot...
rgds,
Roshan
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Many thanks for choosing a new name. We do appreciate it.
Roshan Dawrani
Greenhorn

Joined: Feb 02, 2001
Posts: 3
Hi,
My problem is solved now. The java plug-in that was suggested to me yesterday by somebody helped. But even after that I was getting an error message, which I mentioned my earlier post. The reason I was getting that error message(Protocol does not support output) was that to open a connection to the servlet, I was using openConnection() method of URL. and the url that I was passing to it was being formed as getCodeBase() + "servlet/" + "MyServlet". I was expecting the final URL to be something like "http://localhost:8080/servlet/MyServlet" but because of the result of getCodeBase(), it was becoming something like "file:/C:/Examples/servlet/MyServlet" which was wrong and because of this wrong path, I was not able to open output stream.
getCodeBase() I was using because that's how it was given in the book. Anyway, the problem got solved when I formed the URL as "http://localhost:8080/servlet" + "MyServlet" and now everything is working.
Thanks a lot.
regards,
Roshan
 
wood burning stoves
 
subject: Error in invoking a servlet from an applet (loaded in a browser)