Paging in JSP ! HELP! HELP! HELP!

somebody can order an example to me of paging of results in JSP... or tutorial address that has some scritpt and. since already I am thankful!
[email protected]

If you are interested in creating some type of paging functionality you will need a few things. First, i will assume you have some set of data that you want to page. Let's say you have an array of Objects that has 100 total elements.
You will most likely define a pageSize value that defines how many elements to display on the current page. You will also want to define a pageNumber to represent the current page that you are on.
So lets say that you have a pageSize = 10.
You should define some Java method in a class that has access to the complete array, which takes the pageSize and pageNumber as parameters, and returns an array of the same type.
For example, lets say you have a class called EmployeeSet
public class EmployeeSet
private Employee[] totalEmployeeSet;
public void setEmployeeSet
//some code that populates the totalEmployeeSet array
public Employee[] getEmployeeSet()
return totalEmployeeSet;
public Employee[] getCurrentEmployeePage(int pageSize, int pageNumber)
// some logic to check that parameters are within valid range
Employee[] currentEmployeeSet = new Employee[pageSize];
//now store the current range into your current set
//loop through the totalEmployeeSet starting at the correct
//point (pageNumber*pageSize), and store each element
//into the currentEmployeeSet
return currentEmployeeSet;
I left out some important logic to determine whether the inputs to the method are valid or not, and whether the current page can display 'pageSize' elements or not. I am sure you can figure that out.
I hope this helps some.
-Dras

Similar Messages

  • How to make  paging in JSP?

    I would like to know how to make paging in JSP?
    PLEASE HELP ME !

    It is much easier , if you use MVC framework, you can store
    results in session appropriate action to servlet, it will serve page by page.

  • Paging in JSP(Scriptlets) help-me! help-me! help-me!

    Somebody can order an example of paging in JSP. does not obtain to make the paging.... Please, somebody can help.....� an urgency case me! In case that somebody has some example please, [email protected] orders pro email If possivel in Scriptlets
    Very Obliged!

    <%@ page import="java.sql.*" %>
    <%@ page errorPage="err.jsp" %>
    <%
    By VendeW and Shibayama
    %>
    <html>
    <body>
    <center>
    <h2>Pagina��o usando JSP e MySQL</h2>
    <table border="2">
    <tr bgcolor="tan">
    <th>id</th><th>Titulo</th><th>Image</th><th>Descri��o</th></tr>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conexao = DriverManager.getConnection("jdbc:odbc:book");
    Statement declaracao = conexao.createStatement();
    Statement declaracao2 = conexao.createStatement();
    int limitePorPagina = 5;
    ResultSet resultado = declaracao.executeQuery("Select * from tbl_livro limit " + request.getParameter("pr") + "," + String.valueOf(limitePorPagina));
    ResultSet rs2 = declaracao2.executeQuery("Select count(*) as c from tbl_livro");
    rs2.next();
    int totalregs = Integer.parseInt(rs2.getString("c"));
    %>
    <b>Total de Registros: </b><%=totalregs%>
    <%
    int totalpgs = Math.round(totalregs / limitePorPagina);
    out.write("<b>P�ginas:</b> " + totalpgs);
    if ((totalregs % limitePorPagina) > 0) totalpgs++;
    int pr = Integer.parseInt(request.getParameter("pr"));
    try {
    while (resultado.next()) {
    String id = resultado.getString("id_livro");
    String nm = resultado.getString("nm_livro");
    String img = resultado.getString("image");
    String desc = resultado.getString("desc_livro");
    %>
    <tr>
    <td><%=id%> </td>
    <td><%=nm%> </td>
    <td><%=img%> </td>
    <td><%=desc%> </td>
    </tr>
    <%
    }//while (resultado.next())
    %>
    </table>
    <%
    }//try
    catch (SQLException e) { out.println("SQL Error" + e); }
    if (pr > 0) {
    %>
    [Primeira P�gina] 
    <a href="?pr=<%=pr-limitePorPagina%>">[Anteriores]</a> 
    <%
    }//if (pr > 0)
    if (pr < (totalpgs * limitePorPagina) - limitePorPagina) {
    %>
    <a href="?pr=<%=pr+limitePorPagina%>">[Pr�ximos]</a> 
    <a href="?pr=<%=(totalpgs * limitePorPagina) - limitePorPagina%>">[Ultima P�gina]</a> 
    <%
    }//if (cont < totalpgs)
    %>
    </center>
    </body>
    </html>

  • JSP and Servlet - help please

    Hello,
    I am making this feedback for fun and a bit of learning too. I have an INDEX.JSP page, where the user selects the very first option. Depending upon the selected option he is moved another page PRODUCTFEEDBACK.JSP (so far I have completed this). Here as usual there are many fields to be filled in. As a spams protection i have done this;
    I have a AdditionClass, which is a seperate class where two number are generated at random. This numbers are called by PRODUCTFEEDBACK.JSP. The user is then asked to perform the addition. The completed form is then sent to ProductFeedback servlet.
    When I compile my PRODUCTFEEDBACK.JSP I get this error. Can you please tell whats wrong?
    PRODUCTFEEDBACK.JSP
          *<td>Please help us to prevent Spams by performing this simple mathematical Calculation. We appreciate your effort </td>*
        *</tr>*
      *</table>*
      *<jsp:useBean id = "AddTest" class = "go.AdditionClass" />*
      *<table width="53%"  border="0" align="center">*
        *<tr>*
          *<td><div align="center">*
      *<input name="textfield8" type="text" size="3" value ="<jsp:getProperty name="AddTest" property = "randNum1" />">*
    *  + * 
      *<input name="textfield9" type="text" size="3" value="<jsp:getProperty name="AddTest" property = "randNum2" />">*
    *  = *
    *<input name="_total" type="text" size="5">*
          </div></td>
        </tr>
        <tr>
          <td> </td>
        </tr>
      </table>
      <br>
      <table width="37%" height="23"  border="0" align="center">
        <tr>
          <td width="33%"> </td>
          <td width="67%"><input type="submit" name="Submit" value="Click here to send us this form"></td>
    AdditionalClass.java
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package go;
    import java.util.Random;
    * @author MAC
    public class AdditionClass {
        Random generator = new Random();
        int randNum1; // First Random Number
        int randNum2; // Second Random Number
        public void SetNum1(){
            randNum1 = generator.nextInt(10); // Generate First Random Number
        public int getNum1(){
            return randNum1; //Return First Random Number
        public void SetNum2(){
            randNum2 = generator.nextInt(10); // Generate Second Random Number
        public int getNum2(){
            return randNum2; // Return Second Random Number
        // send the Random Numbers to ProductFeedback class
        public void productFeedbackRandNum1(){
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber1(randNum1);
        public void productFeedbackRandomNum2(){
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber2(randNum1);
    }Erros that I am getting:
    org.apache.jasper.JasperException: Cannot find any information on property 'randNum1' in a bean of type 'go.AdditionClass'
    C:\Documents and Settings\MAC\My Documents\NetBeansProjects\FeedBack\nbproject\build-impl.xml:462: The following error occurred while executing this line:
    C:\Documents and Settings\MAC\My Documents\NetBeansProjects\FeedBack\nbproject\build-impl.xml:440: Java returned: 1
    BUILD FAILED (total time: 1 second)

    Thank you for replying. I modified my Bean class then what is posted above, so thought to repost the code again and seek help. There seems to be no error now but it just dont generate any random numbers, All i get very time is 0. I am wondering, is my code generating 0 as random number, every time :-)
    package go;
    import java.util.Random;
    public class AdditionBean {
        int randNum1; // First Random Number
        int randNum2; // Second Random Number
        public void generateRandomNum1(){
            Random generator = new Random();
            int num1 = generator.nextInt(10);
            SetRandNum1(num1);
            // Send num1 value to ProductFeedback.java
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber1(num1);
        } // End of generaeRandomNum1
        public void generateRandomNum2(){
            Random generator = new Random();
            generator = new Random();
            int num2 = generator.nextInt(10);
            SetRandNum2(num2);
            // Send num1 value to ProductFeedback.java
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber2(num2);
        } // End of generateRandomNum2
        public void SetRandNum1(int num1){
            randNum1 = num1;
        public int getRandNum1(){
            return randNum1; //Return First Random Number
        public void SetRandNum2(int num2){
            randNum2 = num2;
        public int getRandNum2(){
            return randNum2; // Return Second Random Number
    }// End of classThank you,

  • Precompiled JSP. Need HELP

    I need to know how to pecompile jsp, and where to put the result?
    Do I need any jsp blank plug?
    Where to put classes generated from jsp?
    Could you point me to some simple tutorial about it

    hi all
    im new to java technlogy ,i retrived data from
    oracle database inside a html table ,but i want this
    data to be as links to another pages .for example .
    i have
    a
    b
    c
    rived from database in a table .now i want this as
    links ,which on click should navigate to another
    page.
    how should i do with jsp/java please help me
    with sample code
    hank uInstead of making the HTML look like:
        <td>a</td>
        <td>b</td>
        <td>c</td>Make it look like
        <td><a href="linkfora">a</a></td>
        <td><a href="linkforb">b</a></td>
        <td><a href="linkforc">c</a></td>

  • Help menu help loads After Effects 7 Help

    Using Golive CS2, when I go to the help menu and choose Golive Help, After Effects 7 help opens instead, with a dropdown menu that has no listing for Golive Help. I just reinstalled Golive CS2, the update, and a help update to no effect.

    First, ensure you have the latest help centre and Golive Help package:
    Help Centre 2.1:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=3171
    Help Package: http://www.adobe.com/support/downloads/detail.jsp?ftpID=3091
    *Ensure the file GoLive_8.0_en-us.zip is in the Adobe Help
    Centre\AdobeHelpdata\Packages folder.*
    There are a couple of Techdocs relating to the Help Centre:
    331717 Help window doesn't appear when you start Adobe Help Center
    (Windows XP, 2000)
    http://www.adobe.com/support/techdocs/331717.html
    319210 Adobe Help Center is missing content or returns the error, "The
    topic you want to view applies to a CS2 product you have not installed."
    http://www.adobe.com/support/techdocs/319210.html
    If those don't help:
    1. Try deleting the Help Preference file by holding down CTRL+ALT+SHIFT
    whilst starting Help.
    2. Assuming ahc.exe is located in C:\Program Files\Adobe\Adobe Help Center,
    delete the following folders
    C:\Program Files\Adobe\Adobe Help Center\AdobeHelpData\Cache
    C:\Program Files\Adobe\Adobe Help Center\AdobeHelpData\Database
    C:\Program Files\Adobe\Adobe Help Center\AdobeHelpData\Preferences
    C:\Program Files\Adobe\Adobe Help Center\AdobeHelpData\Search
    The only folder under C:\Program Files\Adobe\Adobe Help Center\AdobeHelpData
    you should have left is one called packages.
    Run ahc.exe
    What should happen is that your help centre database should get rebuilt
    (you will see progress messages as it process each help package) and
    everything should work.

  • When I try to install Itunes, I get this error: (translated from Norwegian) There was a network error while trying to read from the file: C: \ windows \ installer \ iTunes.msi I have tried many times to reinstall, but nothing helps, please help me.

    When I try to install Itunes, I get this error: (translated from Norwegian) There was a network error while trying to read from the file: C: \ windows \ installer \ iTunes.msi I have tried many times to reinstall, but nothing helps, please help me.

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Help apple help me, at first I was new to iphone registration 1 apple ID account but because I hardly use icloud account. so I do not remember the password and login name, my computer crash when I decided to run the software on ios7.1, but do not expect m

    help apple help me, at first I was new to iphone registration 1 apple ID account but because I hardly use icloud account. so I do not remember the password and login name, my computer crash when I decided to run the software on ios7.1, but do not expect me to be locked iclou account, I hope this mail unlocked apple for my apple account. I'm currently using the machine iphone 5, IME: ********. thank you ... ask yourself? machine is in warranty period warranty icloud error not send mail to me at mail
    <Personal Information Edited by Host>

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Help.. help.. HP Mini 1000.. reset bios!!! CNU9257483

    help.. help.. HP Mini 1000.. reset bios!!![edited Serial Number by Moderator]
    Thank all>>>>>
    This question was solved.
    View Solution.

    Ken try.
    e9lo7qxvuf
    REO
     I must inform you that these services are not endorsed by HP, and that HP is not responsible for any damage that may arise to your system by using these services. Please be aware that you do this at your own risk.
    HP Expert Tester "Now testing HP Pavilion 15t i3-4030U Win8.1, 6GB RAM and 750GB HDD"
    Loaner Program”HP Split 13 x2 13r010dx i3-4012Y Win8.1, 4GB RAM and 500GB Hybrid HDD”
    Microsoft Registered Refurbisher
    Registered Microsoft Partner
    Apple Certified Macintosh Technician Certification in progress.

  • Help for Help

    Hi
    I remember i have used a SAP Help wich shows a window when we can write a word and it shows the documentation help for that word.
    This is like help window showed when we press F1 in some code line in ABAP program for search help for some ABAP command.
    But i use that Help called from F1 in ABAP code line i do not find where can i write other Word for search help for that Word.
    Then, i tried using the transaction ABAPHELP but in my system we do not have access to this Tcode.
    Does somebody knows how can i go to SAP Help where i can write a Word for search Help for it ?
    Regards
    Frank

    Hi,
    As mentioned above, you are most likely talking about this litte blue "i" icon in SE38 or SE80. It allows to enter abap keyword, glossary, index and lots of others. Just use this one for searching any SAP documentation. There is also online manual available there.
    You can also use below transactions and if not authorized run their respective programs.
    ABAPDOCU - program -> SAPMSABAPDEMOS_TREE
    ABAPHELP -  program -> SAP_HELP_ABAP
    The second you mentioned you are not authorized to call, simply use the program instead.
    Hope this 'help on help' will help
    Marcin

  • No support for pse4, need help with help and everything else.What's a layer? How can I get help PDF from CD? I don't have a clue how to use this. I have a Macbook pro.

    Need help with help pse4 not supported by adobe. how to do topics not available and I have never used any thing like this. Help says there is a download but have not been able to get it. What's a rookie to do ? Is there somewhere I can go to find out how to use PSE4?

    The internet is overflowing with tutorials on PSE. Just google what you want and include Photoshop Elements 4 as part of your search term, or  go to the library and they may have several different books on PSE 4. For PSE 4, you won't find a mac specific book, but that doesn't matter because the editor is the same on either program. Just substitute Command for Ctrl and Option for Alt in the keystrokes, and ignore anything about the organizer.
    Some popular sites for learning elements:
    http://www.photoshopelementsuser.com/
    lynda.com
    eclecticacademy.com
    youtube has a lot of video tutorials, too.

  • I need help with Help

    I have the Apple docs on "providing assistance ..." and the specs on HTML 4.01 & XHTML 1.0. Since I am writing software just for myself, I don't want to spend megabucks on Dreamweaver or GoLive in order to write help files. Is there a poor man's route to writing these files? I don't need anything fancy - just plain text will do for most of it.
    I believe I saw somewhere that IB could help but I can't find anything there. I am using Xcode 2.4.1.
    There is a note in "providing assistance ..." that an example is at /Library/Documentation/Help/MacHelp.help/Contents/Resources/. How do I see into this filewrapper?
    Pete

    You can use any text editor, just save the file as .html instead of .txt
    To get an idea of how to write help content you can look at the help books of existing applications. To see one, go to:
    Library > Documentation > Help
    Right-click on one of those and choose "show package contents" to see whats inside.
    You can also check out the help content in application (lets say ichat) by right clicking on the app and choosing show package contents, then go to:
    Contents > Resources > English.lproj > iChatHelp
    You can copy these files and modify them as you need.

  • HT4009 Ok so my problem is I put $100 on my account an it not letting me buy in app purchases an I'm ticked off to the max an idk how to fix this I bough in app the other day perfectly fine I need help bad HELP me

    Ok so my problem is I put $100 on my account an it not letting me buy in app purchases an I'm ticked off to the max an idk how to fix this I bough in app the other day perfectly fine I need help bad HELP me

    You need to Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • PC crashed. CD-Rom not working. Downloaded CS5 Web Premium but not able to install. Please Help. Help.

    PC crashed. CD-Rom not working. Downloaded CS5 Web Premium but not able to install. Please Help. Help.

    I had problem with my CD-rom, it not able to open. On top of that recently my PC crashed.
    I managed to install other software, but not able to install CS5 Web Premium.
    Ive downloaded the electronic version via Adobe Downloads, but not able install it.

  • Cannot find SAP Input Help (F4 Help) logs

    HI Basis All,
    Somebody changed the layout  in (Input Help (F4 Help) Settings in our PRD environment.
    He logged in SAP in menu Help -->Settings
    Set the F4 help  and changed the display to Dialog (modal).
    I have two questions:
    1-  Is there a way to see by logs who changed the layout?
    I tried ST11 , SM20 and SM21 and did not find nothing.
    2- Is there another way that the below to restrict these access ?
    The way that i find is restricting the objetct S_ADMI_FCD S_ADMI_FCD=F4MX;
    Thanks for all
    Fábio Karnik Tchobnian
    Fábio Karnik Tchobnian

    Hi Fio,
    The Icon (G_BUTTON_CHANGE_SYS) is a Push button and it either exists for an user (S_ADMI_FCD : F4MX) or it does not.
    Tried other ways but looks like the only option is to remove the value F4MX (S_ADMI_FCD object) to avoid end users changing this system setting in Help.
    Rgds,
    Sri

  • MACBOOK WON'T START HELP HELP OMG HELP!!/1/1kghl

    SO! I recently bought a white MacBook and an iPod Nano (gen1 because I wanted them to match). Since then I have had to send in the first iPod, get a second one, and have the exact same problem--neither the MacBook nor the iPod seem to realise at all when they are plugged in. No charging, no syncing with iTunes. Nothing.
    So the customer service bloke told me that I should update OS X. Alright, I toddle on off to Barnes and Noble to take advantage of the Wifi, as I live in the middle of no where and am still on dial-up. Update, update, restart time. I'm supposed to hold down the power button while it restarts.
    Familiar with having to hold down keys while things happen, as I've used Windows all my life, I do. Except, apparently my button-pressing skills are TOO well-honed, because it begins loading and then turns off! Oh no! I may have held that button down a bit too long...
    Easily solved, right? Just boot it up again.
    Except it won't turn on! Well the little flashy LED light goes all flashy, and the thing sort of growls at me like it's in pain. The screen stays black, nothing else happens. I hold down a lot of buttons and still nothing happens. I've been trying turning it on while holding down different buttons, but still nothing. Honestly, I don't handle panic very well.
    So, basically. I am totally freaking out. HELP HELP HELP PLEASE HELP.
    Please pretty please?
    X-POSTED FROM INSTALLATION & WHATNOT FORUMS BECAUSE I AM TOTALLY FRANTIC. Sorry!

    Welcome to Apple Discussions!
    First off, please don't crosspost your question unless instructed to, as it only wastes bandwidth and makes it harder to track who is asking what question.
    Second, sleep it off a night, with your machine unplugged and no battery inserted to get rid of your franticness. It never really pays to be frantic in front of a computer because you don't know what you are doing, and you could be your own worst enemy.
    When you are ready, depress the power button only for 2 seconds and let go.
    If that doesn't work reset the power manager:
    http://docs.info.apple.com/article.html?artnum=303319
    Also try zapping the PRAM if that doesn't work:
    http://docs.info.apple.com/article.html?artnum=2238
    If neither works, are you getting anything on the screen?

Maybe you are looking for

  • I can view the data in front end form, but data is not avilable in backend

    Hi, i created a form with three blocks.In first block i entered the data.Based on the data it will fetch recodrs from A & B tables and insert into C table.This logic i have written in backend and put commit in front end and back end. In the 2nd block

  • Save As with suggested file name and folder

    I would like the user to be able to press a save button on the pdf and the "Save As dialogue box" pops up pre-populated with a file name and location choosen. The user can then choose to name the file something otherwise or select a new location. I w

  • My avg tool bar was working on IE and doesn't seem to with FF6

    running windows 7 ultimate x32 had been using x64 but was having various problems with compatibility,drivers etc so reformatted my hdd and reinstalled 32 bit version. obviously the first thing i did was reinstall my avg internet security 2011 which h

  • Oracle Linux 6 u3 Installation via FTP

    There is a need to install OS (Oracle Linux 6.3) via FTP. The installation process started fine, but after I'd finished with partitions layout and hit "next" on the window displaying "boot loader operating system list", error appeared. the error: "Un

  • Best way to find duplicates

    hello everyone. i'm trying to free up space on my hard drive. what is the easiest way to find and delete duplicate photos and files. specifically in iphoto. thank you.