Repeated requests on same HttpURLConnection

Is it possible to use the same HttpURLConnection to send similar repeated requests (parameters differing slightly based on the result of the previous request)? I end up getting a java.net.ProtocolException, so it seems like it's not possible.
If not, I understand that HTTP is inherently one-for-one in terms of requests and responses, but I would think the same connection could still be used. Any explanations out there concerning this?
The code I have works when I reestablish the connection every time, but I'd obviously like to not have to do it that way.
Thanks,
Ken

The reason you can't do this is because TCP (the upper half of TCP/IP, HTTP's transport protocol) is by definition a stateless protocol and therefore prohibits it. "Stateless" means that the connection only lives as long as necessary to transmit the request, process it, and return the response. That's why cookies are necessary to maintain user sessions in web applications.
To understand why this is necessary for the health of the Internet, imagine if every request to a web server left the connection open - the web server would soon get completely bogged down by open connections and crash! There is no way to guarantee that every client is going to close the connection, so it is better to enforce it at the protocol level.

Similar Messages

  • Multiple HTTP requests through same connection

    Hi...
    I am writing an application which connect to its server through HTTP protocol and the server is basicaly a bunch of servlets hosted somewhere (Right not it in the tomcat running in my PC)
    I know that with Connection Keep-Alive header you can keep the connection alive and do multiple requests from the same server.
    Can some one point me to where can I find some sample code which shows how to send multiple requests through same URL conection or URL object. What i cant figure out is how to reset the URL connection or its streams a and make them send anotehr request message to the serverso server can respond.
    Or do I have to do this manualy (using sockets)

    You SHOULD be able to do a HttpUrlConnection method. However, I have hand-coded HTTP server and client apps and the keep-alive is rarely enabled in servers.
    This is due to better handling of millions of unique hosts requesting, unlike a network os, which is made the other way around.

  • Use of repeating request monitor

    hi,
    i am new to atg.
    can any one tell the use of repeating request monitor?
    can i know what all are expected to be know from a ATG develope(for a junior)? ( which topics of atg)

    can any one tell the use of repeating request monitor?class is atg.commerce.util.RepeatingRequestMonitor
    The class RepeatingRequestMonitor is designed for use as a session scoped component. It is used to track request threads that register themselves as executing by name and for a designated time period, to ensure that the same request handler is not executed by two request scoped components concurrently (as happens when a user clicks a submit button multiple times).
    Form handlers should use this by calling the RepeatingRequestMonitor.isUniqueRequestEntry() method. The boolean return value indicates whether the handler is free to proceed execution, or whether another request scoped component has recently been executing the same method for this session. The handler may specify a timeout duration for this entry, or use the configurable default timeout. After the critical execution, the handler may remove the request entry or have these otherwise expire after the timeout.
    can i know what all are expected to be know from a ATG develope(for a junior)? ( which topics of atg)We can do in ATG "Profile Management", "Browse and Search", Shopping Cart", Checkout and so on..
    As a fresher you should know flow upto checkout and you should have deep knowledge in one task like Profile Management.
    -RMishra
    Edited by: RMishra on Feb 28, 2013 9:05 PM

  • Repeated requests to update Flash player on Amazon Video

    I was streaming a movie perfectly for an hour until the movie hiccuped and then Amazon then prompted me to update my flash player, even though I was already on the latest version. After installing, it didn't work. I have since gone through the entire troubleshooter multiple times, clearing the cache, increasing the storage, etc... and uninstalled, and reinstalled Flash multiple times. I have not gotten my Amazon video to stream on IE or FF with the current flash player.
    Windows 7 32 bit Firefox RCN
    ETA Pictures

    I had the same repeated requests to upgrade, usually just as the video started or before.  It doesn't happen on all videos.  I also tried all nine steps in the trouble shooting guide and noticed I got a little further into the video before the notice appeared.  I tried decreasing the screen resolution and it worked on the laptop screen alone.  When I tried to send it to the LCD TV via vga, I got the notice again.  Tried the reduced resolution to no effect.  Then I killed the laptop screen and tried again. It worked on the TV at full resolution after one failure when I got the the usual notice to upgrade.  I had to restart the 55 min video twice when I got the "loading from amazon" message that persisted (probably a separate problem).  I have  no idea what is going on.  Older cheap laptop without separate graphics card, Windows 7 32bit, Explorer 9, Intel accelerator (4 series) driver  version 8.15.10.2302. 

  • Delete overlapping requests of same DTP from cube

    Dear All,
    i want to delete over lapping requests of same DTP in cube, but here while i am searching for the DTP in process variant, the system is not showing the DTP(it is active).
    can you people have any suggestions.
    Br,
    Vamshi.

    Hey Vamshi,
    Is your DTP a full one or delta one ? Delete Overlapping reqs is not possible for Delta loads.
    In Load Process and Post-Processing option you will find Delete Overlapping Requests from InfoCube, drag and drop and make the following settings:
    Object Type = DTP
    Object Name : DTP Name.
    Check Edit all InfoCubes with the following Delete Selections and click on Delection Selection
    Check Delete Existing Request and check Only Delete Req from same  DTP
    Activate and execute the PC.
    Hope this helps!
    Sheen

  • Problem while sending/Receiving request using the HttpURLConnection obj

    Hi,
    We are facing the problem while passing the request in Weblogic.
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    Currently we are migrating 2 applications to WebLogic. Application1 to application2 request should pass.
    Below is some example we tried:
    "When we send a request to our code using the SSOAdaptor code (which handles the request/session in our application) which is on the SunOne server the request parameters are received by our code successfully. And also in Create User Functionality of application1 we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass."
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues.
    Where as when the request is sent from WebLogic to WebLogic the request parameters are missing some how.
    Is there any issue in Weblogic? Please helpus on this.
    Thanks,
    Nagesh
    Edited by: user9307541 on Mar 15, 2010 5:08 AM

    Hi,
    Please find below scenario for testing.
    We have tested the SSOAdaptor code (it is the fucntion name which will send the data from source) locally by hittiing the WPS adaptor URL in a Java client program(TestRequest.java) and the request parameters were reaching the WPS Adapter successfully.
    Then we have written two test servlets to test the communication between SSOAdaptor(TestServlet.java) and WPS adaptor(WPSServlet.java).
    Functionality of TestSevlet: It is sending a request to WPSServelt similar to the way we are doing it in SSOAdaptor.
    Functionality of WPSServlet: It will receive the request parameters and write the parameter Map to console.
    We have deployed and these two servlets(in a single webapplication) on Tomcat server and the request parameters are reaching the WPSServlet successfully.
    Output on Tomcat server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{TypeAcc=[Ljava.lang.String;@14e3f41, ServiceName=[Ljava.lang.String;@1acd47, GMEPortalUserID=[Ljava.lang.String;@19b04e2, UserID=[Ljava.lang.String;@5dcec6, Country=[Ljava.lang.String;@b25b9d}
    after sending request
    After this we have deployed these two servlets (with in a single webapplication) on the Weblogic server in Dev machine(path: /apps/usmport/domains/usmport/servers/usmport_admin/upload/ssoAdaptor/WEB-INF/classes/com/gm/gmeportal/security/adaptor) and
    now the request parameters are not reaching the WPSServlet.
    Output on Weblogic Server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{}
    after sending request
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    When we send a request to WPSAdaptor using the Old SSOAdaptor code which is on the SunOne server the request parameters are received by WPS successfully. And also in Create User Functionality of Portal we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass.
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues. Where as when the request is sent from weblogic to weblogic the request parameters are missing some how.
    Please find below javs source code used to test this:
    TestRequest.java
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestRequest {
         * @param args
         public static void main(String[] args) throws Exception{
              // TODO Auto-generated method stub
              excutePost("http://localhost:8080/Testing/TestServlet", "GMEPortalUserID=captest.wss@it0555&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
              //System.out.println("********** Now the request is from SSO *****************");
              //excuteGet("http://10.156.0.173:7013/channel21/wpsadapter", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
         public static String excutePost(String targetURL, String urlParameters)
         URL url;
         HttpURLConnection connection = null;
         try {
         //Create connection
         url = new URL(targetURL);
         connection = (HttpURLConnection)url.openConnection();
         connection.setRequestMethod("POST");
         connection.setRequestProperty("Content-Type",
         "application/x-www-form-urlencoded");
         connection.setRequestProperty("Content-Length", "" +
         Integer.toString(urlParameters.getBytes().length));
         connection.setRequestProperty("Content-Language", "en-US");
         connection.setUseCaches (false);
         connection.setDoInput(true);
         connection.setDoOutput(true);
         //Send request
         DataOutputStream wr = new DataOutputStream (
         connection.getOutputStream ());
         wr.writeBytes (urlParameters);
         wr.flush ();
         wr.close ();
         //Get Response     
         InputStream is = connection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(connection != null) {
         connection.disconnect();
         public static String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    TestServlet.java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class TestServlet
    public class TestServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * Default constructor.
    public TestServlet() {
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doPost(request,response);
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              //System.out.println("********************** the request Map is:" + request.getParameterMap());
              try {
                   System.out.println("before sending request");
                   excuteGet("http://localhost:7003/ssoAdaptor/WPSServlet", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
                   System.out.println("after sending request");
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         //System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    WPSServlet.java
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class WPSServlet
    public class WPSServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * @see HttpServlet#HttpServlet()
    public WPSServlet() {
    super();
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              System.out.println("**********************Inside WPS Servlet -- the request Map is:" + request.getParameterMap());
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doGet(request,response);
    Thanks,
    Nagesh

  • Lightroom requires me to sign in 3 or 4 times whenever I use it.   I get confronted with a screen telling my trial has 00 days left and I must license or sign in to continue.   If I simply ignore any of these repeated requests, Lightroom immediately exits

    Lightroom requires me to sign in 3 or 4 times whenever I use it.
    I get confronted with a screen telling my trial has 00 days left and I must license or sign in to continue.
    If I simply ignore any of these repeated requests, Lightroom immediately exits
    .This happens whether or not I sign in to Creative Cloud before attempting to launch Lightroom.
    My subscription is in good standing and Lightroom/ Photoshop are up to date. There are no earlier versions installed.

    From what you report it appears that you have a trial version of Lightroom 5 perpetual license version installed. Subscribing to the Creative Cloud package PS CC and Lightroom will not activate this version. Try the following.
    1. Uninstall Lightroom using the OS system normal uninstall process. This will not affect your existing Catalog and user files and but will just remove the Lightroom Application.
    2. Reboot your computer.
    3. Open the Adobe Creative Cloud Application Manager and it should give you the option to download the latest Lightroom 5 install package. Proceed to download and install this version and it should be activated automatically, no requirement to enter any license key like the Perpetual License version. It will automatically link to your existing Catalog files etc. 

  • Several times after restarting Final Cut X was very slow and it always kept repeating rendering on same three clips. Later it stops rendering on every restart and the machine was normal and faster. Now it keeps crushing on every restart

    My Final Cut X changed behaviour after conneting the external monitor via HDMI. Several times after restarting Final Cut X was very slow and it always kept repeating rendering on same three clips after every restart. Later the dual screen icon disapeared on the top of my screen and it stops rendering on every restart like before and the machine was normal and faster. Now Final Cut won't start anymore whenever I start it loads and crushes immediately on every restart.

    Upgrade FCPX

  • New iPad repeated requests for iCloud ID

    Since setting up my new iPad (3rd generation) I have been plagued with repeated requests for my iCloud ID/Apple ID. It happens at least once a day, often when I open the device in the morning, but also happens during the day when waking the iPad from sleep. I never had this problem with my old iPad 2.  Any help appreciated.

    Librariand seems to be required by iCloud in combination with Evernote. Do you have Evernote installed?
    See this thread Re: Is "librariand" part of Lion ? if yes, what is it for ?https://discussions.apple.com/message/15932747#15932747

  • Repeated request for icloud password on booting

    Recently, and every time I boot, I get repeated requests for my icoud password.
    I have started cancelling the request and can't see any difference.
    Wonder how I can stop this.
    I shut down overnight.

    Try running Keychain First Aid and resetting the original keychain.
    Keychain Reset
    Keychain Issues - Resolve  see post by Kappy

  • Repeated requests for account verification

    I am trying to update my apps on my iPod touch. I get repeated requests to verify my account information without ever getting connected to iTunes and downloding the information.
    I was able to log into iTunes from my PC, downloaded a song and got confirmation for being billed for it.
    Message was edited by: Wolfprince007

    Librariand seems to be required by iCloud in combination with Evernote. Do you have Evernote installed?
    See this thread Re: Is "librariand" part of Lion ? if yes, what is it for ?https://discussions.apple.com/message/15932747#15932747

  • Repeated requests for user name and password

    I am suddenly getting repeating requests to provide my user name and password but the requesting screen already has this information filled in. Each time I press OK the request returns. Is this a server problem?
    Solved!
    Go to Solution.

    A quick look through this board will reveal that this has been an intermittent problem with BT Yahoo! for ages and is one of the reasons are moving to a new BT Mail (which itself has stalled because of problems). Meanwhile, logging in direct to webmail then out again has been known to overcome the password issue.
    You can click the white star next to this message if you think it was helpful.

  • Photoshop CS6 Repeated request for license number

    How can I stop CS6 repeatedly requesting entry of the license number.
    It is becoming a real pain!!

    Here we are on January 6th and still no solution.
    Having paid nearly £200 for the upgrade all I have received is a considerable amount of trouble. The problem has not only affected my upgrade to CS6 but it also seems to have stopped my RAW file processing in CS5 so that I am unable to undertake my normal working procedures.
    Do ADOBE at head office know of these problems (I am aware that others have experienced similar difficulties.)?
    I shall copy this reply to Adobe Systems in Ireland and UK as I feel that I have had a very raw deal in this matter. My computer systems are not unusual and are kept up to date. I have no problems with any other software and have only experienced these difficulties with Photoshop since the upgrade to CS6. Frankly it would seem that Adobe are now only interested in supporting those who are prepared to pay stupid monthly sums of cash!!!!
    I have used, and still use:-  Adobe Premier, Adobe Acrobat, Adobe Soundbooth and Adobe Audition and have had no difficulties with any of this software. I was seriously considering the purchase of Adobe InDesign but it appears that you only wish to support Cloud Membership purchases now so I shall have to re-think that as well. I’m really fed up with Adobe at present. After 30 odd years it would seem you no longer require my patronage.
    Having got that off my chest! I look forward to the session with Adobe to resolve these issues tomorrow at 12:00.
    Will post the result later.
    Peter Neate

  • Why do I get repeated requests for cookie approval on the same website?

    FF 3.6.10
    XP pro. sp3
    I get message "__" wants to change an existing cookie"
    I click "this session only or OK" and still get the request. Each time the cookie description is different. 4 or more requests each time.

    *Extended Cookie Manager: https://addons.mozilla.org/firefox/addon/1243

  • How to submit a child concurrent request in same session as its parent?

    Hi All,
    I need one help. In one of my program, I am using something like this
    fnd_request.submit_request ()—prog A
    fnd_request.submit_request ()—prog B
    fnd_request.submit_request ()—prog c
    now I want prog A,B and C to use same session. the moment I use fnd_request.submit_request, it opens a separate session, I want to use same session. I even tried with request set but didn’t work.
    Kindly help on this.
    Kind regards
    Sandy

    Hi,
    now I want prog A,B and C to use same session. the moment I use fnd_request.submit_request, it opens a separate session, I want to use same session. I even tried with request set but didn’t workThis is an expected behavior, and I believe there is no way to have all requests running under one session.
    Regards,
    Hussein

Maybe you are looking for

  • CAN NOT VIEW ALL TABLES IN MY INSTANCE/SCHEMA

    neither thru an ODBC connection in Access or thru TOAD can I see all of the tables available to me in my instance. In TOAD I can query them, if i know their names and call them in the SQL but when i go to the table view they are not there.... HELP!!!

  • How to setup WPA2-PSK on aironet 1602 i

    I have an AIR-SAP1602I-A-K9 WAP and I am interested in configuring it for WPA2-PSK security for WAP access.  I don't see a way to do this in the GUI, does this model support that type of security?  Thank you.

  • Change in cost in report

    hi gurus i have got a KEY FIGURE i,e cost of invoice.. actually the problem is when m runing a query this particular Key figure changing its decimal place like IN CUBE its value is 167.2 while in report it showin 16.72 kindly suggest me the way to re

  • WCS 7 map editor issue

    Hi Guys, I am currently setting up some maps on WCS version 7. The map displays correctly in the floor view but if I open in Map Editor it seem to crop about a 1/3 of the picture on the right hand side. I have tried using different building/floor siz

  • Adobe forms nested table layout

    Hi, I have an xml input described by a schema including 3 level nested table like this: Table1 __col1 col2 col3 __Table2 ____col1 col2 col3 ____Table3 ______col1 col2 col3 In Adobe LC I have no problem to link the tables using Subforms but the PDF la