在 response.sendRedirect 中隐藏来自 url 的查询字符串参数 [英] Hide querystring parameters from url in response.sendRedirect

查看:121
本文介绍了在 response.sendRedirect 中隐藏来自 url 的查询字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 java servlet,它重定向到不同服务器上的 web 应用程序.

I have a java servlet that is redirecting to a web application on a different server.

我想知道是否有办法隐藏查询字符串参数,以便客户端在地址栏中看不到它们.

I was wondering if there is a way to hide the querystring parameters, so they are not visible to the client in the address bar.

response.sendRedirect("http://www.mywebapp.com/login.html?parameter1=value1&parameter2=value2");

有没有办法强制 sendRedirect POST 到页面并隐藏查询字符串?

Is there a way to force the sendRedirect to POST to the page and hide the querystring?

用例.

  • 用户访问 http://www.mywebapp.com
  • 它们会自动重定向到我的 servlet 过滤器
  • servlet 使用 SAML 处理与身份提供商的 SSO
  • 收到 SAML 响应后,我会将现在经过身份验证的用户重定向回 mywebapp.com
  • 我想将一些参数传递回 web 应用程序.来自 SAML 响应的参数.但我不希望用户在 URL 中看到它们

显然,sendRedirect() 不是我想要的.处理这个问题的最佳方法是什么?

Clearly, sendRedirect() is not what I want. What would be the best way to handle this?

推荐答案

您可以从您的 servlet (HttpConnection) 连接到其他服务器并复制返回的数据.用户只会看到您的服务器.

You could connect to the other server from your servlet (HttpConnection) and copy the returned data. The user will only see your server.

另一种方法是返回一个 HTML 页面,该页面在加载后会自动发送 POST 表单.用户需要允许 JS.

An alternative is returning an HTML page that does send a POST form automatically after loading. The user will need to allow JS.

这篇关于在 response.sendRedirect 中隐藏来自 url 的查询字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆