如何从 Android 应用程序与 Web 应用程序交互?

发布于 2024-12-07 09:35:09 字数 428 浏览 0 评论 0原文

我有一个基于 Java 的 Web 应用程序,它是使用在 Tomcat 服务器上运行的 JSP/Servlet 开发的。该应用程序是为客户支持而开发的。客户可以使用其凭据直接登录该应用程序并提出任何投诉。特定产品。他还可以查看他提出的所有投诉及其状态。他还可以在投诉中添加评论,也可以在需要时关闭投诉。

现在我想开发一个 Android 应用程序,客户可以使用他的凭据登录并执行与他在上述 Web 应用程序中所做的相同的操作。

我有 Android 的基础知识和大量的 Java 知识。有人可以帮助我提供一些指南或示例源代码来开发此类应用程序。特别是在通过向 Web 应用程序发送 HTTP 请求来使用 Android 活动的凭据对客户进行身份验证后,我们如何跟踪该客户的会话,以便向他显示他提出的投诉或允许他添加评论他在接下来的活动(屏幕)中的抱怨。简单来说如何维持session呢?

谢谢,

I have a Java based web application which is developed using JSP/Servlets running on Tomcat server. This application is developed for customer support. A customer can directly login to the application with his credentials and raise any complaints reg. a specific product. He can also view all the complaints he has raised and their status. Also he can add comments to the complaints and also close them when he desires to.

Now I would like to develop an Android app where a customer can login with his credentials and do same operations as he used to do in the above said web application.

I have basic knowledge on Android and good amount of knowledge in Java. Can someone help me with some guidelines or sample source code to develop such kind of application. In particular after authenticating a customer with his credentials from an Android activity by sending HTTP request to the web application, how do we keep track of the session for that customer in order to display him the complaints raised by him or allowing him to add comments to his complaints in next activities (screens). To put it simple how to maintain sessions?

Thanks,

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

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

发布评论

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

评论(1

执妄 2024-12-14 09:35:09

您的问题非常针对您的应用程序。如何维护与服务器的会话很大程度上取决于您,但您可以将其视为实现 Web 浏览器和 Web 服务器之间的关系。

用户登录后,客户端应该从服务器接收某种令牌(类似于 cookie)。所有后续请求都将传递该令牌来授权用户,因此您必须将其保留在设备上。您的服务器将具有令牌到用户的映射。

我建议您研究一下 OAUTH2,也许还可以看看一些常用的 API,例如 TwitterFoursquare 了解有关最佳实践的一些想法。

You question is pretty specific to your application. How you maintain a session with the server is pretty much up to you, but you can think of it as implementing the relationship between a web browser and a web server.

After your user logs in, the client should receive some kind of token from the server (similar to a cookie). All subsequent requests will pass along that token to authorize the user, so you'll have to persist it on the device. Your server will have a mapping of tokens to users.

I would recommend looking into OAUTH2 and maybe taking a look at some well used APIs like Twitter and Foursquare for some ideas about best practices.

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