Can I display the table content of a web page??

Hi guys I am new to java and here I need to count the words in each table and display the table with largest number of words . This being a part of my huge project. Below is my code where I have succeeded in displaying all the tables present in the web page.But I need to count all the words in the table and display only that table which has largest number of words including all the tags. So java experts please help me with this piece of code...................
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class findtable{
  public static void main(String[] args) {
    String inputLine = null;
    String wholeHtml = "";
int trcount=0;
    try{
      URL yahoo = new URL("http://books.google.com/books?q=+subject:%22+Science+Fiction+%22&as_brr=3&rview=1&source=gbs_hplp_fict");
      URLConnection yahooConnection = yahoo.openConnection();
      BufferedReader br = new BufferedReader
        (new InputStreamReader(yahooConnection.getInputStream()));
      int start = 0;
      while ((inputLine = br.readLine()) != null) {
        wholeHtml += inputLine;
        if (inputLine.contains("<table")){
                  ++start;
        if (start != 0) {
          System.out.println(inputLine);
        if (inputLine.contains("</table>")) {
          --start;
    catch (MalformedURLException me) {
       System.out.println("MalformedURLException: " + me);
    catch (IOException ioe) {
      System.out.println("IOException: " + ioe);
    }So any help would be really really appreciated....
The code should take care of nested tables also..
So guys looking forward for the generous help....

I have already parsed the HTML and checked all the closing of tags and corrected the indent using Tidy and then I have applied this code so some other suggestions please

Similar Messages

  • How can I display XSLT transformer errors on a web page ?

    Hi,
    I have some JSP pages that access DB, create an XML based on DB data and then transform it into HTML through an XSLT stylesheet. Developing the XSL code it's easy to make mistakes and generate errors on trasformation, but what I receive on the web page is only a "Could not compile stylesheet" TransformerConfigurationException, while the real cause of the error is displayed only on tomcat logs. This is the code for transformation:
    static public void applyXSLT(Document docXML, InputStream isXSL, PrintWriter pw) throws TransformerException, Exception {
            // instantiate the TransformerFactory.
            TransformerFactory tFactory = TransformerFactory.newInstance();
            // creates an error listener
            XslErrorListener xel = new XslErrorListener();
            // sets the error listener for the factory
            tFactory.setErrorListener(xel);
            // generate the transformer
            Transformer transformer = tFactory.newTransformer(new SAXSource(new InputSource(isXSL)));
            // transforms the XML Source and sends the output to the HTTP response
            transformer.transform(new DOMSource(docXML), new StreamResult(pw));
    }If an exception is thrown during the execution of this code, its error message is displayed on the web page.
    This is the listener class:
    public class XslErrorListener implements ErrorListener {
        public XslErrorListener() {
        public void warning(TransformerException ex) {
            // logs on error log
            System.err.println("\n\nWarning on XEL: " + ex.getMessage());
        public void error(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nError on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
        public void fatalError(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nFatal Error on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
    }When I have an error in the XSL stylesheet (for examples a missing closing tag), I can find on tomcat logs the real cause of the error:
    [Fatal Error] :59:10: The element type "table" must be terminated by the matching end-tag "</table>".
    Error on XEL: The element type "table" must be terminated by the matching end-tag "</table>".but on my web page is reported just the TransformerConfigurationException message that is:
    "Could not compile stylesheet".
    How can I display the real cause of the error directly on the web page?
    Thanks,
    Andrea

    This code is part of a bigger project that let developers edit XSL stylesheets through a file upload on the system and we can't impose the use of any tool for checking the xsl. So, I need to display the transformer error on the web page.I see. This code is part of an editorial/developmental tool for developers to create and edit XSL stylesheets.
    As part of the editorial process, XSL errors during editing can be considered a normal condition. In other words, it is normal to expect that the developers will generate XSL errors as they are developing stylesheets.
    In this light, handling the XSL transformation errors is a business requirement that you need to handle. Using the Java Exceptions mechanisms, e.g. try / catch are inappropriate to handle business requirements, in my opinion.
    I suggest that you look at how you handle the occurence of XSL errors differently than what you currently have. You need to:
    (1) capture the Transformation exception on the server;
    (2) extract the message from the exception and put it into a message that can be easily understood by the user;
    The current error message that you have going to the web browser is not useful.
    And you should not have the Transformation exception sent to the web browser either.
    What you are attempting to do with the exception is not appropriate.
    Handle the Transformation exception on the Business tier and use it to create a useful message that is then sent to the Presentation tier. In other words, do not send Java exceptions to web browser.
    />

  • I am unable to view the full content of various web pages after purchasing Advanced System Care Pro. I was using the free version before with no problems. I cannot figure out if or which setting was changed. Please help

    I am unable to view the full content of various web sites after purchasing Advanced System Care Pro. I was using the free version before with no problems. I cannot figure out if or which setting was changed. I tried doing a system restore but that did not work. I tried turning off all features of ASC pro but that did not work. Javascript is enabled. Please help.
    Brian

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • Firefox is not displaying the latest version of a web page!

    When I open this web page with Safari, it doesn't display exactly the same information as when I open the page with Firefox.
    Based on the missing information, I suspect that Firefox is displaying an OLD version of the page.
    If so, what can I do to always have the most current page displayed???
    Thanks

    If this is a page you visit frequently, then Firefox may have cached an earlier version longer than the site anticipated. To temporarily bypass the cache, you can try one of the following:
    Shift + click the reload button<br>
    Command + Shift + r (on Windows: Ctrl + Shift + r)
    Does that retrieve the latest version? If so, caching is the issue. If not, there must be some other explanation.

  • How can I icrease the view size of a web page so that it is easier to read

    I have a problem reading small print on a web page. I would like to increase the viewing sizeto a larger per centage (150% vice !00%)

    The Firefox [https://support.mozilla.com/en-US/kb/Page+Zoom Page Zoom] feature does a domain by domain level of saving the users preferred zoom level settings, there is no default Page Zoom level setting in Firefox, as with some other browsers.
    Try the Default FullZoom Level extension: <br />
    https://addons.mozilla.org/en-US/firefox/addon/6965
    Or the NoSquint extension: <br />
    https://addons.mozilla.org/en-US/firefox/addon/2592/

  • Can not display the tables in developer

    Hi!
    I use the following applications:
    Database
    1     NLSRTL      9.2.0.5.0     Production
    2     Oracle9i Enterprise Edition      9.2.0.5.0     Production
    4     TNS for 32-bit Windows:      9.2.0.5.0     Production
    PL/SQL
    Java™ Platform     1.5.0_06
    Oracle IDE     1.2.1.3213
    After connecting to the DBMS i am unable to see the objects like tables and views in the Object Browser but the users. Using SQL i can run a query by typing a correct SQL Statement - i also can see the object after type in the dot.
    How i can solve this problem?
    Thanks in advance!

    You are right!
    Now i can see the objects! I established a new connection and changed the owner!
    But i do not understand - i can see all objects with the first username in the former PL SQL Developer. Which rights i have to grant to the other user to see the objects in the new developer as well?
    Thank you!

  • How to display file contents on a web page

    On unix platform I have created a class that can read the contents of a file and display them to the standard output. But now i want to display these file contents on a web page through jsp. On JSP code I have imported this class and want to assign a record from a file and write it to the screen using html. I think the class needs to be modified in order to return the string record read from a file so that im able to access it from a jsp and assign it to a variable the I can display it on the screen. Can someone help me with these code?

    Actually, you mean Linksys.  BIG difference there.
    Linksys Business Series was accumulated into Cisco Small Business, since it was purpose built for small business, not residential/consumer grade.
    The new PVC2300 actually are Cisco branded on the case.
    The collateral you seek is protected by the business unit that supplies it, since it was placed on a portal that only Cisco registered partners can access.
    As I wrote, I already checked with the BU and they told me thats where it lives and not to hand it out.  I cannot override that. 
    I am not sure there are any secrets in there, but I dont make the rules, sorry.
    Do you want to be a Cisco Partner?   Sign up and gain access to everything you need to sell Cisco successfully to end customers?  If you tell me your geography (city/state/zip, I will have an ICAM call you and help recruit you.....
    Steve D
    Systems Engineer
    U.S. Partner Sales team
    RTP, N.C.

  • Can't get the table display my results

    OK After some good hours of debugging i am able to display my results on JTable for my queries. But i got another problem now. When i select Query2 from my JComboBox and click on execute button nothing happens, same thing for query3 and 4. The only thing which works is QUERY1 why? what am i doing wrong?
    import java.awt.FlowLayout;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableModel;
    import java.awt.event.ActionEvent;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.util.Vector;
    public class DatabaseProgramming extends JFrame implements ActionListener{
         static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
         static final String DATABASE_URL = "jdbc:mysql://localhost/employees";
         static final String USERNAME = "jhtp6";
         static final String PASSWORD = "jhtp6";
         private static final String QUERY1 = "SELECT * FROM employees WHERE DEPARTMENTNAME = 'SALES'";
         private static final String QUERY2 = "SELECT * FROM hourlyEmployees WHERE hours >= '30'";
         private static final String QUERY3 = "SELECT * FROM commissionEmployees ORDER BY commissionRate DESC";
         private String names[] = {"QUERY1", "QUERY2", "QUERY3", "QUERY4"};
         private Connection connection;
         private ResultSet resultSet;
         private Statement statement;
         private ResultSetMetaData metaData;
         private JTable resultTable;
         private JComboBox queryBox;
         private JButton button;
         private int number;
         private boolean connectedDatabase = false;
         private DefaultTableModel dtm;
         public static void main(String[] args) {
              DatabaseProgramming frame = new DatabaseProgramming();
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public DatabaseProgramming() {
              super("Testing Database");
              setLayout(new FlowLayout());
              //dtm = new DefaultTableModel(getColumnName(number),0);
              //     statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                   //         ResultSet.CONCUR_READ_ONLY);
              queryBox = new JComboBox(names);
              queryBox.setEditable(false);
                   //queryBox.addActionListener(this);
                   button = new JButton("EXECUTE");
                   resultTable = new JTable();
                   button.addActionListener(this);
                   add(queryBox);
                   add(button);
                   add(resultTable);
                   //add(result);
                   setSize(400,400);
          public void actionPerformed(ActionEvent e)  {
              String selection = (String)queryBox.getSelectedItem();
                        if(selection.equals(names[0]))
                        validateQuery(QUERY1);
                        if(selection.equals(QUERY2))
                             validateQuery(QUERY2);
                        if(selection.equals(QUERY3))
                             validateQuery(QUERY3);
          public void validateQuery(String query) {
                   try {
                        Class.forName(JDBC_DRIVER);
                        connection = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
                        System.out.println("Yay Database Connected");
                    Vector col = new Vector();
                    Vector data = new Vector();
               statement = connection.createStatement();
                  resultSet = statement.executeQuery(query);
                  metaData = resultSet.getMetaData();
                  number = metaData.getColumnCount();
                  for(int i=1; i<=number; i++)
                       col.addElement(metaData.getColumnName(i));
                  while(resultSet.next()) {
                       Vector row = new Vector();
                       for(int i=1; i<=number; i++)
                            row.addElement(resultSet.getObject(i));
                       data.addElement(row);
                 resultTable.setModel(new DefaultTableModel(data,col));
                 resultTable.revalidate();
               catch ( SQLException sqlException )
                  sqlException.printStackTrace();
                  System.exit( 1 );
               catch(ClassNotFoundException e) {
                    e.printStackTrace();
               finally
                  try                                                       
                     statement.close();                                     
                     connection.close();                                    
                  catch ( SQLException sqlException )
                     JOptionPane.showMessageDialog( null,
                        sqlException.getMessage(), "Database error",
                        JOptionPane.ERROR_MESSAGE );
                     System.exit( 1 );
    }

    One last question how can i display the columnName on my JTable? Add the table to a scroll pane and the scroll pane to the frame.

  • Can't not display the table control in the report

    Hello frnds,
    I m create a module pool pgm using saptechnical  'Demo on using Table Control', 
    execute a report bush buttons are displayed but
    can't Dispaly the table ctrl in the report using screen paiter
    any help me, plz.
    Thanks in advance.

    Hi Kumar,
    Check thsi Program demo_sel_screen_with_tabstrip.
    and also a program on Subscreens in ABAPDOCU
    You need to combine both then only this is possible in Report PRograms
    Cheerz
    Ram

  • Hi. How can I delete the table without deleting the content? My pages is 5.2.2.

    Hi. How can I delete the table without deleting the content? My pages version is 5.2.2. Thank you for your help.

    There is no convert Table to text capability in Pages v5.2.2, as there was in Pages ’09 v4.3.
    You can keep the table while making the table grid vanish, leaving the existing tabular text structure. Select the table, and under the Format panel > Table tab, the following settings will produce this output. If selected, you can refine its document placement in the Arrange tab.

  • How can I display the data in table in separate column?

    I have a vi reading data one by one in the same column.
    How can I display the data with separate column?
    like this:
    data 1 | read | read
    data 2 | read | read
    data 3 | read | read
    (would you mind if I will ask for an example
    because it is much easier for me to work
    with an example)
    THANK YOU.

    If you're reading your data in as a 1D array, this is as simple as using the Reshape Array to make a 2D array. I've attached an example in LabVIEW 6.1 format. The example rearranges a single column of data fill several columns horizontally, but you can easily modify this code to fill the columns downward instead.
    Attachments:
    Data_Column_Example.vi ‏18 KB

  • How to display smartform table content in condition basis

    Hi experts
         In smartform, can i display the content of table in a condition basis.
         For example am displaying 4 rows in a page.
         If the rows exists more than 4, remaining rows i want to display in next page.
         Is it possible, if so, how to do, pls anyone help me on this.
    Thanks in advance.
    Regards
    Rajaram

    hi,
    use the command which is present in the flowlogic.
    In that tick the <b>Go to new page</b> check box and write the page no. into the i/o bos besides it and write the condition whatever it is.
    thanks
    Dharmishta

  • How to see all the table contents in SM30

    Hi All,
    I have created a Z-table. In that records are stored based on the dates.
    Suppose :
    The fields and their values in the table are as below,
    Field1 Field2 Field3
    A 22/02/2008 31/12/9999
    A 12/01/2006 21/02/2008
    B 10/11/2007 31/12/9999
    B 27/05/2006 09/11/2007
    But in if we go in SM30 transaction, it is showing only recent records i.e.as below,
    Field1 Field2 Field3
    A 22/02/2008 31/12/9999
    B 10/11/2007 31/12/9999
    Please tell me how can I get the full contents of the table in SM30.

    Hi suman,
    Is this Ztable is created by you or someone else
    Because while creating the Table maintainence, they might have created a logic at events in table maintainence as
    (at new) statement.
    So while displaying it is picking only the first record with Primary key. please check it.
    REward me if helpful.

  • Strange scenario,Oracle can not display the data in mysql correctly

    I use Heterogeneous Service+ODBC to achieve "oracle access mysql"(any other method?),and now i find Oracle can not display the data in mysql correctly:
    -------mysql------------
    mysql> create table tst(id int,name varchar(10));
    Query OK, 0 rows affected (0.00 sec)
    mysql> insert into tst values(1,'a');
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from tst;
    ------------+
    | id | name |
    ------------+
    | 1 | a |
    ------------+
    1 row in set (0.00 sec)
    mysql> show create table tst\G
    *************************** 1. row ***************************
    Table: tst
    Create Table: CREATE TABLE `tst` (
    `id` int(11) DEFAULT NULL,
    `name` varchar(10) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
    -------------oracle ------------------
    SQL> select count(*) from "tst"@mysql;
    COUNT(*)
    49
    SQL> select * from "tst"@mysql;
    id
    1
    SQL> desc "tst"@mysql;
    Name Null? Type
    id NUMBER(10)

    You can make the following query on the result page:
    "select * from the_table where movietitle = ? and cinema = ?"
    then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
    Below is the sample code, it assumes you have a connection to the database:
    PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
    stat.setString(1, usersMovieTitleSelection);
    stat.setString(2, usersCinemaSelection);
    ResultSet res = stat.executeQuery();
    if (res.next()) {
    out.print("The movie is available");
    } else {
    out.print("The movie is not available");
    }Now just add that to your JSP page. Enjoy ! =)

  • Error when displaying the table

    hellow,
        here i have to .htm pages, in first page i am entering the table name, and it has to display the table details in second page.
    but in second page i am getting error like field catalog not found
    plz help me.
    with regards
    babu

    hi babu rs
    Please post the code of the two bsp page with the layout as well as abap code. Only than anybody can help you.

Maybe you are looking for

  • This document cannot be opened as it is not a valid PDF document

    I am trying to get my Amex statement from Amex on my tablet. I have Adobe reader for Andriod and Pdf  to Go. Each time I download and tray to read the document I get this error. Other Pdf files I have downloaded open OK.

  • How to change standard text in(me33k)?

    How to change standard text in me33k (under Reference data : Dept/Proj Manager) field. I tried it changing in CMOD - under Goto in Text enhancements in Keywords then Change . I did this change and in table ekko-verkf I can see the change, but in me33

  • How to choose data in file adapter?

    How to choose data in file adapter?

  • How to Duplicate a Page in Wiki Server 3

    I have just set up a Mac Mini Lion Server to use as a staff information portal / intranet. I would like to use the wiki to keep our standard procedures up to date and all in one place. Is there any way to set up a page template in Wiki Server? All th

  • Manipulating coldfusion structures in flex

    Hi, I am beginner with flex. I was trying a sample login application using flex and coldfusion. I was able to connect to coldfusion, and was able to show an alert message when the user successfully logins. I was just returning a numeric value of 1 if