[英]Tomcat manager connection through HttpClient
Does anyone know what I might be doing wrong here? 有人知道我在这里做错什么吗? I added the username and password to the tomcat-user.xml but I am still getting a "401 Unauthorized" error.
我将用户名和密码添加到了tomcat-user.xml中,但仍然出现“ 401未经授权”错误。
String url = "http://localhost:9080/manager/list";
HttpPost httppost = new HttpPost(url);
httppost.setHeader("Authorization", "Basic " + userPass);
log.debug("executing request {}", httppost.getRequestLine());
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
BufferedReader rd = new BufferedReader(new InputStreamReader(entity.getContent()));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = rd.readLine()) != null) {
buffer.append(line);
buffer.append('\n');
}
rd.close();
The answer depends on whether you're using Tomcat 5.5/6 or Tomcat 7. 答案取决于您使用的是Tomcat 5.5 / 6还是Tomcat 7。
You'll need to access the the listing with the following URL: 您需要使用以下URL访问列表:
http://localhost:9080/manager/text/list
You'll need to configure tomcat-user.xml with a user that has the manager-script
role. 您需要使用具有
manager-script
角色的用户配置tomcat-user.xml。
You'll need to access the the listing with the following URL: 您需要使用以下URL访问列表:
http://localhost:9080/manager/list
You'll need to configure tomcat-user.xml with a user that has the manager
role. 您需要使用具有
manager
角色的用户来配置tomcat-user.xml。
You may not be performing the Basic Auth step correctly. 您可能未正确执行“基本身份验证”步骤。 The username/pass might need to be base64 encoded.
用户名/密码可能需要使用base64编码。 See the highest voted answer in this question: Http Basic Authentication in Java using HttpClient?
请参阅此问题中投票最高的答案: Java中使用HttpClient的Http基本身份验证?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.