<%@ page language = "java"%> <%@ page import = "java.util.*"%> <%@ page import = "java.io.*"%> <%@ page import="java.lang.*"%> <%@ page import="java.net.*"%> <%@ page import="java.nio.*"%> <%@ page import= "javax.xml.parsers.*" %> <%@ page import= "org.w3c.dom.*" %> <% System.out.println("ImportGet3.jsp"); javax.servlet.http.HttpSession hs = request.getSession(); try { String URLString = "http://string-db.org/api/tsv/resolve?identifier=ADD&species=9606"; Properties systemSettings = System.getProperties(); systemSettings.put("http.proxyHost", "proxy.it.iitb.ac.in"); systemSettings.put("http.proxyPort", "80"); systemSettings.put("sun.net.client.defaultConnectTimeout", "10000"); systemSettings.put("sun.net.client.defaultReadTimeout", "10000"); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("aaqua", "aaqua123".toCharArray() ); // specify ur user name password of iitb login } }); System.setProperties(systemSettings); System.out.println(" System Properties Set"); System.out.println(" URL variables set=" + URLString); URL url = new URL(URLString); //url string taken from user input. HttpURLConnection connection = null; connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setDoInput(true); connection.setDoOutput(true); //connection.setUseCaches(false); //connection.setAllowUserInteraction(false); //connection.setRequestProperty ("Content-Type","text"); System.out.println(" connection Set"); OutputStreamWriter dosout = new OutputStreamWriter(connection.getOutputStream()); BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream())); String decodedString; String tempstr = ""; while ((decodedString = in.readLine()) != null) { tempstr = tempstr + decodedString; out.println(tempstr); } System.out.println("Reader Set"); Random rn = new Random(); int rnval = rn.nextInt() ; String fname = "file_importget_"+ String.valueOf(rnval) + ".txt" ; BufferedWriter bw = new BufferedWriter(new FileWriter(fname)); while ((decodedString = in.readLine()) != null) { tempstr = tempstr + decodedString; //out.println(tempstr); bw.write(decodedString); if ( tempstr.indexOf("/") == -1 ) { bw.newLine(); } } System.out.println(" output given.Set"); bw.close(); in.close(); } catch(Exception ex) { out.println("Exception->"+ex); PrintWriter pw = response.getWriter(); ex.printStackTrace(pw); } %>