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

Similar Messages

  • 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

  • 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.

  • Multiple output files from single Request

    Hi guys
    i have one requirment,can we display multiple outputs files (multiple templates) for a single request .
    ie i have some banks ,if i run an request ,it will get the details of each bank details ,induadual template .
    let me know the solution for this one.
    thanks inadvance.

    Pl post details of OS, database and EBS versions.
    Pl elaborate on your requirements. Assuming you are using XML/BI Publisher, the physical output file will be a single file, but you can use XML/BI Publisher bursting features to separate out different outputs.
    How to Implement XML Publisher Bursting in 11.5.10.2?          (Doc ID 740428.1)
    How to Print Via Bursting Control File          (Doc ID 844276.1)
    HTH
    Srini

  • Invoking multiple servlets from a single request

    Hi. I'm wondering if it's possible to execute multiple servlets within a single request and context. I have a servlet defined in web.xml which says:
    <servlet>
    <servlet-name>firstServlet</servlet-name>
    <servlet-class>mypackage.First</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>firstServlet</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    (clearly this one gets invoked upon every request in the context)
    But I also have another servlet which gets invoked when another condition applies:
    <servlet>
    <servlet-name>secondServlet</servlet-name>
    <servlet-class>mypackage.Second</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>secondServlet</servlet-name>
    <url-pattern>*.ftl</url-pattern>
    </servlet-mapping>
    So if the url was http://localhost:8080/mycontext/page.ftl, I want both servlets to get executed. Is there anyway I can do this? I've tried the above code and it doesn't work. How would I do this (or can I even do it)?
    Thanks,
    Dylan

    depending on what your servlets do, you might also think of using filters. say you have a first servlet that compresses the respone you would be better off to implement this as a filter. than you might have a second serlvet that does request logging stuff. this might also be better than in a filter, so you chain first and second filter. the business logic is put in servlet three i.e.

  • How do I host multiple domains on a single Messaging Server?

    How do I host multiple domains on a single Messaging Server?
    <p>
    To host multiple domains on one Messaging Server, use the
    mailAlternateAddress attribute. If you want to host two domains
    (customer1.com and customer2.com) on your server mail1.domain.com,
    make sure that:
    The various domains (in DNS) point to the installed mail server
    (you must have the MX records that
    points mail for customer1.com to mail1.domain.com and
    customer2.com to mail1.domain.com)
    That each person receiving mail at customer1.com and
    customer2.com has an appropriate mailAlternateAddress
    attribute describing the appropriate email address. For
    instance, John Doe can have an email address (i.e. the value
    of the 'mail' attribute for the John Doe LDAP entry) of
    [email protected] and receive his mail on
    [email protected] (the value of the mailAlternateAddress
    attribute)
    With Messaging Server 3.5, mailAlternateAddress can take the
    form of @mail1.domain.com. If jdoe's mailAlternateAddress is
    set to @mail1.domain.com, mail sent to [email protected]
    will be delivered to [email protected]

    jaygatsby1123 wrote:
    So what exactly am I doing with virtual hosts?  There is a place for Aliases...  What would I put in the "Aliases" box?
    Any other host name that you want to resolve to the specified virtual host.  It's quite literally an alias.
    if you want www.example.com and www.example.org to end up at the same web site and you already have a virtual host — Apple refers to virtual hosts as sites — configured for www.example.com in Server.app, then you'd add www.example.org as an alias for the www.example.com virtual host (site).
    Virtual hosts are implemented in a web server using some details of the HTTP or HTTPS protocol, and what the web browser (client) specified.  The client gets handed an IP address or a domain name by the user, and the client then fetches the associated IP address for the target web server from the client's DNS services or local host database, and the client then connects to the IP address and passes over the text string that the user had requested — the IP address or domain name or even some local shortcut set up in the client system — via the HTTP or HTTPS protocol.  The web server receives and processes this arriving text string from the client, and uses it to select which web site to render back to the web client.   One subtle detail lurks here, too: the server's own DNS configuration really isn't involved in the selection of the virtual host.

  • How can I connect multiple clients to a single client ?

    I am currently developing an instant messaging program.I created a server and connected multiple clients to it by using thread logic.However I do not know how to connect multiple client to a single client.
    What shall I do for that?Does anybody know a good tutorial or sample program?Or shall anybody explain me what I shall do for building the Instant Messaging part of my chat program?
    Thank u in advance.

    You may use UDP multicast socket. But since you are using the UDP protocol you might risk losing the data that you send since UDP does not guarantee the safe transfer of data.
    Alternately, you might create a server that allows multiple client to connect to it whose connection Socket objects are then stored in a Vector <Socket> object. The server then sends back data to the connected client about the other clients connected to it. Now when the client wants to send data (like an IM) to another connected client, it has to send a request to the server specifying the client login name and the server in turn streams that particular client's Address and Port to the requesting client. The requesting client then initiates the connection with the other client and then starts a conversation. One more thing, when the client communicates it needs to send information to the server like the name by which it likes to be referenced. In this scenario the server acts like a central repository for clients to query the existence of other clients in the chat room. Each client here runs a thread that listens to incoming connections and when a connection is established, may be opens a IM window or something.
    The third option is to make the server to relay the information from one client to another. Like say, I'm connected to whoopy server and i want to send "Hello" to jackson, then i send the message (ie, Hello) along with the name of the client to which i wish to send it to (ie, jackson). The server then performs a lookup in its Vector <Socket> object and then initiates a connection with jackson and sends the information. However, this method is pretty costly in that you will be wasting a lot of processing behind the server.
    --Subhankar
    P.s. If you stumble upon any other brilliant ideas let me know.

  • Problem with multiple requests to different servers using HTTPService

    Hi
    I'm aware that we are limited to two concurrent connections to a single host, so I'm looking into using either subdomains pointing to the same server, or separate physical servers to process multiple requests side-by-side.
    However, whichever way I try to send three requests, looking at the Network Monitor the 3rd request always waits until one of the first two has finished. In the screenshot below, all three requests were sent at the same time to three separate physical servers, yet the top request didn't start until the bottom request finished, at 15:33:28
    Any ideas how to get round this? I'm using SSL, but I've also tested it on HTTP with the same results. I'm writing an AIR app, and posted this on the AIR forum but was told it was a Flex issue and I should post it here.
    Please let me know if any more information is needed
    Many thanks
    James

    Would that still apply even though I'm not running this inside a browser, but in AIR?
    I've seen this method recommended by other people, and also the following page seems to suggest that what I'm doing should work
    http://www.chadupton.com/blog/2008/08/maximum-concurrent-http-requests-from-adobe-air/
    Kind regards
    James

  • How to capture the Status code in Web application Transcation monitoring if we are using multiple Request

    Hi Team
    We would like to monitor 12 url,s which requires Authentication. Hence i have added the same in one Single Web application transcation template.
    i have added the below info to the get the Stats code displayed in Alert
    Status code is $Data/Context/RequestResults/RequestResult["1"]/BasePageData/StatusCode$
    when i recived a alert it gave the Status code of the 1st Request
    hence i changed the same as
    Status code is $Data/Context/RequestResults/RequestResult["12"]/BasePageData/StatusCode$
    But still i am facing the same issue .
    My first request shows me a status code of 200, and my 12th Request comes with 500 but in the alert i get 200 but it should be 500.
    Kindly help me in how i can get the Status code for the multiple  Request.
    Regards
    Sriram

    Hi Sriram,
    Please run the test of your 12th Request, view full result and check if Status Code is 200.
    Meanwhile, you can run the URL manually to check the result.
    Niki Han
    TechNet Community Support

  • Handling Multiple requests in SOAP Sender Adapter

    Hi All,
    We are working on scenario SOAP-IDOC.
    We receive multiple requests from Source, PI should process them and deliver it to SAP system.
    Now the issue is :
    The messages are in separate SOAP requests i.e. 5 messages = 5 SOAP requests.
    If sending a single message there is no issue.
    If sending multiple messages at once then a time-out occurs.(HTTP 408 Timeout) If sending
    5 SOAP requests in the same transmission then the first message will process ok but the other 4 will report an error. If the 5 SOAP requests are transmitted individually then they process ok.
    Can any one throw some pointers on this? What are the settings I have to do in PI so that sender can avoid getting HTTP 408 timeout error?
    Regards,
    Srini

    Hi Srinivasa,
    Set icm/server_port_X parameter . You can change this in RZ10 .Goto tcode RZ10 select the instance profile and select the extended maintenance and click on Change Now click on Create Parameter Tab and write the profile parameter icm/server_port_X and press enter it will show you the default value if any and then put the new value and click on save and F3 and then again save.System needs to be restarted to reflect these changes.
    Also check out the SOAP adapter FAQ on service market place. This would surely solve your problem(time out).
    Rgds
    joel

  • How to handle multiple requests to the same servlet at one time?

    Hi,
    I am new to Servlets. I have doubt regarding ... Handling multiple requests to a servlet at a time.
    If we send a single request to a servlet, as know that group of objects such as servlet, servletContext, servletConfig, request, response and etc are created in the server, And if 1000's of requests are sent to a same servlet at a time, and if server memory capacity is less, then 1000's of objects are created in a server which would be heavy burden to Server. How to handle the application and development in such situation?
    Kind regards,
    veerendra

    Hi veerendra reddy ,
    By default any web server can will have a thread pool to handle client req's.
    In your point also heavy burden to server you are telling that depends on this.
    we can configure this min & max size of this thread pool.
    by default it will be 0-1000 for tomcat server.
    I am not sure in which file this configuration will be.
    But I hope in server.xml or some xml file consists this info.
    If You what you can edit accordingly. to overcome your heavy burden to server.
    Thanks & Regards
    Nagendra

  • Multiple selects() within a single VM

    Is anyone aware of any contention issues when running multiple threads within a VM where each thread has it's own select statement?
    I have an home grown app server that allows me to run multiple applications within a single VM. The applications are unrelated however they sometimes communicate with each other via TCP. All of them are very network intensive ( 500 messages a second where each message is around 200 bytes ). These apps are usually single threaded where the main thread is a select() loop.
    Therefore, each application is a single threaded select() loop but there are multiple applications running within a single VM.
    I am seeing performance issues when two apps running within the same VM try to send messages to one another via TCP. When the two apps are running on different boxes one app can send about 10,000 messages a second to the other app. However, when the apps are running within the same VM ( localhost TCP connection ) I can only transfer about 1000 messages a second.
    Are 2 selectors running within the same VM a problem? Is it synchronized within the VM so that only one select can fire at a time?
    I am running on a dual proc RH3 box with plenty of memory.
    Any ideas?

    Works for me, though I'm trying on Windows. Test program below. I get >10,000 replies and responses per second over loopback with both "java SelectPingPong both" (one VM) and running client and server on separate VMs.
    Does this program get only 1000 messages/s on Linux? What VM version?
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class SelectPingPong
        private static final int MESSAGE_SIZE = 200;
        private String server_name;
        private Selector selector;
        private HashMap clients = new HashMap();
        static class Client
         ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
         long connect_time = System.currentTimeMillis();
         int number_of_messages;
        public SelectPingPong(int port, String server_name)
         throws IOException
         this.server_name = server_name;
         selector = Selector.open();
         ServerSocketChannel server_channel = ServerSocketChannel.open();
         server_channel.configureBlocking(false);
         server_channel.socket().bind(new InetSocketAddress(port));
         server_channel.register(selector, SelectionKey.OP_ACCEPT);
        public Socket connect(String host, int port)
         throws IOException
         SocketChannel channel = SocketChannel.open();
         Socket socket = channel.socket();
         socket.connect(new InetSocketAddress(host, port));
         configureSocket(socket);
         channel.configureBlocking(false);
         channel.register(selector, SelectionKey.OP_READ);
         clients.put(channel, new Client());
         return socket;
        private void configureSocket(Socket socket)
         throws IOException
         // Let's say we have a request-reply protocol with modest requirements
         socket.setReceiveBufferSize(1024);
         socket.setSendBufferSize(1024);
        public void mainLoop()
         while (true) {
             try {
              selector.select();
              for (Iterator iter = selector.selectedKeys().iterator(); iter.hasNext(); ) {
                  SelectionKey key = (SelectionKey) iter.next();
                  iter.remove();
                  if (!key.isValid())
                   continue;
                  if (key.isAcceptable())
                   acceptClient(key);
                  if (key.isReadable())
                   readFromClient(key);
             } catch (Exception e) {
              System.out.println(server_name + ": error in selector loop: " + e);
              e.printStackTrace();
        private void acceptClient(SelectionKey key)
         throws IOException
         ServerSocketChannel server_channel = (ServerSocketChannel) key.channel();
         if (server_channel == null)
             return;
         SocketChannel channel = server_channel.accept();
         if (channel == null)
             return;
         configureSocket(channel.socket());
         channel.configureBlocking(false);
         channel.register(selector, SelectionKey.OP_READ);
         clients.put(channel, new Client());
         System.out.println(server_name + ": got a new client; " +
                      clients.size() + " clients");
        private void readFromClient(SelectionKey key)
         throws IOException
         SocketChannel channel = (SocketChannel) key.channel();
         Client client = (Client) clients.get(channel);
         ByteBuffer buf = client.buf;
         int count;
         try {
             count = channel.read(buf);
         } catch (IOException e) {
             System.out.println(server_name + ": error reading, closing connection: " + e);
             clients.remove(channel);
             channel.close();
             return;
         if (count == -1) {
             clients.remove(channel);
             System.out.println(server_name + ": client disconnected; " +
                          clients.size() + " clients");
             channel.close();
             return;
         if (buf.position() == MESSAGE_SIZE) {
             if (++client.number_of_messages % 10000 == 0) {
              long now = System.currentTimeMillis();
              System.out.println(server_name + ": " + client.number_of_messages +
                           " messages in " + (now - client.connect_time) + " ms");
             buf.flip();
             // RFE write without blocking
             writeFully(channel, buf);
             buf.rewind();
        public static void writeFully(SocketChannel channel, ByteBuffer buf)
         throws IOException
         while (buf.remaining() != 0)
             channel.write(buf);
        private static void startClient()
         throws Exception
         SelectPingPong client = new SelectPingPong(6667, "client");
         Socket socket = client.connect("localhost", 6666);
         // Send initial message
         ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
         buf.put(new byte[MESSAGE_SIZE]);
         buf.flip();
         socket.getChannel().write(buf);
         client.mainLoop();
        public static void main(String args[])
         throws Exception
         if (args.length == 1 && args[0].equals("server")) {
             SelectPingPong server = new SelectPingPong(6666, "server");
             server.mainLoop();
         } else if (args.length == 1 && args[0].equals("client")) {
             startClient();
         } else if (args.length == 1 && args[0].equals("both")) {
             new Thread() { public void run() {
              try {
                  SelectPingPong server = new SelectPingPong(6666, "server");
                  server.mainLoop();
              } catch (Exception e) {
                  System.err.println("error in server");
             } }.start();
             startClient();
         } else {
             System.err.println("usage: SelectPingPong [client | server | both]");
    }

  • Multiple AD account in single domain for a single user

    Hi,
    Does OIM support multiple AD account in single domain for a single user?
    Scenario 1 :- If the multiple accounts already exists in AD can I pull it from AD to OIM for single user.
    Scenraio 2:- Does OIM allow creation of multiple account in AD for a single user, when requested from OIM?
    Thanks,

    yes. this is possible. OIM allow this.
    obviously the recon rule would be employee number or anything other than ' sAmAccontName' for target recon
    while provisioning make sure you are generating unique sAmAccountName and Common Name(if in same OU) for same user
    If you maintain above no issue having multiple account for a sing user in single domain

  • Can there be multiple ASM instances on single node?

    Hi,
    Can there be multiple ASM instances on single node?
    This one says No : http://www.freelists.org/archives/oracle-l/02-2008/msg00317.html
    And This one says Yes : http://www.databasejournal.com/features/oracle/article.php/3571371
    Thanks in advance.
    Thanks,
    Harsha
    Edited by: user498756 on Sep 11, 2008 2:23 AM

    ...that document doesnt say you cannot have multiple ASM instances on a node. It says "...ASM, +you only need one ASM+ instance for that computer, to manage the two database instances that use ASM."
    The fact that you only need one - and I cannot think of a good reason to have more than one - does not preclude the fact that you do seem to be able to have multiple ASM instances on a single node, each looking after its own set of disks and diskgroups.
    Again - I cannot think of a good reason to do so though!
    -Bob

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

Maybe you are looking for