<%@page import="java.util.*,java.io.*,java.net.*"%> <%@page import="java.net.URLEncoder"%> <%@ page language="java" contentType="text/html; charset=UTF-8" %><% String agentId=request.getParameter("agentId"); String registeredAgentId=request.getParameter("registeredAgentId"); String registeredOperatorId=request.getParameter("registeredOperterId"); agentId = agentId!=null?URLEncoder.encode(agentId, "utf-8"):""; registeredAgentId = registeredAgentId!=null?URLEncoder.encode(registeredAgentId, "utf-8"):""; registeredOperatorId = registeredOperatorId!=null?URLEncoder.encode(registeredOperatorId, "utf-8"):""; %> Live800在线注册—Live800官方网站-卓越的在线客服系统
<%! private static String httpGetAllocateUrl(String urlString) { Socket sock = null; Object inStream; URLConnection urlConnection; try { URL url = new URL(urlString); if(url.getPort() == -1){ sock = new Socket(url.getHost(), 80); }else{ sock = new Socket(url.getHost(), url.getPort()); } sock.setSoTimeout(60*1000); DataOutputStream outStream = new DataOutputStream(new BufferedOutputStream( sock. getOutputStream())); outStream.write(("GET "+url.getFile()+" HTTP/1.0\r\n").getBytes()); outStream.write("Referer: http://www.live800.com/download/signup.jsp\r\n".getBytes()); outStream.write("Accept-Language: zh-cn,en;q=0.8,zh-tw;q=0.5,ja;q=0.3\r\n".getBytes()); outStream.write("Content-Type: application/x-www-form-urlencoded\r\n".getBytes()); outStream.write("User-Agent: live800signup\r\n".getBytes()); outStream.write(("Host: "+url.getHost()+"\r\n").getBytes()); outStream.write("Cache-Control: no-cache\r\n".getBytes()); outStream.write("\r\n".getBytes()); outStream.flush(); String tempResult = null; BufferedReader reader = new BufferedReader(new InputStreamReader( sock.getInputStream(), "utf-8")); StringBuffer sb = new StringBuffer(""); String line = null; boolean isStatus_200 = false; boolean isBody = false; line = reader.readLine(); if(line !=null && line.indexOf("200 OK") > 0){ while ((line = reader.readLine()) != null) { if("".equals(line)){ isBody = true; continue; } if(isBody&&line.indexOf("allocateUrl")>0){ sb.append(line+"\r\n"); break; } } } reader.close(); if (sb.length() > 0) { tempResult = sb.toString(); } outStream.close(); sock.close(); sock = null; return tempResult; } catch (Exception ex) { ex.printStackTrace(); }finally{ if(sock != null){ try { sock.close(); }catch (Exception ex) { ;//do nothing } } } return null; } %>