Data retrieval displayed on multiple pages - Servlets

I am using mysql database, JDBC and Servlets.
Could anyone tell me the best way to display the data retrieved from the database in multiple pages. For example I have 215 records and I want the data displayed in several pages with 10 rows per page.
I want something similar to these forum pages where I can move forward, back, first and last through the database.
Thanks in advance

Hans Bergsten's JSP book from O'Reilly has an example that manages that trick with JSTL. You should buy a copy and download the JSTL implementation from Jakarta and try it out. - MOD

Similar Messages

  • How to retrieve data and display in JSP page

    hi,
    i am trying to retrieve data from SQL server 2000 and display in JSP Page. I have already place the codes of the retrieve in the bean file. I wanna ask is that how to display in the JSP page. If possible, can provide example codings for mi to reference?
    Thanks
    Regards,
    shixuan

    HI Tan ,
    I pressume that you wanted to make use of PDK, the code can go like this .
    <b><u>1) JAVA file</u></b>
    import com.sapportals.htmlb.DropdownListBox;
         import com.sapportals.htmlb.InputField;
         import com.sapportals.htmlb.event.Event;
         import com.sapportals.htmlb.page.DynPage;
         import com.sapportals.htmlb.page.PageException;
         import com.sapportals.portal.htmlb.page.JSPDynPage;
         import com.sapportals.portal.htmlb.page.PageProcessorComponent;
         import com.sapportals.portal.prt.component.IPortalComponentRequest;
         import com.sapportals.portal.prt.component.IPortalComponentSession;
         import com.sapportals.portal.prt.component.IPortalComponentContext;
         import java.sql.*;
         public class P_SAP_B_User extends PageProcessorComponent
         * Method          :           getPage()
         * Description      :                         
         * Input Parameters     :     None
         * Returns          :          Object of Class DynPage     
              public DynPage getPage()
                  return new P_SAP_B_UserDynPage();
                }     // end of dynPage()
                public static class P_SAP_B_UserDynPage extends JSPDynPage
                  /* Variable Declaration     */
                   /* Object of bean class P_SAP_B_CreateUser initialised to null */
                       private P_SAP_B_CreateUser createUserBean = null;
                  /* Flags for checking the occurance of Event & Error. */
                  private int iFlag=0;
                  private int iErrFlag=0;
                  /* Variables for storing the information
                          entered by user in each text field */
                  private String sFname;
                  private String sSname;
                  private String sAge;
                  private String sExp;
                  private String sSkill;
                  private String sUnit;
         * Method          :           doInitialization()
         * Description      :                         
         * Input Parameters     :     None
         * Returns          :          None
                  public void doInitialization()
                         IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
                         Object o = componentSession.getValue("createUserBean");
                         if(o==null || !(o instanceof P_SAP_B_CreateUser))
                           createUserBean = new P_SAP_B_CreateUser();
                           componentSession.putValue("createUserBean",createUserBean);
                        }     // end of if
                         else
                             createUserBean = (P_SAP_B_CreateUser) o;
                         }     // end of else
                   }//end of doInitialisation()
         * Method          :           onUpdate()
         * Description      :                         
         * Input Parameters     :     object of Event class
         * Returns          :          None
                   public void onUpdate(Event e)throws PageException
                        /*     sets flag to 1 when update button is clicked. */
                        iFlag=1;
         * Method          :           doProcessAfterInput()
         * Description      :                         
         * Input Parameters     :     None
         * Returns          :          None
                  public void doProcessAfterInput() throws PageException
                             InputField ifFirstName = (InputField) getComponentByName("FirstName");
                             InputField ifSecondName = (InputField) getComponentByName("SecondName");
                             InputField ifAge = (InputField) getComponentByName("Age");
                             InputField ifExp = (InputField) getComponentByName("Exp");
                             InputField ifSkill = (InputField) getComponentByName("Skill");
                             DropdownListBox dlbUnit = (DropdownListBox) getComponentByName("Unit");
                             int iAge,iExp;
                             IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                            IPortalComponentContext myContext = request.getComponentContext();
                             P_SAP_B_CreateUser myNameContainer = (P_SAP_B_CreateUser) myContext.getValue("createUserBean");
                             if(ifFirstName != null)
                                  this.sFname = ifFirstName.getValueAsDataType().toString() ;
                             }     // end of if
                             if(ifSecondName!= null)
                                  this.sSname = ifSecondName.getValueAsDataType().toString() ;
                             }      // end of if
                             if(ifAge!= null)
                                  this.sAge = ifAge.getValueAsDataType().toString() ;
                             }     // end of if
                             if(ifExp!= null)
                                  this.sExp = ifExp.getValueAsDataType().toString() ; 
                             }     // end of if                         
                             if(ifSkill != null)
                                  this.sSkill = ifSkill.getValueAsDataType().toString() ;          
                             }     // end of if
                             if(dlbUnit != null)
                                  this.sUnit = dlbUnit.getSelection().toString() ;     ;
                             }      // end of if
                          /* Data Validation */
                             /* try block for numeric Exception */
                             try
                                 /* checking for any field left blank by the user */
                                  if(sFname.equals("") || sSname.equals("") ||  sAge.equals("")|| sExp.equals("") || sSkill.equals(""))
                                        /* set error flag to 1 in case of any field left blank */
                                        iErrFlag=1;
                                  } // end of if
                                  else
                                        /* converting Age and Experience fields (String) to integer */
                                         iAge= Integer.parseInt(sAge);
                                         iExp= Integer.parseInt(sExp);
                                       /* setting the boundaries on the value in Age Field */
                                         if(iAge<0)
                                             /* set error flag to 2 in case of age below 0 */
                                             iErrFlag=2;
                                         }// end of if
                                       /* setting the boundaries on the value in Experience field */
                                          else if(iExp<0 ||(iExp/12)>=iAge)
                                              /* set error flag to 3 in case of experience below 0 or exceeding the age in years */
                                              iErrFlag=3;
                                          }// end of else if
                                          /* In case of no error */
                                          else
                                             /* setting the bean variables */
                                             try
                                                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                                 Connection con = DriverManager.getConnection("jdbc:odbc:Test");
                                                 String query="insert into UserData values(?,?,?,?,?,?)";
                                                 PreparedStatement prestat=con.prepareStatement(query);
                                                 /* setting the values to be inserted into the user table */
                                                 prestat.setString(1,sFname);
                                                 prestat.setString(2,sSname);
                                                 prestat.setString(3,sAge);
                                                 prestat.setString(4,sExp);
                                                 prestat.setString(5,sSkill );
                                                 prestat.setString(6,sUnit);
                                                 prestat.executeUpdate() ;
                                                 prestat.close();
                                                 con.close();
                                                 myNameContainer.setSFname(sFname);
                                                 myNameContainer.setSLname(sSname);
                                                 myNameContainer.setSAge(sAge);
                                                 myNameContainer.setSExp(sExp);
                                                myNameContainer.setSSkill(sSkill);
                                                myNameContainer.setSUnit(sUnit);
                                             } // end of inner try block
                                              catch(Exception sqle)
                                                 myNameContainer.setErrMessage("Update failed ! Please try again." );
                                              } // end of catch corresponding to inner try
                                                           } // end of inner else
                                                      } //end of outer else
                                   } //end of outer try block
                                   catch(Exception e)
                                     /* setting flag to 4 in case of non-numeric age/experience values */
                                     iErrFlag = 4;
                                     /* Displaying error message corresponding to the value of error flag */
                                  switch(iErrFlag)
                                    /* Empty Field */
                                    case 1:myNameContainer.setErrMessage( "Please Fill all the fields");
                                    break;
                                    /* Invalid Value in the age field */
                                    case 2:myNameContainer.setErrMessage( "Enter a valid value in Age field.(Hint : Have you entered Age<0 ?");
                                    break;
                                    /* Invalid Value in the experience field */
                                    case 3:myNameContainer.setErrMessage( "Enter a valid value in Experience field.(Hint : Experince should not be negative or greater than your age in months)");
                                    break;
                                    /* Non-numeric value in the Age/ experience fields */
                                    case 4:myNameContainer.setErrMessage( "Please Enter Numeric Value for Age and Experience");
                                    break;
                                 } // end of switch-case block
              } //end of doProcessAfterInput()
         * Method          :           doProcessBeforeOutput()
         * Description      :                         
         * Input Parameters     :     None
         * Returns          :          None
                  public void doProcessBeforeOutput() throws PageException
                       /* Displays Form for new user creation by default */
                       this.setJspName("P_SAP_B_UserCreationForm.jsp");
                         /* In case of an error display an error message page */
                         if(iErrFlag!=0)
                              setJspName("ErrorPage.jsp");
                         } //end of if
                         /* Displays the user's information as entered in the SQL
                            database after its been uploaded by the user */
                         else if(iFlag==1)
                             setJspName("hello.jsp");      
                          } // end of else if
                  } // end of doProcessBeforeOutput()
              } // end of P_SAP_B_UserDynPage Class
         } // end of P_SAP_B_User class
    * End of File P_SAP_B_User.java
    2) Bean
    package com.sap.usercreation;
    import java.io.Serializable;
    public class P_SAP_B_CreateUser implements Serializable
         private String sFname;
         private String sLname;
         private String sUnit;
         private String sSkill;
         private String sExp;
         private String sAge;
         private String errMessage;
         * @return
         public String getSFname() {
              return sFname;
    * @return
    public String getSLname() {
         return sLname;
    * @param i
    * @param string
    public void setSFname(String string) {
         sFname = string;
    * @param string
    public void setSLname(String string) {
         sLname = string;
    * @return
    public String getSUnit() {
         return sUnit;
    * @param string
    public void setSUnit(String string) {
         sUnit = string;
    * @return
    public String getSSkill() {
         return sSkill;
    public void setSSkill(String string) {
         sSkill = string;
    * @return
    public String getSAge() {
         return sAge;
    * @return
    public String getSExp() {
         return sExp;
    * @param string
    public void setSAge(String string) {
         sAge = string;
    * @param string
    public void setSExp(String string) {
         sExp = string;
    * @return
    public String getErrMessage() {
         return errMessage;
    * @param string
    public void setErrMessage(String string) {
         errMessage = string;
    3) The Jsp file i have already posted.
    See if you copy this code and paste it wont work as i have not given you full code ,But yes this gives you an overview of how things can be done .
    Thanx
    Pankaj

  • Continued Header Display in Multiple pages

    Hi All,
    I am working on a print form. The requirement in body of the form is like this...
    Header with 10 columns
    Subsequent Items with 10 columns
    The above Header and Item both are dynamic.  There may be multiple Headers and Multiple Items. I am able to display the multiple headers with multiple Items. But the problem is when the data flows to multiple pages and if the page break occurs then the line items flowed into next page should be followed by its header. I have achieved that. Now the header which is coming in the next page should come with concatenated value page contd.. in the second column of the header... What would be the possible way to achieve the same..
    Regards,
    Mohammed Shukoor.

    Could you please eloborate the question. 
    as per my understanding, you need an extra line to be appended when pagination occurs with the page value and contd...
    Please let me know, if my understanding is right.
    thanks
    Rakesh.

  • How to display a multiple-page html file

    My program has a multiple-page help file, which is an html file, that I would like to display page by page.
    My code presently doesn't even display anything, even though I put my "help.html" into two places, where I have my .java files and where I have my project file. Here it is:
    try
            JDialog dialog = new JDialog(AnanyaCurves.this, true);
            dialog.setTitle("Ananya Curves Help");
            JEditorPane editorPane = new JEditorPane();
            editorPane.setEditable(false);
            java.net.URL helpURL = JFrame.class.getResource("help.html");
            editorPane.setPage(helpURL);
            dialog.getContentPane().add(editorPane);
            dialog.setLocationRelativeTo(AnanyaCurves.this);
            dialog.setVisible(true);
    catch (IOException e)
    }AnanyaCurves is my main class, which extends JFrame, and the code above is the code for the method of a JMenuItem.
    Please help with my help! Thanks a lot!

    Hi,
    BrigitAnanya wrote:
    My code presently doesn't even display anything, even though I put my "help.html" into two places, where I have my .java files and where I have my project file. It has to be where the CLASS files are.
    Here it is:
    java.net.URL helpURL = JFrame.class.getResource("help.html");
    This might be in the path where the JFrame.class file is.
    You should better use
             java.net.URL helpURL = YourMainClass.class.getResource("help.html");greetings
    Axel

  • SSRS 2008 R2 report does not print the page header for a html content displaying on multiple pages

    Hi
    I need to display the html content from the database. The html content are quite long and can have content of 3-5 pages. Issue I  am facing is f the record has html content of 3-5 pages, then it does not print the page header (which is a separate tablix) on
    second page onwards.
    Nikesh Shah
    Nikesh Shah

    Hi Nikesh,
    According to your description, I’m not sure the meaning of Page header in your scenario. In Reporting Services, a page header that run along the top of each page, respectively. Headers can contain static text, images, lines, rectangles, borders, background
    color, background images, and expressions. But we couldn’t add tablix in the page header.
    If you are saying report header, a report header consists of the report items that are placed at the top of the report body on the report design surface. They appear only once as the first content in the report. So it cannot repeat in other pages.
    If you are saying tablix header, freezing column headers are different in table and matrix. For more details, please refer to the following thread:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c8ddc1af-1bdf-4e72-8aab-0353c7cc848a/ssrs-report-freezing-row-and-column-while-scrolling-issue?forum=sqlreportingservices
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Adobe forms-multiple pages display problem

    Hi All,
      I had a query regarding the display of multiple pages in adobe 5.5 version.
    I had data which suits in more than one page in adobe.But its displaying only the data in the first page.And it is displaying the empty second page also,but with no data.So any suggestions to solve this issue???

    Hi,
    version  5.5.1.280? It is version of Adobe Reader? If yes then you can't use this version for viewing of adobe forms (note 834573 - SAP Interactive Forms by Adobe: Acrobat/Reader version).
    Another suggestion: Is subform of your first Body Page flowed (tab Object->Subform, propertie Content)? If not then content of this Body Page can't dynamically grow.
    Check subforms of your Body Pages, especially tab Object->Pagination.
    Regards
    Michal

  • Issue in displaying box in multiple pages of scripts

    Hi all,
    In my requirement i am getting the output in multiple pages . I am using ' BOX FRAME 30 TW' for getting the box .This box is getting only in first page but is not displaying in multiple pages.
    how can i achieve this?
    waiting for u r replies.
    Regards,
    Bhanu.R

    Hi Phani,
    The box you defined must be on the same page where you defined your first page.
    Always take a variable window to make it apper on multiple windows.
    First write perform for your box then call your main page.
    Much Regards,
    Amuktha.

  • Printing Multiple pages in Smartform on Local printer

    Hi guys,
    I have a smartform with a command to print a page with the general conditions.
    When I print this on a defined printer in SPAD everything goes fine (got 2 pages) but when I print this same form thru the Local printer I only get 1 page. It seems the second page is printed over the first.
    Tried it with more pages, 1 with data then general conditions then data again, and it also prints it all on 1 page thru the Local printer. With the third page on top of the second on top of the first.
    Does anybody know how to solve this issue.
    Thanks.

    Hi,
    I checked the printers and they are using the normal SAPWIN type. I tried it with access method F and G but both give the same result. The page format used is the standard DINA4.
    On the print preview it looks fine, when I print it on a printer from my windows session using the local printer it all prints on the first page (so it only shows the last page).
    I tried to add the check SY-TABIX > 1 and it is the same issue.
    The problem seems not to be with the smartform because if I print a layout which do not have a command to add an extra page but it contains enough data to print on multiple pages and we get the same result. Second page is printed over first page.
    Thx.

  • Display multiple pages of PDF in ABAP webdynpro

    Hi Friends,
    We have a requirement, where we have to display all the pages of PDF in ESS Portal using Abap WD.  I have got the xstring data for all PDF pages.   How can I display them now? 
    I used interactive form, but it can display just one page.  Is there any method or UI element by which multiple pages can be displayed.
    Please provide your valuable inputs.
    Thanks,
    Sumeet

    The pdf is stored in spool in parts, and are not in single pdf file.  I have managed to get the xstring values for all the pages.  Saying multiple pages, I mean there multiple individual pdf page.  We cannot scroll them, but need some kind of button to traverse to next page. 
    I wanted to know, if there is anything helpful in Webdynpro to display it.

  • Keep the data among multiple pages

    I have MyForm.jsp for the form, and MyAction.jsp that process the
    request.
    MyAction.jsp will interact with another system, if it fails, then it
    will show MyForm.jsp with the data entered by the user again.
    Everything is in the same browser.
    In my case, should I keep the data in the session, so that it can go
    back? Maybe I should
    use <jsp:forward> tag also?

    I have MyForm.jsp for the form, and MyAction.jsp that
    process the
    request.
    MyAction.jsp will interact with another system, if it
    fails, then it
    will show MyForm.jsp with the data entered by the user
    again.
    Everything is in the same browser.
    In my case, should I keep the data in the session, so
    that it can go
    back? Maybe I should
    use <jsp:forward> tag also?Yup, puuting the data in session is okay. But if you use jsp:forward, you could put it in the request attributes as well, since the forward will use the same request. This will lower the scope of the data so multiple submits from the same user don't trip over each other.
    One thing you might think about is saving the data in a JavaBean specifically designed to transport the data (this is often called a Data Transfer Object). This will make it easier to store and retrieve the data in an understandable and uniform manner between multiple pages.

  • Data in multiple pages in smartforms

    i have a normal window which has lots of data, problem is it shows only first page. how can i show all those data in multiple pages?
    there is also a main window. this normal window will show up only after that main window.

    use main window to do that
    OR
    in the initialization put al your outputdata in an internal table and program this so that the table has 2 fields,
    field_1 has pagenumber
    field_2 has display information.
    define your window as late.
    according to pagenumber display relevant info in that page with a loop.
    Regards,
    Guido

  • Data Display in next page in JSTL

    Hi
    I have two jsp pages. In first page I get a resultset based on query and show values in a table format. In this one column value is hyper link. My second page should show the data related to particular hyperlink when I click the link.
    first.jsp
    <sql:transaction dataSource="${example}">
    <sql:query var="Power" >
    SELECT EMP_ID, EMP_TYPE, EMP_NAME, FROM EMP where TRANSACTION_TIMESTAMP > sysdate - 3 and EMP_name = '<c:out value="${s}"/>'
    </sql:query>
    </sql:transaction>
    <table border="1">
         <%-- Get the column names for the header of the table --%>
    <tr>
    <c:forEach var="columnName" items="${Power.columnNames}">
    <th><c:out value="${columnName}"/></th>
    </c:forEach>
    </tr>
    <c:forEach var="row" items="${Power.rows}" >
    <tr>
    <td><c:out value="${row.EMP_id}" /></td>
    <td> <c:out value="${row.EMP_type}" /></td>
         <td> <c:out value="${row.EMP_NAME}" /></td>
    </tr>
    </c:forEach>
    </table>
    When I hit the hyper link, Second page has to show values of emp-id, emp_type, emp_name corresponding to emp_id value only.
    Please any body suggest how to go about it.
    Suuryan

    If you want to keep the results over multiple page navigations, you need to put the query results into session:
    When you click the link, you need to send as a parameter some way of identifying which row was selected. Either the empId, or the index of the row number you clicked.
    <c:forEach var="row" items="${Power.rows}" varStatus="status">
    < href="<c:url value="Second.jsp">
       // the empid
      <c:param name="empId" value="${row.EMP_id}"/>
      // the row index
      <c:param name="rowSelected="${status.index}"/>
    </c:url>">
    <c:out value="${row.EMP_id}" /></a>On the second page you then use the empId, or the row index to display the correct record.
    If you keep the results in session:
    <sql:query var="Power" scope="session">
    you can access the correct record in the second page using
    ${Power.rows[param.rowSelected]}"
    alternatively do another query
    Select from .... WHERE EMP_ID = ?
    and substitute in the empId from the previous screen.
    Cheers,
    evnafets

  • Data not getting displayed in every page ...

    Hi,
    I'm facing a peculiar problem. I have a template where i want to display a certain table in every page but i can't place it in header. As far as i know it should get displayed if I select "Repeat as header row at the top of each page".
    This table is under a group <?for-each@section:G_HEADERS?> ... The problem that i'm facing is the table is getting displayed in the first page but not on subsequent pages ... i even tried putting a simple table with a static text .. but its behaving simillarly .... I tried Table-> Heading rows repeat but to no avail ..
    Please help me if someone has any solution ...

    Do you have a single page or multiple pages?
    You should be able to put a table in the header. Read up in the user guide on
    <?start:body?>
    <?end body?>
    Which allows you define the header/foot inside the Word body.
    In the 5.6.2 user guide it is on page 6-13:
    Creating RTF Templates -> Defining Headers and Footer -> Multiple or Complex Headers and Footers.
    In the word header you can use <??> command, but you have to spell them out and
    not use form fields - becaue Microsoft Word does not allow form fields in headers.
    Klaus

  • Master page Dynamic data not getting displayed in consecutive pages

    Hi,
       I have buit a dynamic form which has some dynamic content in master page and a dynamic table in the body page.
    Layout is
    Master page
          Sub form
                 Field1 -TextView
                 Field2 - TextField      bind with Node1--->Attribute1
                 Field2- TextField       bind with Node2---->Attribute2
                Field n - TextField
    all the text fields are bound to various nodes from RFC
    Body Page
             Sub form
                  Table -Grows Dynamically
    When i run the application all the fields are displayed perfectly in the first page.
    when the table data goes more than one page the problem arises
    The Text fields in the master page is  not displaying the values in the second page ,but the text views and the table values are fine.
    The values are getting displayed in both pages if i put any attribute inside the parent node.Is there any property i need to set at node level or subform level?
    Thanks in advance,
    Siva

    Hi
    I Would like to give a suggestion eventhough i don,t have answer to you question.
    Master Page is used for static content as per SAP and Adobe like company logo and  company address footer section and placing  watermarks etc....
    I feel because of the Dynamic behavior in master page it Leeds this problem.
    Regards
    Malli

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

Maybe you are looking for

  • Mac OS X, windows and FreeNAS sharing folders

    I just setup FreeNAS. I want to have all our documents and pictures to reside on that. This way I wont have two different copies of any certain file. It is relatively easy to have the 'My Documents' folder from my windows notebook point to the Networ

  • First time using iDVD

    I have iLife 05 and I am finally getting around to doing all the cool stuff I am capable of with my MAC. I have a few questions hopefully some people out there could answer. 1. When I want to create a DVD, can I use photos from iPhoto and/or home vid

  • ITunes COM SDK License Warning

    Hi,    I'm developing a commercial app that works with the iTunes COM SDK. However, on the download page for the SDK, there's this warning: Warning: Pre–release software is Apple confidential information. Your unauthorized distribution of pre–release

  • EP configuration docs

    Hi All, I am working on Webdynpro Java, I know iview/page/workset/role creation in EP. Now I wanted to shift to pure EP administration and configuration side. I want learn it from scratch... like deployement of portal server on WEBAS/J2EE engine and

  • Disk Verification Problem...?

    Hello Folks, I'm hoping this is the correct section to post this...... I've been posting over on the iDVD section of this site where 'Glo H' was trying to help me solve a problem I'm having. We seem to have run our course there and he suggested I pos