日期:2014-05-17  浏览次数:20876 次

怎么在jsp页面中显示
public class Main {

  public static void main(String[] args) throws Exception {
  // Create and initialize HTTP parameters
 
  HttpParams params = new BasicHttpParams();
  ConnManagerParams.setMaxTotalConnections(params, 100);
  HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);

   
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(
  new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));

   
  ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
  HttpClient httpClient = new DefaultHttpClient(cm, params);

  // create an array of URIs to perform GETs on
  String[] urisToGet = {
"http://www.baidu.com", 
  "http://www.sohu.com"  
  };

  // create a thread for each URI
  GetThread[] threads = new GetThread[urisToGet.length];
   
  try{
 
for (int i = 0; i < threads.length; i++) {
HttpGet httpget = new HttpGet(urisToGet[i]);
threads[i] = new GetThread(httpClient, httpget, i + 1);
 
 
}

// start the threads
for (int j = 0; j < threads.length; j++) {
threads[j].start();
}

// join the threads
for (int j = 0; j < threads.length; j++) {
threads[j].join();
}
  }finally {
  httpClient.getConnectionManager().shutdown();  
  }  
  }

  /**
  * A thread that performs a GET.
  */
  public static class GetThread extends Thread {

  private final HttpClient httpClient;
  private final HttpContext context;
  private final HttpGet httpget;
  private final int id;

  public GetThread(HttpClient httpClient, HttpGet httpget, int id) {
  this.httpClient = httpClient;
  this.context = new BasicHttpContext();
  this.httpget = httpget;
  this.id = id;
  }

  /**
  * Executes the GetMethod and prints some status information.
  */
  @Override
  public void run() {

  System.out.println(id + " - about to get something from " + httpget.getURI());

  try {
   
  HttpResponse response = httpClient.execute(httpget, context);  
   
  System.out.println(id + ":" +response.getStatusLine());  
   
  } catch (Exception e) {
  httpget.abort();
  System.out.println(id + " - error: " + e);
  }
  }
  }
}

怎么输出到页面上!!谢谢各位了!




------解决方案--------------------
想调用类里面的什么东西呢,如果是属性或者方法的话,你在jsp页面上面导入
Java code
<%@ page import="类的路径" %>
然后在jsp页面里面用小脚本写代码
<%
//例子如userInfo存在作用域中
<%out.print(userInfo.getName)%>