inputstream

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

inputstream

synature "Brandon"
I hope you don't mind some questions from a newbie to Java and internet
stuff, though an old fan of REXX.

The following fragment works, but what ends up in my array is totally mixed
up, and not everything that was on the page is present.  The title line is
way down near the end of the list, and it seems just about every line is out
of order compared to what I get if I type in the URL in the browser address
bar.  This is from a servlet I'm running against the JRUN engine, and it
works fine, I don't really need the information in sequence to find out if
the words "No match" show up, but my next project does need to get the same
thing one would get from a browser...

When I tried to check for content length, I got a -1.
When I tried to use URLConnection, it said it wasn't accessible -- but if I
read the Java API right, URL.openConnection returns a URLConnection, doesn't
it?

Also, I thought I saw something somewhere that would allow me to fill a
Rexx object with the lines from a BufferedReader without having to loop
through it.

    Lookfor = Request.getParameter("lookfor")
    WhoIsRslt = 'http://rs.internic.net/cgi-bin/whois?'||Lookfor
    do
      WhoisURL = URL(WhoIsRslt)
      connect = WhoisURL.openConnection
      content = connect.getInputStream
      bR = BufferedReader(InputStreamReader(content))
      i = 1
      line = bR.readLine             loop while line \= null
        WhoisRslt[i] = Rexx(line)
        i = i+1
        say ' ' line
        line = bR.readLine
        end
      WhoIsRslt[0] = i

TIA
Brandon C. Smith
http://www.synature.com
[hidden email] or [hidden email]

BTW, FrontPage does a great job of importing from the web or from a local
dir full of HTML "help" files.  I sucked in the JDK Docs that way, so it was
only a few keystrokes in FrontPage to set up a search engine to help find
things.  More than a bit on the slow side doing the import, however.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

RE: inputstream

bob.keller
Hi Brandon,

It looks to me like some of the stuff on the referenced page are
graphics (GIF files) . A BufferedReader reads a character stream. The
GIF files would not be placed into the array. Is this what's missing ??

re: URLConnection - You might want to check out Dion's FAC page. I think
there was a URLConnection example there.  

Best Regards,

Bob <:-)>

> -----Original Message-----
> From: *@synature.com [SMTP:*@synature.com]
> Sent: Tuesday, May 05, 1998 1:21 PM
> To: NetRexx List
> Subject: inputstream
>
> I hope you don't mind some questions from a newbie to Java and
> internet
> stuff, though an old fan of REXX.
>
> The following fragment works, but what ends up in my array is totally
> mixed
> up, and not everything that was on the page is present.  The title
> line is
> way down near the end of the list, and it seems just about every line
> is out
> of order compared to what I get if I type in the URL in the browser
> address
> bar.  This is from a servlet I'm running against the JRUN engine, and
> it
> works fine, I don't really need the information in sequence to find
> out if
> the words "No match" show up, but my next project does need to get the
> same
> thing one would get from a browser...
>
> When I tried to check for content length, I got a -1.
> When I tried to use URLConnection, it said it wasn't accessible -- but
> if I
> read the Java API right, URL.openConnection returns a URLConnection,
> doesn't
> it?
>
> Also, I thought I saw something somewhere that would allow me to fill
> a
> Rexx object with the lines from a BufferedReader without having to
> loop
> through it.
>
>     Lookfor = Request.getParameter("lookfor")
>     WhoIsRslt = 'http://rs.internic.net/cgi-bin/whois?'||Lookfor
>     do
>       WhoisURL = URL(WhoIsRslt)
>       connect = WhoisURL.openConnection
>       content = connect.getInputStream
>       bR = BufferedReader(InputStreamReader(content))
>       i = 1
>       line = bR.readLine             loop while line \= null
>         WhoisRslt[i] = Rexx(line)
>         i = i+1
>         say ' ' line
>         line = bR.readLine
>         end
>       WhoIsRslt[0] = i
>
> TIA
> Brandon C. Smith
> http://www.synature.com
> [hidden email] or [hidden email]
>
> BTW, FrontPage does a great job of importing from the web or from a
> local
> dir full of HTML "help" files.  I sucked in the JDK Docs that way, so
> it was
> only a few keystrokes in FrontPage to set up a search engine to help
> find
> things.  More than a bit on the slow side doing the import, however.
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~
> To unsubscribe from this mailing list ( ibm-netrexx ), please send a
> note to
> [hidden email]
> with the following message in the body of the note
> unsubscribe ibm-netrexx <e-mail address>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

re: inputstream

synature "Brandon"
In reply to this post by synature "Brandon"
Bob,

Well, it seems to have been partly my fault.  I looked at the trace results
(when I figured out where they were...) and discovered that all 50 someodd
lines of the URL I connected to did get put into WhoIsRslt, in sequence,
with the [1] being the first line, [2] the second and so forth.

I see from looking again at loop over that the order is not garunteed, but I
would think I'd see all of them, rather than just a random collection from
the following:

    loop ndx over WhoIsRslt
      out.println(WhoIsRslt[ndx])
      end

What I got was lines 13, 2, 43, 12, 11, 7 or something like that.  I'm sure
I can fix it my explictly using the index I built, but shouldn't loop over
have found all the lines?  (I didn't need them in sequence this time)

Brandon

-----Original Message-----
From: [hidden email] <[hidden email]>
To: [hidden email] <[hidden email]>; [hidden email]
<[hidden email]>
Date: Wednesday, May 06, 1998 11:26 AM
Subject: RE: inputstream

>Hi Brandon,
>
>It looks to me like some of the stuff on the referenced page are
>graphics (GIF files) . A BufferedReader reads a character stream. The
>GIF files would not be placed into the array. Is this what's missing ??
>
>re: URLConnection - You might want to check out Dion's FAC page. I think
>there was a URLConnection example there.
>
>Best Regards,
>
>Bob <:-)>
>
>> -----Original Message-----
>> From: *@synature.com [SMTP:*@synature.com]
>> Sent: Tuesday, May 05, 1998 1:21 PM
>> To: NetRexx List
>> Subject: inputstream
>>
>> I hope you don't mind some questions from a newbie to Java and
>> internet
>> stuff, though an old fan of REXX.
>>
>> The following fragment works, but what ends up in my array is totally
>> mixed
>> up, and not everything that was on the page is present.  The title
>> line is
>> way down near the end of the list, and it seems just about every line
>> is out
>> of order compared to what I get if I type in the URL in the browser
>> address
>> bar.  This is from a servlet I'm running against the JRUN engine, and
>> it
>> works fine, I don't really need the information in sequence to find
>> out if
>> the words "No match" show up, but my next project does need to get the
>> same
>> thing one would get from a browser...
>>
>> When I tried to check for content length, I got a -1.
>> When I tried to use URLConnection, it said it wasn't accessible -- but
>> if I
>> read the Java API right, URL.openConnection returns a URLConnection,
>> doesn't
>> it?
>>
>> Also, I thought I saw something somewhere that would allow me to fill
>> a
>> Rexx object with the lines from a BufferedReader without having to
>> loop
>> through it.
>>
>>     Lookfor = Request.getParameter("lookfor")
>>     WhoIsRslt = 'http://rs.internic.net/cgi-bin/whois?'||Lookfor
>>     do
>>       WhoisURL = URL(WhoIsRslt)
>>       connect = WhoisURL.openConnection
>>       content = connect.getInputStream
>>       bR = BufferedReader(InputStreamReader(content))
>>       i = 1
>>       line = bR.readLine
>>       loop while line \= null
>>         WhoisRslt[i] = Rexx(line)
>>         i = i+1
>>         say ' ' line
>>         line = bR.readLine
>>         end
>>       WhoIsRslt[0] = i
>>
>> TIA
>> Brandon C. Smith
>> http://www.synature.com
>> [hidden email] or [hidden email]
>>
>> BTW, FrontPage does a great job of importing from the web or from a
>> local
>> dir full of HTML "help" files.  I sucked in the JDK Docs that way, so
>> it was
>> only a few keystrokes in FrontPage to set up a search engine to help
>> find
>> things.  More than a bit on the slow side doing the import, however.
>>
>>
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~
>> To unsubscribe from this mailing list ( ibm-netrexx ), please send a
>> note to
>> [hidden email]
>> with the following message in the body of the note
>> unsubscribe ibm-netrexx <e-mail address>
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

RE: inputstream

bob.keller
In reply to this post by synature "Brandon"
Hi Brandon,

Beats me. I would have thought 'loop over' would output all the lines.
However, I've never had a need to use loop over. You might want to ask
Mike about it.

Best Regards,

Bob <:-)>  

> -----Original Message-----
> From: *@synature.com [SMTP:*@synature.com]
> Sent: Wednesday, May 06, 1998 10:50 AM
> To: NetRexx List
> Subject: re: inputstream
>
> Bob,
>
> Well, it seems to have been partly my fault.  I looked at the trace
> results
> (when I figured out where they were...) and discovered that all 50
> someodd
> lines of the URL I connected to did get put into WhoIsRslt, in
> sequence,
> with the [1] being the first line, [2] the second and so forth.
>
> I see from looking again at loop over that the order is not garunteed,
> but I
> would think I'd see all of them, rather than just a random collection
> from
> the following:
>
>     loop ndx over WhoIsRslt
>       out.println(WhoIsRslt[ndx])
>       end
>
> What I got was lines 13, 2, 43, 12, 11, 7 or something like that.  I'm
> sure
> I can fix it my explictly using the index I built, but shouldn't loop
> over
> have found all the lines?  (I didn't need them in sequence this time)
>
> Brandon
>
> -----Original Message-----
> From: [hidden email] <[hidden email]>
> To: [hidden email] <[hidden email]>;
> [hidden email]
> <[hidden email]>
> Date: Wednesday, May 06, 1998 11:26 AM
> Subject: RE: inputstream
>
> >Hi Brandon,
> >
> >It looks to me like some of the stuff on the referenced page are
> >graphics (GIF files) . A BufferedReader reads a character stream. The
> >GIF files would not be placed into the array. Is this what's missing
> ??
> >
> >re: URLConnection - You might want to check out Dion's FAC page. I
> think
> >there was a URLConnection example there.
> >
> >Best Regards,
> >
> >Bob <:-)>
> >
> >> -----Original Message-----
> >> From: *@synature.com [SMTP:*@synature.com]
> >> Sent: Tuesday, May 05, 1998 1:21 PM
> >> To: NetRexx List
> >> Subject: inputstream
> >>
> >> I hope you don't mind some questions from a newbie to Java and
> >> internet
> >> stuff, though an old fan of REXX.
> >>
> >> The following fragment works, but what ends up in my array is
> totally
> >> mixed
> >> up, and not everything that was on the page is present.  The title
> >> line is
> >> way down near the end of the list, and it seems just about every
> line
> >> is out
> >> of order compared to what I get if I type in the URL in the browser
> >> address
> >> bar.  This is from a servlet I'm running against the JRUN engine,
> and
> >> it
> >> works fine, I don't really need the information in sequence to find
> >> out if
> >> the words "No match" show up, but my next project does need to get
> the
> >> same
> >> thing one would get from a browser...
> >>
> >> When I tried to check for content length, I got a -1.
> >> When I tried to use URLConnection, it said it wasn't accessible --
> but
> >> if I
> >> read the Java API right, URL.openConnection returns a
> URLConnection,
> >> doesn't
> >> it?
> >>
> >> Also, I thought I saw something somewhere that would allow me to
> fill
> >> a
> >> Rexx object with the lines from a BufferedReader without having to
> >> loop
> >> through it.
> >>
> >>     Lookfor = Request.getParameter("lookfor")
> >>     WhoIsRslt = 'http://rs.internic.net/cgi-bin/whois?'||Lookfor
> >>     do
> >>       WhoisURL = URL(WhoIsRslt)
> >>       connect = WhoisURL.openConnection
> >>       content = connect.getInputStream
> >>       bR = BufferedReader(InputStreamReader(content))
> >>       i = 1
> >>       line = bR.readLine
> >>       loop while line \= null
> >>         WhoisRslt[i] = Rexx(line)
> >>         i = i+1
> >>         say ' ' line
> >>         line = bR.readLine
> >>         end
> >>       WhoIsRslt[0] = i
> >>
> >> TIA
> >> Brandon C. Smith
> >> http://www.synature.com
> >> [hidden email] or [hidden email]
> >>
> >> BTW, FrontPage does a great job of importing from the web or from a
> >> local
> >> dir full of HTML "help" files.  I sucked in the JDK Docs that way,
> so
> >> it was
> >> only a few keystrokes in FrontPage to set up a search engine to
> help
> >> find
> >> things.  More than a bit on the slow side doing the import,
> however.
> >>
> >>
> >>
> >>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> ~~~~~~~
> >> To unsubscribe from this mailing list ( ibm-netrexx ), please send
> a
> >> note to
> >> [hidden email]
> >> with the following message in the body of the note
> >> unsubscribe ibm-netrexx <e-mail address>
> >
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~
> To unsubscribe from this mailing list ( ibm-netrexx ), please send a
> note to
> [hidden email]
> with the following message in the body of the note
> unsubscribe ibm-netrexx <e-mail address>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

RE: inputstream

Mike Cowlishaw-2
In reply to this post by synature "Brandon"
Yes, 'loop over' should return all lines.   Brandon, could you send me a small
testcase that shows the problem?

Thanks.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow, IBM UK Laboratories
mailto:[hidden email]   [http://www2.hursley.ibm.com]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>