Send a GET request then get results.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Send a GET request then get results.

  1. #1
    Eric Renken Guest

    Send a GET request then get results.

    I am trying to create an applet that communicates with the server. I'm not
    sure if I am going to have to go to the socket level. I would rather use
    this code:

    try
    {
    url = new URL(getDocumentBase(), strCallPage);
    input = url.openStream();
    }
    catch (MalformedURLException e)
    {
    System.out.println("bad url");
    return;
    }
    catch (IOException e)
    {
    System.out.println("error opening stream");
    return;
    }

    In this code "strCallPage" has all the information for the GET request. The
    problem is when I call this it gives me a file not found. When I don't
    include the "?ID=sda" to the ASP page name it works fine. The problem is it
    is looking for a file with the "?ID=sda" as part of the file name. I could
    probably get around this by using cookies, but I would prefer not to have
    to. I want to use 1 page as a general function page, and the results
    populate fields in the Applet. If I have to use cookies how can I create
    cookies using Java in my Applet?

    Thanks,

    Eric Renken



  2. #2
    infugax Guest

    Re: Send a GET request then get results.


    "Eric Renken" <EricRenken@email.msn.com> wrote:
    [...]
    >The problem is when I call this it gives me a file not found. When I don't
    >include the "?ID=sda" to the ASP page name it works fine.


    It's the server'S job to look for the requested file (and to respond with
    a
    file not found error). If the file you requested could not be found, it's
    a
    server problem, not a problem of your applet (if your url is realy correct).

    try to load the url with your browser and look whether you get the same
    error.


    good luck wishes
    infugax

  3. #3
    Eric Renken Guest

    Re: Send a GET request then get results.

    When I include the HTTP path I get this error:

    com.ms.security.SecurityExceptionEx[Host]: cannot access "ntserver":80

    When I do this in the browser it works fine:

    http://ntserver/JavaTest/SendTo/ABKItems.htm

    and when I do this from my browser it works fine:

    http://ntserver/JavaTest/SendTo/ABKI...0&OWNERID=1020

    Which is in the same directory as my Java applet so if I don't include the
    "?C=100&OWNERID=1020" it works fine. It is trying to open it as a file with
    that as the entire file name.

    After I do:

    url = new URL(getDocumentBase(), strCallPage);

    "url" shows that the protocol="file" host="" port=-1
    Can I change the protocol to HTTP? That seems to be the problem.

    Thanks,

    Eric Renken


    "infugax" <infugax@gmx.net> wrote in message
    news:3940fa0c$1@news.devx.com...
    >
    > "Eric Renken" <EricRenken@email.msn.com> wrote:
    > [...]
    > >The problem is when I call this it gives me a file not found. When I

    don't
    > >include the "?ID=sda" to the ASP page name it works fine.

    >
    > It's the server'S job to look for the requested file (and to respond with
    > a
    > file not found error). If the file you requested could not be found, it's
    > a
    > server problem, not a problem of your applet (if your url is realy

    correct).
    >
    > try to load the url with your browser and look whether you get the same
    > error.
    >
    >
    > good luck wishes
    > infugax




  4. #4
    infugax Guest

    Re: Send a GET request then get results.


    >After I do:
    >
    > url = new URL(getDocumentBase(), strCallPage);
    >
    >"url" shows that the protocol="file" host="" port=-1
    >Can I change the protocol to HTTP? That seems to be the problem.


    did you test your applet by visiting its webpage though the net or by
    loading the page locally?

    URL(URL, String) uses any information of the passed URL that not
    available from the String. So the protocol of that passed URL should
    be "http" and its server should be "ntserver".
    I would check the result of getDocumentBase().toString() and/or the
    result of the same method invoked on your above created url.
    That will probably look like "file://c:/JavaTest/" if you tried to test your
    applet by loading the page locally. Of course, your browser does not
    allow your applet to use the "file://" protocol: it's a (dummy) protocol
    to access your local drives.


    best regards
    infugax


  5. #5
    Eric Renken Guest

    Re: Send a GET request then get results.

    Thank you for the info. Your explanation here did it for me. I tested it
    using the URL and not loading it using the path and it worked.

    Thanks again,

    Eric

    "infugax" <infugax@gmx.net> wrote in message
    news:394297d5$1@news.devx.com...
    >
    > >After I do:
    > >
    > > url = new URL(getDocumentBase(), strCallPage);
    > >
    > >"url" shows that the protocol="file" host="" port=-1
    > >Can I change the protocol to HTTP? That seems to be the problem.

    >
    > did you test your applet by visiting its webpage though the net or by
    > loading the page locally?
    >
    > URL(URL, String) uses any information of the passed URL that not
    > available from the String. So the protocol of that passed URL should
    > be "http" and its server should be "ntserver".
    > I would check the result of getDocumentBase().toString() and/or the
    > result of the same method invoked on your above created url.
    > That will probably look like "file://c:/JavaTest/" if you tried to test

    your
    > applet by loading the page locally. Of course, your browser does not
    > allow your applet to use the "file://" protocol: it's a (dummy) protocol
    > to access your local drives.
    >
    >
    > best regards
    > infugax
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center