• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet-Servlet Communication

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Stephan Bardubitzki
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 am Arthur, King of the Britons. And this is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic