Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

HttpURLConnection without waiting

Thread view: 
ennio - 18 Sep 2006 18:27 GMT
Hi everybody.
I need to connect to a servlet, because i want to send an http request
with some parameters.

This is the code:
URL url = new URL("http://blahblahblah.com.../servlet?var1=value");
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.getInputStream();

The point is that connection.getInputStream() waits for the for the
whole processed response of the servlet. But i don't want to wait,
because the server-side is a long process and i don't mind about the
output. I just want to send the request.
How can i accomplish that? If i write a raw-socket request, will the
server (tomcat) kill the servlet thread if i close the socket? Do i
really need to write a raw-socket request?
thanks
su_dang@hotmail.com - 18 Sep 2006 19:18 GMT
> Hi everybody.
> I need to connect to a servlet, because i want to send an http request
[quoted text clipped - 14 lines]
> really need to write a raw-socket request?
> thanks

On the top of my mind, if you don't care about the output, you can
create a thread and do it from there.  Your main thread will not be
blocked.
ennio - 18 Sep 2006 21:06 GMT
Thank you very much. I was thinking about it too. I was wondering if
it's "okay" to launch threads from a servlet.

su_dang@hotmail.com ha scritto:

> On the top of my mind, if you don't care about the output, you can
> create a thread and do it from there.  Your main thread will not be
> blocked.
Andrea Desole - 19 Sep 2006 09:01 GMT
> Thank you very much. I was thinking about it too. I was wondering if
> it's "okay" to launch threads from a servlet.

yes. Just make sure the thread terminates, or you will have a lot of
threads after some time. Maybe a better solution would be to use one
thread that queues the jobs coming from the servlets called by the users


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.