Java Applet,关于用户数据

发布于 2024-09-04 19:40:15 字数 85 浏览 4 评论 0原文

一般来说,java小程序如何操作用户数据?以购物网站上的“购物车”为例,用户输入数据后,是否会在用户每次访问网站时预加载数据?或者当用户在页面上时检索数据?

Generally, how does a java applet manipulate user data? Take for instance "shopping carts" on shopping websites - after a user enters the data, is the data then preloaded each time a user accesses a website? Or is the data retrieved as the user is on the page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌面超妹 2024-09-11 19:40:16

我从来没有见过一个小程序可以做购物车之类的事情,这将是一种低效且用户不友好的方法。所以一定有什么地方存在巨大的误解。另外,Java确实不应该与JavaScript

此类信息通常存储在会话中的服务器端内存中。在 PHP 中,它存储在 $_SESSION 中,并存储在 HttpSession 中的 JSP/Servlet 中。该会话又由服务器管理的 cookie 支持,只要用户在同一浏览器实例中的网页上处于活动状态,该 cookie 就会存在。有些网站甚至将其与登录名和数据库结合起来,以便可以根据当前登录的用户在数据库中存储/检索信息,而该用户又存储在会话中。

简而言之:服务器端代码(PHP、Java/JSP/Servlet、C#/.NET/ASP 等)仅存储信息本身并在页面中显示信息。

I've never seen an applet which does shopping cart like stuff, it would have been an inefficient and userunfriendly approach. So there must somewhere be a huge misconception. Also, Java should really not be confused with JavaScript.

Such information is usually stored in the server side memory in the session. In PHP, it's stored in $_SESSION and in JSP/Servlet in HttpSession. The session is in turn backed by a server-managed cookie which lives as long as the user is active on the webpage within the same browser instance. Some websites even couples this to a login and a database so that the information can be stored/retrieved in/from the database depending on the currently logged in user which in turn is stored in the session.

In a nut: the server side code (PHP, Java/JSP/Servlet, C#/.NET/ASP, etc) just stores the information itself and displays the information in the page.

烟燃烟灭 2024-09-11 19:40:16

问题不清楚,因为您可以通过多种方式在网站中存储数据。

通常购物车不是 Java Applet,而是由网络服务器动态创建的页面。在这种情况下,大部分信息直接存储到服务器中,与正常的http请求一起发送和接收。

当谈论Java Applet时,您必须记住它是嵌入到网页中的应用程序,拥有自己的虚拟机。因此它将数据存储在内存中,并且可以在加载期间从网页接收参数,动态地从 javascript 接收参数并使用周围打开的真实 TCP 套接字(对于 http 或更底层的东西)。

Question is not clear since you can have many ways to store data in a website.

Usually shopping carts are not Java Applets but just pages that have been dynamically created by the webserver. In this case most of the information is stored directly into the server, sent and received together with normal http requests.

When talking about Java Applets you have to remember that it is a application embedded into a webpage that has its own virtual machine. So it stores the data inside the memory and it can receive parameters from the webpage during loading, from javascript dynamically and using real TCP sockets opened around (for http or more low level things).

遥远的她 2024-09-11 19:40:16

通常,购物车信息是由 JavaScript 处理的,而不是 Java Applet(至少从我所见)。但我认为小程序可以做一些有趣的事情。 Java Applet 的 VM 仅当标签在浏览器中存在时才存在,因此当页面加载时,Applet 必须从服务器收集数据,然后对其执行任何操作。如果用户离开,则必须重新开始。

一种替代方法是使用框架集,以便在用户在单独的框架中导航时保持小程序处于活动状态。由于没有一种很好的方式与小程序 AFAIK 进行通信,因此它必须定期“ping”服务器以检查购物车的更新。不过,这个请求可以做得相当轻量——也许小程序会向服务器发送一个会话 ID,而服务器会响应该会话的购物车上次更改的时间。然后小程序可以仅在需要时重新请求更新的购物车内容。

More often than not, the shopping cart information is handled by JavaScript, rather than a Java Applet (at least from what I've seen around). But an applet could do interesting things, I think. The Java Applet's VM only exists as long as the tag is alive in the browser, so the applet would have to collect its data from the server when the page is loaded, then do whatever it does with it. If the user navigates away, it'll have to start over.

One alternative would be to use framesets in order to keep the applet active while the user navigates about in a separate frame. Since there's not a great way to communicate with the applet AFAIK, it would have to "ping" the server periodically to check for updates to the shopping cart. This request could be made pretty lightweight, though - perhaps the applet sends a session ID to the server, and the server responds with the last time that session's shopping cart changed. Then the applet can re-request the updated shopping cart contents only when needed.

戒ㄋ 2024-09-11 19:40:16

一般来说,小程序被禁止存储任何客户端数据。

因此,所有数据都不可避免地存储在服务器端。其余的取决于如何为此类小程序组织客户端-服务器交互,您列出的两种方法都是可行的。

In general, applets are forbidden from storing any data client-site.

So, all data would inevitably be stored server-side. The rest depends on how the client-server interaction is organized for such applet, both approaches you've listed are doable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文