`

利用服务器端方法调用访问链接返回结果的一个方法

    博客分类:
  • java
JSP 
阅读更多

调用服务器端方法时,根据服务器端方法访问另一个链接后返回的结果进行判断的方法
public String doCheckAuthor(){
  Map params = getStrictParams();
  if (params.get("传递的参数") != null) {
   this.setMessage(params.get("传递的参数").toString().trim());
  }
  try {
   String checkUrl = "
http://地址:xxx.jsp?传递的参数="
     + params.get("传递的参数").toString().trim();
   URL url = new URL(checkUrl);
   HttpURLConnection urlConnection = (HttpURLConnection) url
     .openConnection();
   BufferedReader in = new BufferedReader(new InputStreamReader(
     urlConnection.getInputStream()));
   //System.out.println(in.readLine().toString());
   if(in.readLine().toString().equals("1")){
    this.setMessage("1");
   }
  } catch (Exception e) {
   //e.printStackTrace();
   this.getLog().debug(ExceptionUtils.getExceptionTraceString(e));
  }
  return "checkAutor";
 }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics