Multiple post requests using a single HttpConnection

Hi,
is it possible to send multiple post requests using a single Http connection.
i am currently trying to simulate the preformance overhead because of creating HttpURLConnection to talk to my servlet. But, that made me wonder, if is there a way to send multiple post requests using a single HttpURLConnection.
can anyone help me with this.
thanks in advance

Hi
I found this article through Google. I hope it helps a little
http://www.developer.com/tech/article.php/761521
D

Similar Messages

  • How to post multiple http requests using a single http connection in java

    I am using the httpurlconnection class and it allows only to post one request on a connection. I require to post multiple http requests by opening a single connection. Code examples please. Thanx in advance.

    Hi
    I found this article through Google. I hope it helps a little
    http://www.developer.com/tech/article.php/761521
    D

  • Multiple POST requests

    Greetings everybody,
    For this particular question I am not getting any help from the Java forums and Google.
    Not very long ago I had to send a stream of bytes from an applet to a servlet (the applet and its helper classes are packed inside a signed jar file), but I used to fail miserably at every step.
    I tried every trick in the book (for me the books were Google and Java forums!!). I set the servlet's path in the Windows CLASSPATH, I tried to call the applet from within a servlet- of course after placing the applet file in the servlets folder- (in the hope that since the applet was in the same location as the servlets the URL would get established) e.t.c but still URL url=new URL(<servlet URL>) refused to invoke the servlet.
    Finally somehow I managed to get it done using the code below:
    public class Xyz extends Applet
    //DONT BE SURPRISED RIGHT NOW!!
    Class cls=this.getClass();
    ClassLoader cldr=cls.getClassLoader();
    //THE ACTUAL SERVLET CONNECTING CODE
    URL url=cldr.getResource("http://localhost:8000/servlet/<SomeServlet>");
    /*This statement does not work........ URL url=new URL("http://localhost:8000/servlet/<SomeServlet>").A NULL URL OBJECT GETS CREATED!! */
    HttpURLConnection hurlc=(HttpURLConnection)url.getConnection();
    //ALL THE NECESSARY FORMALITIES TO BE PERFORMED TO WRITE THE STREAM TO THE SERVLET
    hurlc.setDoInput(false);
    hurlc.setDoOutput(true);
    hurlc.setUseCaches(false);
    hurlc.setRequestMethod("POST");
    OutputStream os=hurlc.getOutputStream();
    //WRITING THE STREAM
    os.write(<some byte buffer>);
    //NOW COMES THE TRICKY PART
    hurlc.getResponseCode();
    I had to do getResponseCode() because once ClassLoader.getResource(<servlet URL>) invoked the servlet using the GET method I COULD NOT INVOKE THE SERVLET AGAIN. I had to force an invokation using getResponseCode().
    Well all is well now excepting for a small irritant. Instead of issuing one POST request the URLConnection is issuing multiple POST requests. In the Apache logs I get to see something like:
    GET /snodx/callapplet.htm 200 116
    GET /snodx/keystore_for_holding_fingerprint_for_trusted_applet 200 234
    GET /snodx/applet_and_helpers.jar 200 105
    HEAD /servlet/<SomeServlet> 200 187
    POST /servlet/<SomeServlet> 200 312
    POST /servlet/<SomeServlet> 500 604
    POST /servlet/<SomeServlet> 500 604
    The last 2 lines indicate that the servlet was invoked but the connection closed somehow. This is confirmed by taking a look at the Apache error logs:
    Premature end of script headers.
    Premature end of script headers.
    In the JServ servlet engine error logs I am getting:
    (500)apj12 returned an error handling request
    cannot scan servlet headers.
    The problem is occurring somewhere in getResponseCode().This statement is invoking the servlet using the request method set (POST) several times (2 or 3 times).
    Can someone explain what's going on?
    This is briefly the servlet code:
    public class SomeServlet extends HttpServlet
    //THE SERVICE METHOD IS CALLED BY A HEAD REQUEST TO THIS SERVLET
    public void service(ServletRequest reque,ServletResponse respon) throws ServletException,IOException
    this.doPost((HttpServletResponse)reque,(HttpServletResponse)respon);
    //GO DIRECTLY TO THE POST METHOD
    public void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
    ServletInputStream sis=req.getInputStream();
    if(sis.available()<2) //CHECK THAT THERE IS STREAM WHICH HAS AT LEAST 2 BYTES OF DATA!!
    log("NO STREAM FROM APPLET");
    else
    //PERFORM ALL ACTIONS TO WRITE TO STREAM OF BYTES TO A LOCAL FILE
    I have the servlet engine JServ 1.1.2 configured to run with Apache 1.3.19 on Windows 2000.
    I compiled the Applet and the Servlet using JDK1.3 and JSDK2.0. I have JRE 1.3.1_02 installed on my Win2k machine.
    Sorry for the long winded story here.
    Awaiting a reply.
    SNODX
    (The search keywords combination getResponseCode multiple POST requests +Applet and many other related keyword combinations did not match any document in the Java forums. The search string "Multiple POST requests" "getResponseCode" and many other related search strings did not match any document in Google.I am continuing the search effort however                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    interresting the classloader solution. Well if that works, i would keep it like that so far.
    But maybe this can help:
    os.write(<some byte buffer>);
    ..and then
    os.flush()//to make sure the outputstream is sent immediatly.
    //i think getResponseCode() is not necsessary in that case
    //but not certain, after all ...setUseCaches(false);
    One thing you should do is remove the complete
    service() {
    ...this.doPost();
    the reason is that when a POST arrives at the servlet, the default service-method of the ancestor class (which is javax.servlet.Servlet) will automaticaly make a call to doPost() of the javax.servlet.http.HttpServlet subclass. You should not overide it I believe.
    maybe... -try to establish an OutputStream only once in the Applet.
    - receive the other end exactly once (as you did) in the doPost as an InputStream;
    - eventually wrap both sides in respective Buffered(In)(Out)putStream(Reader)(Writer)
    - start looping and .write() and .read() at both sides on the single and same in-and-outputStream();
    (i.e avoid establishing the connection from the applet several times..., get one connection and keep it)
    sorry if this story would be irrelevant,
    Papyrus

  • How to create the multiple spool requests for a single report.

    Hi gurus,
                     I have one requirement to be completed , i need to send the out put of the report via mail in pdf format. for that what i did was, iam executing report in background and creating spool request and converting it to pdf and sending the file.
    now the problem is, its a customer ledger report, for each customer i need to create a new spool request and send mail to that particular customer, now my dought is how to create multiple spool requests for a single pro and how i need to go about it.
    And one more question is can we create a spool request for a report which is running in online.
    waiting for inputs frm gurus.

    Hello,
    As per my knowledge for creating new spool id you will have to set
    output_options-tdnewid = 'X'.
    and then using
    job_output_info-spoolids
    create a pdf using
    call function 'CONVERT_OTFSPOOLJOB_2_PDF'
    Rachana.

  • Can I have multiple TFS instances use a single SSRS installation

    Can I have multiple TFS instances use a single SSRS installation?
    Thanks

    Hi Kim,
    According to your description, you have multiple TFS instances using one Reporting Services instance. Right?
    For installing TFS, to use a named instance with Team Foundation Server, you must install SQL Server by using a named instance, or move or restore Team Foundation Server data to a named instance, or create a team project collection on a named instance. Please
    refer to the link below:
    Work with SQL Server Named Instances
    Reference:
    Understanding SQL Server and SQL Server Reporting Services
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Multiple HTTP requests using single HTTPService component

    Hi,
    I am having one requirement, I need to use a single HTTPService component to send request to a same and single ASP.net multiple times.
    How can I acheive that..? I know that I can acheive this by sending one request at a time and after the "result" event is called for the first request then sending the second request and so on...
    But if I do so then it will be delayed response as I need to wait until the result handler for the previous request is called...
    So how do I do this..?
    Any help greatly appreciated....:)
    Thanks in advance..
    Thanks,
    Bhasker Chari

    yep, the setting works when set to 10. Seemed to not work when set to 20. Anyways, summary is "long polling" and Flex
    or Flash are not good compatriates. So, you will need to work out your own mechanism on the server or client
    side to limit the sockets used/wasted. Painful but true.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import com.util.HTTPServiceProxy; 
    import mx.rpc.events.FaultEvent; 
    import mx.rpc.events.ResultEvent; 
    import mx.rpc.http.HTTPService; 
    private var urlOpenTasksDefault:String = HTTPServiceProxy.servercontext + "/blahblah?something=somethign";  
    private var waitRequestPart:String = "&wait=5000&lastUpdate=" // long polling period for now for testing
    private var iResponses:int; 
    private function runTest(urlString:String):void{ 
    var service:HTTPService = new HTTPService();service.url= urlString;
    service.resultFormat =
    "e4x";service.method =
    "get";service.contentType=
    "application/xml";service.addEventListener(
    "result", httpResult);service.addEventListener(
    "fault", httpFault);service.send();
    public function httpResult(event:ResultEvent):void { 
    trace("httpResult " + iResponses++ );}
    public function httpFault(event:FaultEvent):void { 
    trace("httpFault " + (iResponses++) + event.fault.faultString);}
    private function test1(evt:Event):void {iResponses=0;
    var reqs:int = parseInt(requests.text); 
    for( var i:int=0; i<reqs; i++ ){runTest(urlOpenTasksDefault);
    private function test2(evt:Event):void {iResponses=0;
    var reqs:int = parseInt(requests.text); 
    for( var i:int=0; i<reqs; i++ ){runTest(urlOpenTasksDefault+waitRequestPart+
    "0");}
    ]]>
    </mx:Script> 
     <mx:Label text="Requests"/>
     <mx:TextInput id="requests"/>
     <mx:Button label="Test Requests-Responses" click="test1(event)"/>
     <mx:Button label="Test Long Polling" click="test2(event)"/></mx:Application>

  • OSB example calling multiple business services using a single proxy service???

    Hi,
    I have three business services created using http urls i.e.
    1. LoginBS
    2. GetListBS
    3. LogoutBS
    My requirement is to get a list of names from GetListBS using a single proxy service and to call GetListBS I have to first call LoginBS then GetListBS i.e. after authentication and then finally logout.
    Kindly help with a detailed example for this and I am new to OSB.
    Thanks,
    Vik

    Hi Eric,
    Thanks for the response. We figured that it is possible to call multiple services with Split Join. However, we ran into the issue you described. We had a blocking call and had to wait until each of the services returned a response.
    However, we needed a Async model for our design and felt that this might not be a right fit.
    We are now looking at implementing the publish option with QoS configured as this fits our usecase better. Thanks for the help again.
    Rudraksh

  • Update multiple rows & columns using a single statement

    I have the following table with tablename - emp
    first_name last_name age
    aaa bbb 31
    56
    78
    ggg hhh 36
    2nd & 3rd row contain null values (no data) in first_name & last_name column . I want to update those two rows with data using a single statement. How do I do it?
    I was thinking may be something like the following:-
    UPDATE emp
    SET first_name= , last_name=
    CASE
    WHEN age = 56 THEN 'ccc', 'ddd'
    WHEN age = 78 THEN 'eee', 'fff'
    ELSE first_name, last_name
    END
    -----------------------------------------------

    Can you give an example of a nested decode statement.
    test@ora>
    test@ora>
    test@ora> --
    test@ora> drop table t;
    Table dropped.
    test@ora> create table t as
      2  select rownum x, cast(null as varchar2(10)) y from all_objects
      3  where rownum <= 10;
    Table created.
    test@ora>
    test@ora> select x, y from t;
             X Y
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    test@ora>
    test@ora> -- You want to change the values of y to 'a' through 'j' for x = 1 through 10
    test@ora> -- and y = 'X' otherwise
    test@ora> --
    test@ora> -- Let's say the limit on the number of components were 12
    test@ora> -- Then your decode statement would've been:
    test@ora> --
    test@ora> update t
      2  set y = decode(x,
      3                 1, 'a',
      4                 2, 'b',
      5                 3, 'c',
      6                 4, 'd',
      7                 5, 'e',
      8                    'f');
    10 rows updated.
    test@ora>
    test@ora>
    test@ora> select x, y from t;
             X Y
             1 a
             2 b
             3 c
             4 d
             5 e
             6 f
             7 f
             8 f
             9 f
            10 f
    10 rows selected.
    test@ora>
    test@ora> -- As you can see you are unable to:
    test@ora> --
    test@ora> -- change y to 'g' if x = 7
    test@ora> -- change y to 'h' if x = 8
    test@ora> -- change y to 'i' if x = 9
    test@ora> -- change y to 'j' if x = 10
    test@ora> -- change y to 'X' otherwise
    test@ora> --
    test@ora>
    test@ora> -- What you would do then is -
    test@ora> -- (i)  Let the 11 components remain as they are and
    test@ora> -- (ii) Introduce a nested decode function *AS THE 12TH COMPONENT*
    test@ora> --
    test@ora>
    test@ora> rollback;
    Rollback complete.
    test@ora>
    test@ora> --
    test@ora> update t
      2  set y = decode(x,
      3                 1, 'a',
      4                 2, 'b',
      5                 3, 'c',
      6                 4, 'd',
      7                 5, 'e',
      8                 decode(x,
      9                        6,  'f',
    10                        7,  'g',
    11                        8,  'h',
    12                        9,  'i',
    13                        10, 'j',
    14                            'X')
    15                );
    10 rows updated.
    test@ora>
    test@ora> select x, y from t;
             X Y
             1 a
             2 b
             3 c
             4 d
             5 e
             6 f
             7 g
             8 h
             9 i
            10 j
    10 rows selected.
    test@ora>
    test@ora>HTH
    isotope
    Extrapolate that to 255 components and you get 254 + 255 = 509 components. And so on...
    Message was edited by:
    isotope

  • Multiple requests in a single HttpConnection

    this is the point,
    I would like to make a while that sends multiple requests, but with just one HttpConnection.
    something like this:
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    public class Ping extends Thread {
        String url;
        HttpConnection conn = null;
        DataInputStream hdin = null;
        DataOutputStream hdout = null;
        public Ping(String url) {
            this.url = url;
        public void openConnection() {
            try {
                conn = (HttpConnection) Connector.open(url);
                conn.setRequestMethod(HttpConnection.POST);
            }  catch(Exception e) {
                e.printStackTrace();
        public void efetuaConsulta() {
           int counter = 0;
           try {
                if(null == conn)
                    openConnection();
                while(counter <= 10) {
                    hdout = conn.openDataOutputStream();
                    hdout.writeInt(counter);
                    hdout.flush();
                    hdout.close();
                    hdin = conn.openDataInputStream();
                    counter = hdin.readInt() + 1;
                    hdin.close();
                    System.out.println("--> "+counter);
            } catch(Exception e) {
                e.printStackTrace();
        public void run() {
            efetuaConsulta();
    }well, this the idea, but its not working....
    this class would send an incremented int every request to my servlet,
    in another project, my servlet would do something....
    but this is not working because it says my DataOutputStream is already opened.
    I tried to do a singleton too, but it doesnt work....
    someone knows how to do it?
    I know it's possible because midp1.0 supports HTTP1.1
    and HTTP1.1 support what Im trying to do here....

    Http 1.1 is not supported. You could implement that yourself...
    try to move the openconnection into the while loop. that should work

  • Change the display of the multiple Table items using a single Drop-down

    I have created a Web Template in BEx WAD (BW 3.5) with 4 Tables assigned to 4 dfferent Queries. Now I want to change the display of the all the Four Tables based on the selection of display properties chosen in a single Dropdown item. The properties to be selected  in the dropdown are like changing the Alternate style display of Rows, Suppress Alternate Style, Display only 30 Rows or 60 Rows.
    Please help me in writing the script necessary to pass the command from the dropdown to all the Tables to get the desired output.
    Thanks,
    Krishna
    Edited by: Hari Krishna Velampalli on Oct 26, 2008 12:00 AM

    Dipika, Thanks for the response.
    I tried using that option but again since we cannot give custom options in a drop-down,
    I created a Form with a drop-down list of options like Suppress Result Rows, Suppress alternate style of rows, Display only 30 Rows, Display only 100 rows .. and so on.
    Now I am able to change the display of my first table by selecting the options in the drop-down list. But my intention is to apply that selection to Multiple Tables.
    How can I achieve that?
    HK

  • Multiple Windows accounts using a single Library

    I have not found a way to solve this problem but I am convinced that it is my lack of Windows expertise, so hopefully someone can point me in the right direction. I am talking about the iTunes Library and NOT Music Folder.
    I have two login accounts in my WinXP environment. I want both of these accounts to have not just access, but full control over iTunes - add music, create and delete playlists, etc. In effect, I want iTunes to see both accounts as if they were one user. There is no issue with simultaneous access and conflicts because the machine is not configured to allow fast user switching(and it can't be - our IT dept won't allow). This also prevents using any sort of solution which uses iTunes music "sharing".
    I had no problem locating the iTunes Music Folder in common space so both accounts can access the actual music, but for now, I've had to copy the iTunes Libray.itl (and the XML lib file) into the second user account's Docs and settings\account\My Documents\My Music\iTunes\ path. Then I try remember which was changed last and manually sync - painful and error prone.
    I tried copying the iTunes folder and library files to common access space (all users), and then creating shortcuts, renaming the shortcuts to the actual files names (dropping "shortcut to"), and putting the shortcuts in the locations where iTunes expects to find the "real" files. This is how I got it to work on the Mac - with aliases - but I guess that aliases and shortcuts don't exactly behave the same.
    Any help would be appreciated. Thanks - TK

    hi The Kid!
    here's a bleeding-edge hack along those lines ... unsupported, no guarantees of success on a 6.0.x, etc, etc ...
    MacMuse, "Multiple users on one PC" #1, 02:14pm Sep 5, 2005 CDT
    love, b

  • Getting Multiple Recordsets using A Single Connection using jdbc-odbc

    I have a java application which uses sql 7.0 database server. I want to have multiple recordsets created using a single connection using jdbc-odbc bridge. Kindly let me know the procedure.

    Well, you create a recordset, then you create another one, and so on. Are you actually having a problem or you just don't know where to start?

  • Printing multiple spool requests at a time

    Hi All,
    I am using function module RSPO_OUTPUT_SPOOL_REQUEST to print the contents of the spool request. I want to print multiple spool requests at a time. We can input only one spool request number to the above function module at a time. Is there any way that I can print multiple spool requests with only single Print Popup Window ?
    Thanks.

    Hi Khanna,
    I tried that option at first place only. It results in multiple Print Popups. I want to avoid this. For all spool print requests, I want to show ONLY ONE Print Popup.
    Thanks.

  • CHaRM-Is that possible to create multiple Transport Request in UC

    HI Gurus,
    Quick question on ur.gent correction using Solution Manager CHaRM in EHP1. Is it possible to create multiple transport request(TR) for single ur.gent correction (UC). DO NOT confuse with transport task.
    For example, after I created transport request and developer start working and release the task, realised to add another transport request for same UC. When I tried, it did not create any TR but checked the message found that
    Schedule Manager: Monitor
    Job Status: Processing completed, but with warnings
    Program Name: /TMWFLOW/SCMA_TRORDER_CREATE
    Action to be checked: Ur.gent Correction: Create Transport Request
    There is already an open request, XXXXXXXXXX, for this project
    So only way I can do that I released the TR and able to create another TR.
    May be wondering why I need to create another TR, why not create TASK and work on that.
    But this is the requirement at our company.
    I will appreciate the effort and time to provide me the solution of this.
    Thanks
    Ava

    Hi Ragu,
    That's really quick turn around. Unfortunately not able to found whatever you mentioned in your message. Here is detail,
    I navigate to Actions - Depending on Status, found the entry as
    Trans. Type     StatProf         UserStatus     Seq     Action in SAP Change Manager
    SDHF             SDHFHEAD   E0002            10       CREATE_HF
    SDHF             SDHFHEAD   E0002            20       CREATE_REQ
    SDHF             SDHFHEAD   E0002            30       SAVE_PARTNER
    SDHF             SDHFHEAD   E0002            40       SET BO LINKS
    Where SDHF - Ur.gent Correction
               E0002 - In Development
               CREATE_HF -        Create an Instance in SAP Change Manager
               CREATE_REQ -     Create Transport Request with Task
               SAVE_PARTNER - Save Partners in Respective Partner Roles
               SET BO LINKS -     Sets Links to Business Objects
    I don't see any OPEN_TR.
    Any other place need to make change.
    Thanks
    Ava

  • How Can I Use Multiple Weblogic Instances in a Single OS

    Hello Everyone,
    Actually I have to install Some different applications. Few of them need weblogic 10.3.6 and others need 10.3.4. The OS am using is Oracle  Enterprise Linux 5.
    Now I am able to install 2 separate(One of 10.3.4 and 10.3.6) instances with two different users,In two different directories.
    I have installed the weblogic 10.3.6 version with a user webadmin and installed node manager with port 5556. This is working fine.
    The main problem here is :
    In the second instance (10.3.4 ) installed with a a different user and gave the port number to NodeManager as 1600 and its not getting started. Its throwing error and also after some errors in the terminal am able to see that its reverting to port number 5556 only.
    What might be the issue?
    I have to install 2 different versions of weblogic in a single Server. But am failing with NodeManager. What Can I do to have multiple weblogic instances with multiple versions in a single server ?
    Can anyone suggest a resolution for this please ?
    Thanks in advance.

    Pl do not spam these forums with multiple posts - How Can I Use Multiple Weblogic Instances in a Single OS

Maybe you are looking for