[英]Is there a way to read the browser's cookie from a java applet?
I have a java applet that needs to do http requests to the server. 我有一个Java小程序,需要对服务器执行http请求。 A quick experiment showed that the session id cookies from the browser is not sent along, so i'll have to set it manually.
一个快速实验表明,浏览器的会话ID cookie不会一起发送,因此我必须手动设置它。 Currently, I see 2 possible solutions:
目前,我看到2种可能的解决方案:
I'd prefer the first solution, but i wasn't able to find a working solution for that. 我希望使用第一个解决方案,但无法为此找到有效的解决方案。 all information i found (mostly netscape.javascript.JSObject) were outdated (my 1.5 VM does not have this class)
我发现的所有信息(主要是netscape.javascript.JSObject)都已过时(我的1.5 VM没有此类)
Any great ideas or resources i have not yet found? 我还没有发现任何很棒的主意或资源?
Are you sure your JVM doesn't contain this class? 您确定您的JVM不包含此类吗? You should look in
$JAVA_HOME/lib/plugin.jar
. 您应该查看
$JAVA_HOME/lib/plugin.jar
。 I found it in my 1.5.0_14 installation. 我在1.5.0_14安装中找到它。
If you are generating the page dynamically, you don't necessarily need to use JavaScript to communicate the session ID. 如果要动态生成页面,则不必使用JavaScript来传递会话ID。 As long as you know it server-side, you can place it into an applet parameter tag in the generated HTML which contains the
<applet>
tag. 只要您知道它在服务器端,就可以将其放置在生成的包含
<applet>
标记的HTML中的applet参数标记中。
如今,所有浏览器都支持httponly cookie。如果在相应的响应标头中有意识地在服务器中将cookie设置为“ httponly”,则小应用程序可能无法访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.