|
Prev: quartz job stopping
Next: IBM's JVM?
From: Stefan Palme on 14 Jul 2008 18:42 Hi all, hope this is the right place to ask for help - some hours of search engine stressing did not bring any light... I have a rather complex 3rd party web application using Cookies for authenticating purposes. Every HTTP request from the user's browser sends an HTTP request header like "Cookie: session=1234567" to the server. One of the application's HTML pages contains an <applet>-Tag causing the users browser to load an applet. The applet lives in the same codebase as the web application, i.e. something like this: <applet code="my.package.Main" archive="applet.jar"> ... (some applet params) </applet> The "Cookie" header used for authentication is of course also set in the HTTP request used to load applet.jar to the client. Is there a way to access the Cookie-Header (or any other HTTP request header) of the HTTP request that was used to load the applet's jar file? I.e. in the applet code I want to do something like this: public class Main extends JApplet { public void init() { System.out.println("Cookie: "+WHATEVER.getRequestParam("Cookie")); System.out.println("User-Agent: "+WHATEVER.getRequestParam("User- Agent")); ... } } Is there a really existing way for "WHATEVER.getRequestParam()"? Thanks for any help -stefan-
From: Arne Vajhøj on 14 Jul 2008 20:11 Stefan Palme wrote: > hope this is the right place to ask for help - some hours of > search engine stressing did not bring any light... > > I have a rather complex 3rd party web application using Cookies > for authenticating purposes. Every HTTP request from the user's > browser sends an HTTP request header like "Cookie: session=1234567" > to the server. > > One of the application's HTML pages contains an <applet>-Tag causing > the users browser to load an applet. The applet lives in the same > codebase as the web application, i.e. something like this: > > <applet code="my.package.Main" archive="applet.jar"> > ... (some applet params) > </applet> > > The "Cookie" header used for authentication is of course also > set in the HTTP request used to load applet.jar to the client. > > Is there a way to access the Cookie-Header (or any other HTTP > request header) of the HTTP request that was used to load the > applet's jar file? > > I.e. in the applet code I want to do something like this: > > public class Main extends JApplet { > public void init() { > System.out.println("Cookie: "+WHATEVER.getRequestParam("Cookie")); > System.out.println("User-Agent: "+WHATEVER.getRequestParam("User- > Agent")); > ... > } > } > > Is there a really existing way for "WHATEVER.getRequestParam()"? The applet code runs client side and has no access to the information present server side when the code was previously retrieved. But the applet can access the cookie information stored in the browser about the HTML document via the Java applet - JavaScript interface. See: http://www.rgagnon.com/javadetails/java-0180.html for examples. Arne
From: Richard Maher on 14 Jul 2008 20:54 Hi Arne, > See: > http://www.rgagnon.com/javadetails/java-0180.html > for examples. Great site! If only there was some JSException processing there somewhere then I too would be happy :-( Cheers Richard Maher "Arne Vajh�j" <arne(a)vajhoej.dk> wrote in message news:487beb43$0$90271$14726298(a)news.sunsite.dk... > Stefan Palme wrote: > > hope this is the right place to ask for help - some hours of > > search engine stressing did not bring any light... > > > > I have a rather complex 3rd party web application using Cookies > > for authenticating purposes. Every HTTP request from the user's > > browser sends an HTTP request header like "Cookie: session=1234567" > > to the server. > > > > One of the application's HTML pages contains an <applet>-Tag causing > > the users browser to load an applet. The applet lives in the same > > codebase as the web application, i.e. something like this: > > > > <applet code="my.package.Main" archive="applet.jar"> > > ... (some applet params) > > </applet> > > > > The "Cookie" header used for authentication is of course also > > set in the HTTP request used to load applet.jar to the client. > > > > Is there a way to access the Cookie-Header (or any other HTTP > > request header) of the HTTP request that was used to load the > > applet's jar file? > > > > I.e. in the applet code I want to do something like this: > > > > public class Main extends JApplet { > > public void init() { > > System.out.println("Cookie: "+WHATEVER.getRequestParam("Cookie")); > > System.out.println("User-Agent: "+WHATEVER.getRequestParam("User- > > Agent")); > > ... > > } > > } > > > > Is there a really existing way for "WHATEVER.getRequestParam()"? > > The applet code runs client side and has no access to the > information present server side when the code was > previously retrieved. > > But the applet can access the cookie information stored > in the browser about the HTML document via the > Java applet - JavaScript interface. > > See: > http://www.rgagnon.com/javadetails/java-0180.html > for examples. > > Arne
From: Jean-Baptiste Nizet on 15 Jul 2008 03:43 On 15 juil, 00:42, Stefan Palme <pa...(a)kapott.org> wrote: > > One of the application's HTML pages contains an <applet>-Tag causing > the users browser to load an applet. The applet lives in the same > codebase as the web application, i.e. something like this: > > <applet code="my.package.Main" archive="applet.jar"> > ... (some applet params) > </applet> > If this HTML page is dynamically generated, you can retrieve the cookie information when generating the HTML page, and pass it to the applet as an additional applet parameter. JB.
From: Stefan Palme on 16 Jul 2008 02:55
Hi, On Tue, 15 Jul 2008 00:43:59 -0700, Jean-Baptiste Nizet wrote: > If this HTML page is dynamically generated, you can retrieve the cookie > information when generating the HTML page, and pass it to the applet as > an additional applet parameter. This is the current workaround - but I was looking for a more "natural" way to access the cookies. Thanks to Arne for the hint regarding JSObject. Will take a look at this, but I guess this will not be an option because of the dependency to a third party package... Best regards -stefan- |