File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Sockets and Internet Protocols
how to wait my class for the servlet response
Joined: May 07, 2007
Jul 10, 2007 09:37:00
I need to make a class which will send a request to
thru the URL connection but I want to wait my class for the servlet response what all are the possible way to do this pleas help me out
Thanks <br />Shanmugam N
Amit M Tank
Joined: Mar 28, 2004
Jul 10, 2007 14:41:00
Write something like this
URL url = new URL(urlString); HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection(); urlconnection.setDoOutput(true); urlconnection.setRequestMethod("POST"); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(urlconnection.getOutputStream())); FileInputStream fileinputstream = new FileInputStream(inputFile); for(int i = 0; (i = fileinputstream.read()) != -1 :wink: writer.write(i); writer.flush(); writer.close(); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(urlconnection.getInputStream())); String response; while((response = bufferedreader.readLine())!= null) System.out.println(response); }
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: how to wait my class for the servlet response
repetedly calling a servlet from another servlet
Issue with large request data using AJAX
server side request for pop up in JSP.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014