请求 j_security_check 仅使用正确的参数返回 408 错误 [英] Request to j_security_check return 408 error only with right paramters

查看:76
本文介绍了请求 j_security_check 仅使用正确的参数返回 408 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 servlet 向 j_security_check 发送请求并从响应中获取 auth cookie.代码:

I want to send request to j_security_check from servlet and get auth cookie from response. Code:

String url = "http://someserver:8080/j_security_check?j_username=user&j_password=qwerty";
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();

如果我输入了错误的身份验证参数,那么在响应时我会得到一个默认的错误登录页面,但是如果我输入正确的身份验证参数,我会得到服务器代码 408.这是怎么回事?

If I put wrong auth parameters then on response I get a default wrong-login page, but if I put right auth parameters I got server code 408. What's wrong?

推荐答案

要使用 j_security_check auth 在 tomcat 服务器上获取一些资源,需要实现三个步骤:

To get some resource on the tomcat server with j_security_check auth it is necessary to implement three steps:

  1. 向所需的私有资源发送 GET 请求,作为响应,您将获得一个 cookie(标题设置 cookie".
  2. 将带有 cookie 的请求(来自第 1 步)发送到 j_security_check.在响应时,您应该得到代码 302 -暂时移动".
  3. 现在您可以使用相同的 cookie 对私有资源重复请求,根据响应您获得所需的资源数据.

这篇关于请求 j_security_check 仅使用正确的参数返回 408 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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