aspose file tools*
The moose likes Servlets and the fly likes Applet-Servlet Communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet-Servlet Communication" Watch "Applet-Servlet Communication" New topic
Author

Applet-Servlet Communication

Stephan Bardubitzki
Greenhorn

Joined: Dec 26, 2005
Posts: 29
Hi all,

I'm using an applet as front-end and servlets as back-end, which works just fine except the JVM warm up time.

Today, I tried to use a servlet to redirect to a page I can't connect from an applet due to the security manager. I can successfully connect and write data to the output stream, but the servlet doesn't appear to be executed.

This is the code snippet from the applet:


and this from the servlet:


Neither in the trace nor in the containers log files are any exceptions thrown.

I would much appreciate any help.

Thanks.
Stephan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42583
    
  65
Not sure what the servlet problem is, but this can't work because of the security restrictions - you're trying to have the applets HTTP request redirected to some other host.

But I don't understand the logic in general: if the applet already knows which page it should replace itself with, why doesn't it just call getAppletContext().showDocument to go to that page?


Ping & DNS - my free Android networking tools app
Stephan Bardubitzki
Greenhorn

Joined: Dec 26, 2005
Posts: 29
Ulf, there are a number of issues. Firstly, my applet used the browser window as its frame. There is nothing else than the applet, that means I don't want to load the new page in the applet window. Secondly, the applet is not signed. There is actually nothing I need from the client machine what the security manager not allows. Doing as you suggest with
will cause Firefox 1.5x and IE to block the new window.
I hoped by using a servlet to get around this, but I know that I also have to find a way to trigger the client to open the redirected page in a new window.

Stephan
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

The redirect command from the Servlet never reaches the browser, does it? I mean, the http protocol is used, all right, but the redirect command gets written to the applet's in stream, which the browser has got nothing to do with except. The browser and the http protocol providing a conduit for the applet to read/write data, but doesnt interpret the data as it would in case of a request sent from it.

One approch would be to have the servlet open another HttpURLConnection and communicate with the redirected resource rather than actually redirecting the entire request.

ram.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet-Servlet Communication