XMLHTTP Question

Discussion in 'Javascript' started by bboyle18@gmail.com, Feb 22, 2005.

  1. Guest

    Hi,

    I've been looking into the possibility of using XMLHTTP for my
    enterprise application but I still have a question.

    When you send the request to the server, how does the server know how
    to handle the request? (i.e. how do I specify what method to call in my
    java servlet?)

    I'd appreciate any help on this.....I've only got a vaey basic
    knowledge of javascript and I am fluent in java.

    Thanks,

    B
     
    , Feb 22, 2005
    #1
    1. Advertising

  2. Treat it as you would any other URL.

    MK


    <> wrote in message
    news:...
    > Hi,
    >
    > I've been looking into the possibility of using XMLHTTP for my
    > enterprise application but I still have a question.
    >
    > When you send the request to the server, how does the server know how
    > to handle the request? (i.e. how do I specify what method to call in my
    > java servlet?)
    >
    > I'd appreciate any help on this.....I've only got a vaey basic
    > knowledge of javascript and I am fluent in java.
    >
    > Thanks,
    >
    > B
    >
     
    The Mighty Krell, Feb 22, 2005
    #2
    1. Advertising

  3. wrote:


    > I've been looking into the possibility of using XMLHTTP for my
    > enterprise application but I still have a question.
    >
    > When you send the request to the server, how does the server know how
    > to handle the request? (i.e. how do I specify what method to call in my
    > java servlet?)


    The request is simply a HTTP request, for instance a GET request, a
    servlet then knows how to treat a HTTP GET request and the servlet
    container I think provides an API to read the query string. Similar if a
    HTTP POST request is send I think a servlet has a method to process such
    requests and read out the body of the POST request.
    So on the client you need to decide about the URL of the servlet, about
    the HTTP request method (e.g. GET, POST etc) and then make the request e.g.
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('GET', 'servletURL', true);
    // now set request header if needed
    httpRequest.onreadystatechange = function () {
    // handle response here e.g.
    if (httpRequest.readyState == 4) {
    ..
    }
    };
    httpRequest.send(null);
    or
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('POST', 'servletURL', true);
    // now set request header if needed
    httpRequest.setRequestHeader('Content-Type',
    'application/x-www-form-urlencoded');
    httpRequest.onreadystatechange = function () {
    // handle response here e.g.
    if (httpRequest.readyState == 4) {
    ..
    }
    };
    httpRequest.send('a=1&b=2');

    A HTTP request doesn't call particular methods on the server, for that
    you would need to look into webservices, IE/Win with the webservice
    behavior and Mozilla with its webservice proxying API allow that but of
    course then you also need to implement a web service on the server.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 22, 2005
    #3
  4. Mr.Clean wrote:


    >>A HTTP request doesn't call particular methods on the server, for that
    >>you would need to look into webservices, IE/Win with the webservice
    >>behavior and Mozilla with its webservice proxying API allow that but of
    >>course then you also need to implement a web service on the server.
    >>

    >
    > On the other hand, XMLHTTP CAN call specific "functions", or verbs on
    > the server. Take, for instance the WebDAV implementation of Hotmail, in
    > the WebDAV specs, there are no mentions of BPROPPATCH, BDELETE, BMOVE,
    > verbs, etc. However, you can call them using XMLHTTP on their WebDAV
    > implementation.
    >


    Other protocols can certainly be implemented on top of HTTP or using
    HTTP as the transport, for instance a web service client and a web
    service server usually communicate by exchanging SOAP messages over HTTP
    and for instance the MS web service behavior is implemented with the
    help of Microsoft.XMLHTTP.

    But the original poster asked about XMLHTTP and servlet communication,
    that looks more like doing a certain HTTP request (e.g. GET, POST) on
    the client and processing that with the servlet as something that
    receives HTTP requests and sends a HTTP response.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 22, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. al

    XMLHTTP Question??

    al, Jun 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    382
    M. Zeeshan Mustafa
    Jun 26, 2004
  2. Dave H

    XMLHTTP question

    Dave H, Jan 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    450
    Steven Cheng[MSFT]
    Jan 13, 2006
  3. =?Utf-8?B?U2hhaHJpYXI=?=

    xmlhttp post question

    =?Utf-8?B?U2hhaHJpYXI=?=, Jul 1, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    9,787
    Martin Honnen
    Jul 1, 2006
  4. Shannon
    Replies:
    7
    Views:
    320
    Bob Barrows
    Sep 29, 2003
  5. yawnmoth

    Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

    yawnmoth, Nov 7, 2006, in forum: Javascript
    Replies:
    11
    Views:
    401
    Matt Kruse
    Nov 9, 2006
Loading...

Share This Page