Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. How to filter arraylist results in servlet-jsp/jsp-servlet?

How to filter arraylist results in servlet-jsp/jsp-servlet?

Scheduled Pinned Locked Moved Java
javadatabasetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alok Sharma ji
    wrote on last edited by
    #1

    hello friends in my project i have an arraylist showing results in a jsp page table of given contents of database, i want to add a filter to it to show only the matched contents from list,

    the table which is coming out is as:
    student_id class_id student_name
    1x0001 10 Ashish
    1x2001 11 Anurag
    1x2002 11 Arpit
    1x0001 10 Alok

    .............going on...

    but i want the result to display page only for class_id::11 and remove other results how to do that?

    greatest things can be achieved with small but innocent ideas :)

    T 1 Reply Last reply
    0
    • A Alok Sharma ji

      hello friends in my project i have an arraylist showing results in a jsp page table of given contents of database, i want to add a filter to it to show only the matched contents from list,

      the table which is coming out is as:
      student_id class_id student_name
      1x0001 10 Ashish
      1x2001 11 Anurag
      1x2002 11 Arpit
      1x0001 10 Alok

      .............going on...

      but i want the result to display page only for class_id::11 and remove other results how to do that?

      greatest things can be achieved with small but innocent ideas :)

      T Offline
      T Offline
      TorstenH
      wrote on last edited by
      #2

      easy.. i think you're setting the table via a TableModel:

      new AbstractTableModel() {
      public String getColumnName(int col) {
      return columnNames[col].toString();
      }

      public int getRowCount() { return rowData.length; }
      
      public int getColumnCount() { return columnNames.length; }
      
      public Object getValueAt(int row, int col) {
          return rowData\[row\]\[col\];
      }
      
      public boolean isCellEditable(int row, int col)
          { return true; }
      
      public void setValueAt(Object value, int row, int col) {
          rowData\[row\]\[col\] = value;
          fireTableCellUpdated(row, col);
      }
      

      }

      - While filling the table you can select the rows to be added to the table by a simple mechanism. This would not modify the ArrayList. - Also you can set up a filtered, temporary ArrayList and give that one to the table. - check this filtering @ oracle.com JAVA tutorials Choose your way and keep things easy (comments help...) regards, Torsten

      I never finish anyth...

      A 1 Reply Last reply
      0
      • T TorstenH

        easy.. i think you're setting the table via a TableModel:

        new AbstractTableModel() {
        public String getColumnName(int col) {
        return columnNames[col].toString();
        }

        public int getRowCount() { return rowData.length; }
        
        public int getColumnCount() { return columnNames.length; }
        
        public Object getValueAt(int row, int col) {
            return rowData\[row\]\[col\];
        }
        
        public boolean isCellEditable(int row, int col)
            { return true; }
        
        public void setValueAt(Object value, int row, int col) {
            rowData\[row\]\[col\] = value;
            fireTableCellUpdated(row, col);
        }
        

        }

        - While filling the table you can select the rows to be added to the table by a simple mechanism. This would not modify the ArrayList. - Also you can set up a filtered, temporary ArrayList and give that one to the table. - check this filtering @ oracle.com JAVA tutorials Choose your way and keep things easy (comments help...) regards, Torsten

        I never finish anyth...

        A Offline
        A Offline
        Alok Sharma ji
        wrote on last edited by
        #3

        well just to be clear, this question is not related to swing its related to servlet J2EE, A very similar example of my case is here link[^] which is returning only names and id of people but in my case its name ,id, class id thus i have to filter the data as per my needs, anyways i am going to see the arraylist sorting method in your given link.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups