HTTP connection between two java programs(classes)

Hello everyone,
here's my question:
I need to create two java applications(just two console apps) that can exchange data with each other only via the HTTP protocol. I guess I have to use the URLConnection class. How can I do that? Basically I need to make one app work as a server and the other one just as a simple client.
thanks in advance

URLConnection.
As for the server, you could use a Servlet. There are Java libraries that act as a servlet container without requiring installation. Jetty comes to mind.

Similar Messages

  • Difference between a java program and a java class

    Hi there,
    What is the difference between a java program and a java class?

    HI,
    A java class is an object - described in a .class file - which has been given properties and behaviours and which can be instantiated in a program.
    A java program( application ) consists of at least one class (one of which must be declared public) and which executes its main() method ( of the public class ) when it is started.
    Every program is a class but not every class is a program.
    Examples:
    A java program
    // this simple program will print out the first command line argument you put
    // in after calling : java ScreenWriter "arguments"
    class ScreenWriter
    public static void main( String [] args )
    if( args.length > 0 )
    System.out.println( args[0] );
    A java class
    //the Math class is already defined in the java.lang package
    //and contains a constant for PI
    //So I can include the Math class with the PI constant in my simple program
    //and now I have a program that involves my ScreenWriter class and the Math class too.
    class ScreenWriter
    public static void main( String [] args )
    if( args.length > 0 )
    System.out.println( args[0] );
    System.out.println( "The value of Pi is: " + Math.PI );
    When you see package and import declarations at the start of a program they are there to ensure the compiler knows which classes are used in the program.
    Hope that helps,
    Terry

  • Connection between two views

    Hi Experts,
    Please give me some inputs related to connection between two views ???

    Hi
    http://help.sap.com/saphelp_46c/helpdata/de/39/7dfeaaac6011d189c60000e829fbbd/frameset.htm
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2cceb190-0201-0010-be88-acdbeb2ad65f
    How to acces context of view B from view A without using the controller?
    http://help.sap.com/saphelp_nw04s/helpdata/en/7b/67eaa71bdf2645be6e811eee980a04/frameset.htm

  • SNC connection between two SAProuter

    Hi Guys,
    Please give me the procedure to establish the SNC connectivity between two SAProuter.
    Thanks and Regards,
    Atul

    Hi Atul,
    have tried the SDN Search Function with "snc AND saprouter"? It gave me this Links:
    SNC User Guide:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/snc user guide.pdf
    Configure Secure Network Communication SNC:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/configure secure network communication snc.pdf
    Regards
    Gregor

  • How to make HTTP connection between a midlet and a php server?

    As the title above, can anyone share how to make a HTTP connection between those 2? J2ME and PHP. Thanks a lot!

    Can you be a little more specific on what you really want.
    When i started doing j2me application, i was required to be able to comunicate to a oracle client database, and my first though was using PHP based pages to comunicate and do the query. Later they would just generate the answer and get it on the cellphone. You can communicate with a PHP server via either GET or POST. I'd choose POST as is more secure IMO.
    Here are quite a good ammount of examples of how you can do it
    http://www.java2s.com/Code/Java/J2ME/Networks.htm
    They aren't PHP based examples, but you have can an idea of how it can be done

  • Can two java program write to the same port by fetching data from different

    can two java program write to the same port by fetching data from different ports, if yes is thing possible for a 3rd program to get all data (is there any data loss or collision)
    how is this possible

    can two java program write to the same port by fetching data from different portsTwo java clients can connect to the same server port and they can both write to it. However the server will see the connections as two separate accepted sockets.

  • Setting up a https connection between SAP CRM and genesys gplus adapter

    Hello All-
    We are integrating SAP CRM with genesys mysap gplus adapter. We are struck in setting up a https connection between sap and gplus adapter.
    Can anyone here help me out in this like how to get the SSL Protocol, keystore, keystore password,truststore and truststore password.
    Information abt Adapters server certificate. Do we need to configure the adapter for the proxy also?
    Any additional comment will help. Thanks in advance!

    Hello Vinod,
    Please refer the following OSS notes 564085.
    Please reward if helpful.
    regards,
    Muralidhar Prasad.C

  • How to make a connection between two wireless sensor networks of different groups through gateway?did any external device or coding is needed?

    my objective is to make a connection between two wireless sensor networks....i am using two nodes and one gateway for each wireless sensor network.....what is the procedure for connecting these two wireless sensor networks of different groups

    my objective is to make a connection between two wireless sensor networks....i am using two nodes and one gateway for each wireless sensor network.....what is the procedure for connecting these two wireless sensor networks of different groups

  • How to check the Network Connectivity between two systems.

    Hello Everyone,
    Please let me know different ways to check the network connectivity between two systems other than ping/traceroute commands.
    Thank You.
    Edited by: 835435 on Jan 20, 2012 11:43 AM
    Edited by: 835435 on Jan 20, 2012 11:44 AM

    Use snoop.
    snoop -d <nic> - will give requests and replies coming/going in/out of the specified NIC.
    snoop -d <nic> <MAC address of the target host> - will give requests coming from the required host.

  • RFC connection between two SAP systems (with SAP router)

    Hi!
    I would like to set up a RFC-connection from SAP Solution Manager to other SAP system.
    The network connection between the servers is VPN.
    How can I set up this RFC-connection, if my connection between two SAP systems looks as follows,
    (I use the following SAP routers)?
    my server  --> customer
    my server --> internal SAP Router server xy (10.101....) --> SAP Router customer 2 (10.1....) --> SAP System customer (134....)
    Back-way
    SAP Systeme customer --> SAP Router customer (134.1....) --> internal SAP router (212.6....) --> my server
    How can I set up this RFC-connection, if my connection between two SAP systems looks as follows,
    (I use the following SAP routers)?
    something like:
    /H/10.101..../S/sapdp99/H/10.1.4..../S/sapdp99/H/134...
    Thank you very much!
    regards
    Thom

    Same answer as in the other forum where you cross posted....

  • The connection between two Tuxedo machines

    We want to locate our servers(services) onto different machines, we want to know
    :whether the connection,between two machines, is built up at the first time the
    servers booted and kept persistently connectted, or just build up the connection
    when there comes a request.

    Remote machines connect to one another lazily. If you have machines A
    (master), B and C, then B and C do not connect until a request is made
    between B and C. All machines connect to the master at boot time.
    roopesh wrote:
    >
    The connection is persistent and is not request based.
    The machines communicate using BRIDGE.The DBBL which runs
    on the primary master machines keep doing sanity checks
    and health of BBL at all the machines connected and if
    any BBL does not respond for the specified time(set by
    DBBLWAIT) in RESOURCES section.then that machine gets partitioned by DBBL.
    for more info you can read tuxedo documentation.
    Thanks
    Roopesh
    "YANG YI" <[email protected]> wrote:
    We want to locate our servers(services) onto different machines, we want
    to know
    :whether the connection,between two machines, is built up at the first
    time the
    servers booted and kept persistently connectted, or just build up the
    connection
    when there comes a request.

  • Gprs connection between two mobile phones

    Hi
    is it possible to make a gprs connection between two mobile phones without a server(pc...)? when the answer "yes" please give me an exapmle...

    I'm not sure, I'm just connecting some facts. I'm talking about Siemens S55. It has implemented sockets (both client sockets and server sockets). The phone, when connected via GPRS has IP address (Siemens' netmonitor reports it..). But i've never tried to use server-socket on my mobile.
    So it seems that it is in fact possible on some handsets. (AFAIK nokia 6610 and similar does not support sockets...)

  • Connection between two clients

    Hi,
    I want to get some guidance on connection between two clients. Suppose I need to connect client 500 with client 900 in the same system without changing the logical names.
    Thanks & Regards
    Nabarun

    Nabarun -
    It almost sounds as if you just want an RFC to go from one client to the other.  RFCs (SM59) are not client dependant so you can create one in any client.  You can create one with the system name and point it to the client number using a specific user and password.  I would recommend for security it be a communications user and not a dialog user depending on what you will be sending between the clients.  However, the user will need the correct permissions and again, depending on what you are trying to accomplish, it may have to be a DIAG user although I would be wary.  Then create a 2nd RFC pointing back to the other client.  For example...
    RFC 1
    System Name = <System>
    Client = 500
    User = <userid in clnt 500>
    RFC 2
    System Name = <System>
    Client = 900
    User = <userid in clnt 900>
    Then when you are in client 500, there is a path/connection to client 900 via that clients ID and password and vice versa using the appropriate RFC.  Again, with out more info on what you are attempting, this may be your solution.  Hope this helps.  Good luck
    Regards,
    Zecher

  • How to configure connectivity between two vm linux hosts

    Hello All,
    i have installed vm workstation with two RHEL4 linux installation.
    Node 1:RHEL4
    Node 2:RHEL4
    i have configured 2 ethernet cards am able to ping in a host but not each other.
    i have tried to ping from Node 1 to Node 2 am getting icmp_seq=0 Destination Host Unreachable .....
    kindly suggest how to configure connectivity between two host permanently.please explain with example if possible. or suggest any link.
    thanks,
    Mike.

    1003614 wrote:
    thanks for quick reply ....Oracle vm workstation 4.2 am using.
    ... then your post is now moved to the appropriate forum space for your question (Oracle VM for x86).

  • How to submit a HTTP Request from a Java Program

    I am working on an web based application where in I need to submit the HttpRequest through a Java Program and not through browser. Moreover my intent is just to submit the HttpRequest. I donot want to wait for the response to come back. I have used the URL Connection class to do the same and I am trying to post this request. The contents of the methods that I am using are as below:-
    public void doPost(URL url, String inputXMLString) throws IOException
              //Create URLConnection based on the passed URL
              URLConnection connection = url.openConnection();
              connection.setDoOutput(true);
              connection.setDoInput(false);
              connection.setUseCaches(false);
              connection.setAllowUserInteraction(false);
              connection.setRequestProperty("Content-type", "application/x-www-form-
    urlencoded");
              //Get the Connection's output stream and write the request to it.
              PrintWriter out = new PrintWriter(connection.getOutputStream());
              out.print("&ena-request-input=" + URLEncoder.encode(inputXMLString));
              out.flush();
              out.close();
    Call to the above method does not invoke the URL I am intending to submit the request at.
    Can anybody give me the clue....................................................?

    I agree with the advice to launch a new thread to read and ignore the response. I don't think you should have to do it to make it work, but it's worth trying for two reasons:
    1) If it turns out it does make it work, well, then either you can leave it that way, or use that as a clue to help figure out how to make it work the way you want.
    2) There may be an error message there that will give you an idea why it's not working.
    When you say it's not invoking the servlet, what does that mean, and how do you know? Is it just that the final results aren't being seen? Put a bunch of logging statements in the servlet. It could be that it's getting hit, but you're corrupting the string you're building, or sending some extra junk that it can't handle. Spit out a log statement from the start of doPost, to see if it's even getting there. Then log the parameter. Enclose the output in quotes or braces or something to make sure there's not extra junk. I've had XML docs not parse because there was a blank line at the beginning.
    If it works in the browser but not from your standalone app, then you need to have the servlet tell what difference it sees in the two cases. Print out headers, other params, everything you can think of.
    Re-read the docs for URL, HttpURL, whatever, to make sure you're doing all the right steps in the right order. Make a servlet that just takes a single, simple param=value via POST and see if you can get that to work.

Maybe you are looking for

  • Replication of CUSTOMER from ECC to CRM

    Hi CRM Guru Is that anyway to download the partner function (sold-to, ship-to, payer, bill-to, employee) in the customer sales area data from ECC to CRM (created as BP relationship in CRM) in the INITIAL LOAD? For example: Customer in ECC 100000000 h

  • Media Encoder CS4 No Error No File (Says It's Created, but It Isn't)

    I have tried repeatedly today to encode an QuickTime container to P2 format, and while Adobe Media Encoder CS4 appears to load correctly, do the conversion, and confirm the file creation, I can not find the file that was supposed to be created. There

  • Mail adapter with number of recivers

    Hi Can any1 tell me how to use the reciver mail adapter to send mail to number of recepients ? thx,Shai

  • Selection in query

    HI Gurus, I have a problem. I am doing AP aging report. I want to display a field called status ( net due date - last date). Last date should be given as a variable in selection screen, but the problem is last date is not in DSO on which the report i

  • Can't pull up skin in Firefox

    Using RoboHelp 7 (plus updates) and pure HTML for the application's GUI from which the help pages are called. The good folks over at Google groups identified this problem almost a year ago: http://groups.google.com/group/macromedia.robohelp.webhelp/b