Error in invoking a servlet from an applet (loaded in a browser)
RoshanDawrani
Greenhorn
Joined: Jan 21, 2001
Posts: 16
posted
0
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: 6913
posted
0
"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.
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
posted
0
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: 6913
posted
0
Many thanks for choosing a new name. We do appreciate it.
Roshan Dawrani
Greenhorn
Joined: Feb 02, 2001
Posts: 3
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Error in invoking a servlet from an applet (loaded in a browser)