tomcat笔记

重启Tomcat应用:

  public String reloadApp(){
		String url="http://localhost:1081/manager/reload?path=/app";
		return remoteLogin(url,"admin", "admin");
	}
	
	public String remoteLogin(String url,String username,String password){
		HttpClient client = new HttpClient( );
		HttpMethod method = new GetMethod( url );
		Credentials credentials =  new UsernamePasswordCredentials( username,password );
		client.getState().setCredentials( null, null, credentials );
		try {
			client.executeMethod( method );
			String response = method.getResponseBodyAsString( );
			method.releaseConnection( );
			return response;
		} catch (HttpException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "请示失败";
	}


未完,待续…………

你可能感兴趣的:(重启tomcat服务,java操作tomcat,重启tomcat应用)