Reading an HTML stream

Hi,
I would like to invoke a web page through my java program, receive the output (what the server sends back... i.e. html) and store in some variable. More specifically, I have an ASP page that writes only xml back to the client. I want to invoke this ASP page from my java program (which has no GUI) and then parse the returned XML accordingly. Is this possible? If so, can anyone point me in the right direction?
TIA!
-Mike

Use URLConnection and it's easy to do.

Similar Messages

  • How to read the html source code of a webpage.

    How can I read the html source code of a webpage with a java application?
    Is there a good idea?

    >
    How can I read the html source code of a webpage
    with a java application?
    Is there a good idea?
    I don't know if this is a good idea, but it works.
    1) Use a URL to obtain the document's location
    2) Use a URLConnection to open a connection between your computer and the
    document server
    3) Connect to the server
    4) Get the InputStream of said connection
    5) Associate the Input Stream with a Buffered Input Stream
    At this point you can use a loop to read lines from the BufferedInput Stream and append them to a TextArea or other suitable text component.

  • Error while executing SSIS package - Error: 4014, Severity:20, State: 11. A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 109, output error: 0)

    Hi,
    We are getting the following error when running our SSIS packages on Microsoft SQL Server 2012 R2 on Windows Server 2008 R2 SP1:
    Error: 4014, Severity:20, State: 11.   A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 109, output error: 0)
    SQL Server Data Tools and SQL Server Database Engine reside on the same server.
    We tried the following:
    Disabling TCP Chimney Offload
    Installed Windows Server 2008 SP1
    Splitting our SSIS code into multiple steps so it is not all one large continuous operation
    The error occurs during a BulkDataLoad task.
    Other options we are investigating with the engineering team (out-sourced, so delayed responses):
    Firewall configurations (everything is local, so this should not make a difference)
    Disabling the anti-virus scanner
    Are there other things we can try?
    Any insight is greatly appreciated.
    Thanks!

    Hi HenryKwan,
    Based on the current information, the issue can be caused by many reasons. Please refer to the following tips:
    Install the latest hotfix based on your SQL Server version. Ps: there is no SQL Server 2012 R2 version.
    Change the MaxConcurrentExecutables property from -1 to another one based on the MAXDOP. For example, 8.
    Set "RetainSameConnection" Property to FALSE on the all the connection managers.
    Reference:
    https://connect.microsoft.com/SQLServer/feedback/details/774370/ssis-packages-abort-with-unexpected-termination-message
    If the issue is still existed, as Jakub suggested, please provide us more information about this issue.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to read the HTML code from a webpage

    Hi, I want to be able to read the HTML code of a web page
    In order to extract some info from some pages.
    How can I do that?
    is it using cl_http_client ? I played with that class a bit, but wih no sucess to what I need...

    Hi RagnaRock,
    You can use the following form, hope it helps you.
    Regards,
    Ozcan.
    form get_data_from_url using iv_url type clike changing iv_data type string.
    DATA: HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT .
      clear  iv_data.
      CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
           EXPORTING
            URL                = IV_URL
    *          PROXY_HOST         = '10.1.1.1'
    *          PROXY_SERVICE      = '1234'
    *       SSL_ID             =
           IMPORTING
             CLIENT             = HTTP_CLIENT
           EXCEPTIONS
             ARGUMENT_NOT_FOUND = 1
             PLUGIN_NOT_ACTIVE  = 2
             INTERNAL_ERROR     = 3
             OTHERS             = 4.
      CHECK SY-SUBRC = 0.
      CALL METHOD HTTP_CLIENT->SEND
        EXCEPTIONS
          HTTP_COMMUNICATION_FAILURE = 1
          HTTP_INVALID_STATE         = 2.
      CHECK SY-SUBRC = 0.
      CALL METHOD HTTP_CLIENT->RECEIVE
        EXCEPTIONS
          HTTP_COMMUNICATION_FAILURE = 1
          HTTP_INVALID_STATE         = 2
          HTTP_PROCESSING_FAILED     = 3.
      CHECK SY-SUBRC = 0.
      iv_data = HTTP_CLIENT->RESPONSE->GET_CDATA( ).
    endform.                    "get_data_from_url
    Edited by: Ozcan Gurdal on Aug 11, 2010 4:07 PM

  • Display HTML stream in Web Dynpro application

    Hello,
    Sorry, I am new to the Web Dynpro environment, so this might seem like a stupid question.
    How can I display streaming HTML content in a Web Dynpro application.  The IFrame element only seems to allow you to point to a URL.  In this case, I am receiving an HTML stream back from an R/3 system via a BAPI call.
    Thanks very much.

    Hi
    As per your question, I understand that HTML output is getting generated through a R3- Bapi call. Fine, create a model with the data binding to the context to some text view. Simply create view with the relevant UI element through which you want to exhibit the data and call the R3 call through your model. instead of a HTML output, you will get your data in the view.
    you may not get the exact format / style of the html output.
    Otherwise, directly HTML content cannot be shown in webdynpro. You need to have some UI control to take its content.
    Or else, you can go in for j2ee stack and end up with a java based appl, use a simple jsp and get the output!
    if you have any specific queries do let us know
    hope this helps you
    thanks

  • Reading System out stream ?

    Hi,
    I don't know whether I am asking a stupid question or not . But my problem is that in my thousand lines of code i wrote number of System.out.println(".....") statements to describe various situations / state of program which write those strings of messages to standard output i.e console . Here at this point of situation I was wondering that is there a possible way that i could read System.out stream by concurrently running a thread who could look on this stream and could redirect it to a file where i want. By achieving this I don't need to go at every piece of code where i have written System.out.println(".....") and change it to get desired result.
    If it is possible , please let me know ?
    Thanks in advance,
    Hemant.

    A suggestion - next time, set up a boolean - call it maybe "debugFlag" and check it befor a system.out write. That way all that's needed is to reset the flag and recompile when it goes to "production".
    And then the other possibility is to use your editor and do some global change all in your code.

  • Read Servlet output stream

    how can i read servlet output stream

    i m using SAX to create an XML.
    I set result to "Servlet Output Stream" as shown below :->
    SAXTransformerFactory saxTF = SAXTransformerFactory.newInstance();
    TransformerHandler th = saxTF.newTransformerHandler();
    Transformer t = th.getTransformer();
    StreamResult stRes = new StreamResult(res.getOutputStream());
    th.setResult(stRes);
    th.startDocument();
    what i want to wright the same xml result in file at the same time(parallel y).

  • How to read an html file and replace a text using text_io

    hi,
    i want ro read an html file using text_io and replace a particular text with a new text
    eg: i want to replace a text called "data.js" and with "maps.js"
    how do i do this?

    You have to write your own code to do that. TEXT_IO is just a low level text file interface.
    You need to read in all the text, save it in some internal format (array of varchar2's maybe or in the DB) and then perform a search on the text you have read in, find out where the instances of "data.js" are located and substitute them with "maps.js" After that you need to write to a new file and delete the old one. There is no way to search and replace inside the existing file (what's sometimes referred to as 'in-place' substitution).
    See the help section called About the TEXT_IO package for an overview of how it works and some code examples.

  • Opening a browser to read an HTML file

    I need to be able to open a browser to read an html file that I can specify. The HTML file probably, but not necessarily, reside on the same machine as the app.
    I've looked through the APIs amd can't seem to figure this one out.
    Any help would be appreciated.

    Do you really need to open a browser, or are you just wanting to bring the text of an HTML doc into your program? If by some chance it's the latter, then that can be done pretty easily with URLConnection.getInputStream()...

  • I want to read a HTML document from internet

    Is it i should use javax.swing.text.html.HTMLDocument?

    Is it i should use javax.swing.text.html.HTMLDocument?What do the docs for that class say? Does it have methods for reading an HTML document from the internet?

  • Here's a dumb ? I'm trying to find out how I can print from my ipad. I read about air streaming printers. so is a wireless printer considered an air streaming printer. i have 1 pc, my mac

    here's a dumb ? I'm trying to find out how I can print from my ipad. I read about air streaming printers. so is a wireless printer considered an air streaming printer. i have 1 pc, my mac

    If you already have a printer, you can probable use a program like, printopia to let your mac share your printer with the iOS device like your iPad. The catch being your computer has to be on, and not asleep, for the printer to work with your iPad.
    If you need a printer that is airprint ready, you can find a list on AirPrint, wireless printing straight from your iPad. Check out the bottom of the page where it says works with airprint enabled printers. There are even links on the page so you can buy the printers right from Apple's website.

  • Problem while reading clob with Stream

    Hi
    I'm trying to read some clob data from database using Streams.
    Here is the simple code of what I'm trying to do
    Environment *env =  Environment::createEnvironment("JA16SJIS", "OCCIUTF16", Environment::THREADED_MUTEXED);
    Connection *conn = env->createConnection("user", "pass", "database");
    Statement stmt = conn->createStatement("SELECT FROM TABLE");
    ResultSet *rs = stmt->executeQuery();
    char buffer[65536];
    rs->setCharacterStreamMode(3, 65536);
    while (rs->next ())
         Stream* stream = rs->getStream (3);
         int r = stream->readBuffer(buffer, 65536);
         rs->closeStream(stream);
            ..I call setCharacterStreamMode method for the right column and than iterate through recordset. But if i just iterate through the recordset without reading stream data, the second call of rs->next() crash the program.
    Any idea what this could be, and why the application crash if I don't read the entire stream? Is there some catch with Streams?

    Thx, I just thought that there is some other way to avoid the whole stream reading.
    Thx anyway

  • Searching the HTML Stream

    I need to search NOT WELL FORMATTED HTML for data extraction. Are there any stream searching library in java.

    Hi,
    Anil_Pathak wrote:
    I need to search NOT WELL FORMATTED HTML for data extraction. Are there any stream searching library in java.If the "NOT WELL FORMATTED" is not too bad, one could extend HTMLDocument and overwrite HTMLDocument.HTMLReader. There the parser callback is involved an so one can overwrite the handleXY methods to get the tags and the text out of the HTML.
    Example
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.text.html.parser.*;
    class ParseHTML {
      ParseHTML(String myHTML) {
        HTMLEditorKit kit = new HTMLEditorKit();
        try {
          kit.read(new StringReader(myHTML), new MyHTMLDocument(), 0);
        } catch(IOException e) {
          e.printStackTrace();
        } catch(BadLocationException e) {
          e.printStackTrace();
      public static void main(String[] args){
        String myHTML = "<TITLE>Test</TITLE>" +
                                   "<P>Paragraph <B>test</B> with bold" +
                                   "<TABLE border=1>" +
                                   "<TR><TD>Tablecell1.1</TD>" +
                                   "<TD>Tablecell1.2</TD>" +
                                   "<HR>" +
                                   "<IMG src=\"duke.gif\">" +
                                   "<P>End";
        ParseHTML phtml = new ParseHTML(myHTML);
      class MyHTMLDocument extends HTMLDocument {
        MyHTMLDocument() {
          super();
        public HTMLEditorKit.ParserCallback getReader(int pos) {
          return new HTMLReader(pos);
        public HTMLEditorKit.ParserCallback getReader(int pos, int popDepth, int pushDepth, HTML.Tag insertTag) {
          return new HTMLReader(pos, popDepth, pushDepth, insertTag);
        class HTMLReader extends HTMLDocument.HTMLReader {
          HTMLReader(int pos) {
            super(pos);
          HTMLReader(int pos, int popDepth, int pushDepth, HTML.Tag insertTag) {
            super(pos, popDepth, pushDepth, insertTag);
          public void handleText(char[] data, int pos) {
            System.out.println("text: " + new String(data));
            super.handleText(data, pos);
          public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
            System.out.println("simple tag: " + t + " Attributes: " + a);
            super.handleSimpleTag(t, a, pos);
          public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
            System.out.println("start tag: " + t + " Attributes: " + a);
            super.handleStartTag(t, a, pos);
          public void handleEndTag(HTML.Tag t, int pos) {
            System.out.println("end tag: " + t);
            super.handleEndTag(t, pos);
    }greetings
    Axel

  • Reading in HTML file then writing to file - losing formatting.

    I am reading in a HTML file using a Buffered Reader then writing it to a file. However when i write it to a file using
    out = new PrintWriter(new BufferedWriter(new FileWriter(path, true)));
    out.write(content);
    out.flush();
    i seem to lose all carriage returns and find that the whole html is on one single line with the only noticable formatting being the spaces between the html tags.
    How can i stop it losing carriage returns?

    You only showed the part where you are writing it out.
    Does your reader code look like this:
      BufferedReader r = ...
      String content = "";
      while (true) {
        String line = r.readLine();
        if (line == null) break;
        content += line;
      }If it does, the problem lies here, as doing a readLine removes the line terminator. Soooo....
        content += line + "\n";Of course, to be most efficient and good, don't use String concatenation, use a StringBuffer (though it should be noted that when I decompiled this test code, suns compiler did indeed use a StringBuffer).
    When you print, use the PrintWriter methods print and priintln as they don't throw exceptions.

  • Read external XML stream into a field

    Hello all -
    I have been trying to get this working for a week now and still no luck. It seems like it's possible to find field values to external XML file, but Acrobat tries to parse the XML and be smart about it.
    I have a custom form logic that needs to read an XML file from a URL and assign the stream to a form field that can later be accessed via FormField.rawValue.
    The XML is rather basic - something like
    1
    2
    3
    4
    I tried the xfa.connectionSet to no avail. I am now trying to bring in that value with SOAP, but have been reading that it might give prompts in Reader.
    Can I simply read an external URL and assign the server response to a variable or a field ?
    My apologies for the super-basic question!!
    Thanks in advance!
    Frank

    I get the following error, probably means the file referenced is not available...
    SQL Error: ORA-22806: not an object or REF
    22806. 00000 - "not an object or REF"
    *Cause:    An attempt was made to extract an attribute from an item that is
    neither an object nor a REF.
    *Action:   Use an object type or REF type item and retry the operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • How to Save a text file in the server?

    hello i just want to save an text file in the server. My idea is to load an xml text file maybe make some changes and then save it back to the server, so i can avoid all the database/php work because i know nothing about it. thank you

  • E 72 GPS and E-mail problem after firmware upgrade...

    Hi - to all the gurus out there, 1. i upgraded my firmware to 31.023. Now My GPS (whether using Ovi Maps or Google Maps) locks only at home ( probably the place of my last GPS lock before the upgrade- my guess). Tried many times but it simply refuses

  • Problem with SQL Developer

    Dear All, I have two questions as stated below while using the SQL Developer: 1) I have installed the application to a few PCs; while others are using the system without problems, on my PC, whenever I have entered / opened a SQL scripts on my SQL Loa

  • Creating same-name directories, different cases

    I'm trying to set up two directories with basically the same name but different cases: domain.com/DirectoryName domain.com/directoryname Just because I know someone will type it in the second way assuming it will work, since the typical user does not

  • Can't mount iDisk

    I'm having problems mounting my iDisk on my PowerMac. Every time I try, I get the message "The Volume for "iDisk" cannot be found". The PowerMac is running 10.4.5 with all the latest updates. What's strange is that I also have a iBook G4 and a Powerb