Limiting output to 10 per page (servlets)

I'm using netBeans to create a servlet that querys the database and displays the results. I'm trying to limit the results to 10 per a page but I'm having trouble. I've referred to Karl Moss's guide to java servlets and attempted to input his coding, but i'm unable to compile clean. Here's the code.
package TranDB;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
* @author tranquel
* @version
public class memberList extends HttpServlet {
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet MemberList</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet MemberList at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("<br>");
Properties props = new Properties();
props.put("user", "username");
props.put("password", "password");
query("sun.jdbc.odbc.JdbcOdbcDriver",
"jdbc:odbc:fitnessDB",
props,
"SELECT First_Name, Last_Name, Address, Telephone, Activities FROM memberList",
out);
out.println("</html>");
out.flush();
out.close();
out.close();
private boolean query(String driverName, String connectionURL,
Properties props, String query,
PrintWriter out)
boolean rc = true;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
long startMS = System.currentTimeMillis();
int rowCount = 0;
try
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(connectionURL, props);
stmt = con.createStatement();
rs = stmt.executeQuery(query);
rowCount = formatTable(rs, out);
catch (Exception ex)
out.println("Exception!");
ex.printStackTrace(out);
rc = false;
finally
try
if (rs != null)
rs.close();
if (stmt != null)
stmt.close();
if (con != null)
con.close();
catch (Exception ex)
if (rc)
long elapsed = System.currentTimeMillis() - startMS;
out.println("<br><i>" + rowCount + " rows in " + elapsed + "ms</i>");
return rc;
private int formatTable(ResultSet rs, PrintWriter out) throws Exception
int rowCount = 0;
out.println("<center><table border>");
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
StringBuffer sb = new StringBuffer("<tr>");
for (int i = 0; i < columnCount; i++)
sb.append("<th>");
sb.append(rsmd.getColumnLabel(i + 1));
sb.append("</th>");
sb.append("</tr>");
out.println(sb.toString());
while (rs.next())
rowCount++;
sb = new StringBuffer("<tr>");
for (int i = 0; i < columnCount; i++)
sb.append("<td>");
sb.append(rs.getString(i + 1));
sb.append("</td>");
sb.append("</tr>");
out.println(sb.toString());
out.println("</table></center>");
return rowCount;
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
Basically can someone help me alter this code to split the html output to 10 rows per a page with a NEXT button to move forward through the results
thanks
tranquel

Search the JDBC forum for pagination.

Similar Messages

  • CS5: Print thumbnails, 7x7 per page limitation + master labels

    I'm testing InDesign CS5 and I have two questions regarding the "Thumbnails" option of the Print window.
    1. Is there a way to define a greater number of thumbs per page?
    I'm working on a 500+ pages book and I'd like to be able to print more than 7x7 thumbs per page in order to discuss the book content with my client. I could print a PDF and then place the pages of thumbs into a new InDesign document but…
    2. A colour label can be define for each Master, finally!, allowing for an easier overview of documents. In this logic, when I print Thumbnails, is there a way to see the label colour on each thumb. Ideally, at the end of the last page of thumbs, I'd like a listing (like a caption) summarizing each colour label next to the Master page name and code with a count of pages.
    Thanks in advance for your guidance. If these options aren't available at all, I'll fill in a Feature Request.

    Set up the document on a page size large enough to hold 4 place cards, but only put one set of fields, in the upper left position. When you do the merge, select multiple records per page and ID will duplicate averything as many times as it will fit according to the spacing limits you set.
    This is covered quite well in Help.

  • Multiple frames in report - Need output on 1 page (not one frame per page)

    Hi
    I have a report with multiple frames and in the output they are printing one frame per page. How can i have one below the other and not have this page break?
    Thx.

    Check the following in frame properties:
    Maximum Records per Page: should be 0
    Page Break Before: should be No
    Page Break After: should be No

  • List Mode as opposed to the silly 20 per page and 220 app icon limitation?

    Does anyone know of a tweak that would allow all apps to be in a list mode as opposed to taking up so much real estate? On an iPod, I can understand why there are only 20 app icons per page but on an aPad, one could easily have several more, and better yet, a list of several apps could be posted on one page. I already filled up my iPad's 11 page, 220 icon limit.
    Silly restriction, that is, only 220 app icons, and then not making adjustments for the larger screen.
    Any input? Thanks in advance!

    The iPad runs the iPhone and iPod Touch OS.
    Firmware update 4.0 will allow for creating a folder for apps.
    http://www.apple.com/iphone/preview-iphone-os/
    Organize apps into folders with drag-and-drop simplicity. Get faster access to your favorites and browse and manage up to 2160 apps at once — many more than the current limit of 180 apps.

  • How to give no of lines per page in alv report

    hi
    could anybody tell me
    how to give no of lines per page in alv report
    i need bottom of page too
    if possible plz send the code too
    it ll be very helpful to me
    thanx
    kals.

    Hi,
    This is possible, using some of the events in the ALV.
    You could use AFTER_LINE_OUTPUT event and call you form after say, a certain line count is reached on the list output.
      MOVE 'AFTER_LINE_OUTPUT' TO gw_event-name.
      MOVE 'AFTER_LINE_OUTPUT' TO gw_event-form.
      APPEND gw_event TO gt_events.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                it_events                = gt_events[]
    and define the form for each event as follows - this would be a dynamic call by the ALV.
    *&      Form  after_line_output
    *       Form for the After Line Output Event in the internal table
    *      --> rs_lineinfo
    FORM after_line_output USING rs_lineinfo TYPE slis_lineinfo.
      IF sy-linno eq v_linno.          "Defaulted value for line count
        perform write_footer.
        NEW-PAGE.
      ENDIF.
    ENDFORM.                    " after_line_output
    For lines per page:
    rs_lineinfo-tabindex would give you the index of the current line in the list, which you could use to read the t_outtab table, and reduce the line count of items displayed on the earlier page.
    There are a few other events too, like BEFORE_LINE_OUTPUT and END_OF_LIST which you can use as required and print the data.
    Regards,
    Anil.

  • Limit records per page in the horizontal looper?

    Might sound confusing, but I'm wondering if/how I can use the horizontal looper to show 30 records per page?
    For example, I have a photo thumbnail collection. I want to show 5 columns and 10 rows. Is there a way to get the looper to put a link to the 'next 50' so the user can see the next 50 thumbnails (starting at thumbnail 51 of course)?
    thanks

    I guessing here but there must be a bit of php code that you can edit that limits the number of records to be displayed instead of the default value of 10.

  • Number of rows displayed per page in an interactive report

    Hi,
    I'd like to know if it's possible to change the values of the select list called 'Rows' in an interactive report (which is displayed in the search bar).
    Indeed, I want to display 16 rows per page and I can only choose among the values 1, 5, 10, 15, 20, 25, 30, 50, 100, 200...
    Thank you for your reply.
    Emilie.

    Hi Tobias,
    Thank you for your help.
    I had already tried this but it's not what I want. What your are saying only limits the values in the select list (for example, if I set to 16, I can't choose values higher than 16 in the select list 'Rows' of the search bar).
    I want to limit the number of rows displayed in the interactive report to 16 per page.
    Any other idea?
    Emilie.
    Hi Emilie,
    Go: Home>Application Builder>Application 301>Page 51>Interactive Report Attributes>Search Bar>Maximum Rows Per Page
    Set to = 16
    Oracle help description: Defines the maximum number to display in Rows Per Page Selector in the search bar.
    Greetings,
    Tobias

  • Limit rows per page, include spacer and format last row on page break

    Hello,
    I am new to BI and would like some help with an issue I don't seem to be able to resolve?
    I have a table that uses two xml group elements (2nd nested inside first) to produce my detail lines.
    Example:-
    First for-each loop runs over shipto details and within this another for-each loop runs over items related to that shipto, all of which results in multiple detail lines.
    I need to limit the number of rows per page and should the data roll over to the next page I need to place a horizontal closing border on the first page's table (only using column borders).
    Also when the data does not fill the page I need to add spacer rows to the page limit?
    I have tried using examples found in these forums, position(), counters etc… but due to having the second detail loop I’m unable to get these working or I’m doing something wrong?
    Your help would be greatly appreciated.

    Hi BIPuser, thanks for the links.
    I have tried some of the examples which I can get working with a single level of detail lines. However when I add the second level of detail lines the position() function seems to fail as my rowlimit appears to be ignored.
    I am also unable to get the $lpp example working because the outer detail loop may only have one xml element and therefore BI assumes only one line is to be printed when in fact the inner xml element detail loop may have further multiple lines. I need to effectively count the outer & inner loops as one to determine the number of lines being processed.
    Example of xml - My table for detail lines needs to include both ShipTo & item number lines grouped as shown, thereby counting & outputting 7 lines in this instance.
    <INVOICE>
    <On_Ship_To_S23> Outer loop
    <On_itm_num_shr_row_S21> Inner Loop
    <On_itm_num_shr_row_S21>
    <On_itm_num_shr_row_S21>
    </On_Ship_To_S23>
    <On_Ship_To_S23>
    <On_itm_num_shr_row_S21>
    <On_itm_num_shr_row_S21>
    </On_Ship_To_S23>
    </INVOICE>

  • Rows per Page for PIVOT view.

    Hi,
    Is there any way we can show limited no of rows in pivot. Rows per Page for PIVOT view.
    on the click on next one should move to the next page.
    Thanks

    Pagination in Pivot Solves your problem at UI Level only.
    Below is the link that guide you how to implement Pagination in Pivot:
    [http://oraclebizint.wordpress.com/2008/01/17/oracle-bi-101332-pagination-in-pivot-tables/]
    Hope it helps you..
    -Vency

  • Create a PDF with 6 slides per page from a ppt ALL on the iPad

    Is there any way to create a PDF file with six slides per page from a PowerPoint presentation using only an iPad (and apps)?
    I know how to do this on a Mac (i.e. Print > 6 per page> save as PDF) but is there a way I can do this all on the iPad?
    Basically i want a way to output a ppt or keynote document with 6 slides per page using only the iPad. I have both Keynote and PowerPoint for iOS on my iPad.
    any help would be much appreciated!!
    p.s. I'm using an iPad 2 running iOS 7.1.2 ( but will be updating to iOS 8 in the next few days when it comes out). Jailbreaking is not an option!!

    iWork for iOS
    Try asking here. It's your best chance of getting an answer.

  • How can I create a one image per page caption sheet that includes the description in Bridge?

    I am trying to find a way to create a one-image-per-page caption sheet for my workflow. I currently place each image into Word and copy the description onto the document, then repeat for each image. I am hoping that there is a way to automate this process using Bridge. I know that it can be done using Lightroom, however, that is not currently an option for me. Is this something that can be done or am I bound, like Sisyphus to Microsoft Word? I have a very limited grasp of scripting, but I feel like this is possible.
    Thanks for any help.

    To create a NetBoot image, you could just put the cluster node in target mode and attach it to your PowerBook. Then use SIU to create the NetBoot image.
    If you're trying to create a backup image of the disk, use hdiutil, or put in in target mode and create the image with Disk Utility.

  • Capturing the output of a JSP page as HTML

    Hi,
    Can anyone tell me if this is possible. I have a JSP page that contains
    information about an order that was just entered (Essentially a
    confirmation page). What I want to do is somehow intercept the output
    stream inside the JSP page and write it to a file, as plain html, which
    I
    will later attach to an email and send to someone.
    Thanks,
    Jordi
    Jordi Pinyol Essi Projects
    Ingeniero de Desarrollo
    [email protected] t +34 977 221 182
    http://www.essiprojects.com f +34 977 230 170

    You won't be able to "intercept" the output since it is the JSP page itself that is doing the writing.
    Will the file that you write the output to reside on the client side or the server side? It sounds like you want to receive the HTML output not as something to view on the browser, but a file you can save and send and use later. If this is the case, one technique that might work is to take advantage of the servlet name mapping feature that is available for registered JSP pages.
    Assuming your JSP pages are registered, you would map your JSP page like:
    <servlet>
    <servlet-name>confirmation</servlet-name>
    <jsp-file>confirmation.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
    <servlet-name>confirmation</servlet-name>
    <url-pattern>/confirmation.out</url-pattern>
    </servlet-mapping>
    What happens is that a request for the URL /NASApp/myapp/confirmation.out gets mapped to the confirmation.jsp JSP page. If you set your MIME type correctly in the JSP page, the HTML output from the JSP page is not properly recognized by the browser causing it to prompt you to save the file.
    I have used this technique to generated CSV files from a JSP page. The browser is completely fooled.
    JC
    Jordi Pi?ol wrote:
    >
    Hi,
    Can anyone tell me if this is possible. I have a JSP page that contains
    information about an order that was just entered (Essentially a
    confirmation page). What I want to do is somehow intercept the output
    stream inside the JSP page and write it to a file, as plain html, which
    I
    will later attach to an email and send to someone.
    Thanks,
    Jordi
    Jordi Pinyol Essi Projects
    Ingeniero de Desarrollo
    [email protected] t +34 977 221 182
    http://www.essiprojects.com f +34 977 230 170

  • Capturing the output of a jsp page and save that output in a WORD .doc file

    Hi,
    This is Naveen. I got stuck up with a problem/doubt. URGENT ! URGENT !
    My doubt is how to capture the output of a jsp page(the content is dynamic generated) and save that output to a MS-Word doc file.
    I know that therez an option of using Servlets Filters, but this concept is supported by Servlet 2.3 spec. and not earlier. And we are working on previous spec. and our web-servers also supports the prev. version and not the 2.3 version.
    If incase, therez a third-party utility for free usage, suggestions are appreciated.
    Hope most of them came across this kind of functional requirement. If anyone of them succeeded in this, please express ur bitter experience if any, faced during the coding.
    Thanks in Advance for help.
    Naveen

    You can set the MIME content type as .doc and try to open the Page.
    res.setContentType("application/vnd.ms-excel"); to generate the Page output as Excel
    res.setContentType("application/vnd.ms-word"); to generate the Page output as MS Word doc
    Hope this helps..

  • 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

  • Display column titles only once per page

    Hello,
    I am a newbie to BIP (R12.1.3). Below is how the output data shows up in my custom template:
    Vendor type lookup : Expense
    Vendor no: A12345 Vendor Name: Test Vendor1 Vendor Category: Expense - Construction
    VENDOR SITE INVOICE# INVOICE DATE DUE DATE INVCT AMT REM AMT PAYMENT METHOD
    ======== ====== ========= ====== ====== ====== ============
    Kannapolis A#12345 03-MAR-12 15-MAR-12 1000.00 1000.00 Check
    Vendor no: B12345 Vendor Name: Test Vendor2 Vendor Category: Expense - Rents
    VENDOR SITE INVOICE# INVOICE DATE DUE DATE INVCT AMT REM AMT PAYMENT METHOD
    ======== ====== ========= ====== ====== ====== ============
    Test Site B#12345 03-MAR-12 15-MAR-12 1500.00 1500.00 EFT
    The column titles repeat for each vendor since the titles are in the for-each loop under the vendor grouping. However, is there a way to restrict the titles to show up only once per page on all the pages? I tried putting the titles outside the vendor grouping but with in the vendor type lookup grouping. It is displaying the titles only on page1.
    Thanks,
    Monkey

    Hi, could you try Inserting the code <?if:position()=1?> before the header of your template and the code <?end if?> after the header of your template.
    See the a sample code below:
    <?if:position()=1?>
    VENDOR SITE INVOICE# INVOICE DATE DUE DATE INVCT AMT REM AMT PAYMENT METHOD
    <?end if?>
    Thanks,
    mr_bip_learner

Maybe you are looking for

  • Enterprise manager is Not Connecting to database

    Hi I installed oracle 10g on my system the installation was successfull but in the enterprise manager console 1.database instance is down 2.Listener is up and running 3.Agent Connection to Instance Status Failed Details ORA-12505: TNS:listener does n

  • Cisco Pix 506 Blocks certain websites in Win 7/Vista but not XP

    We have been using a Pix 506E with Websense for many years and it has worked fine.  We recently got rid of Websense, deleted all references to it in our configuration, and now on Win 7/Vista machines, certain websites are not accessible, yet are acce

  • Analog cameras

    I have three analog/digital capture cards and I can get one camera to show up but the second will not. If I switch the second camera to a digital camera all is well. Got any ideas as to how to trouble-shoot this issue? TIA d

  • Google Sync with Mavericks Calendar totally broken?

    When I go to Internet Accounts and add my google account, Calendar never works. It tries to connect and fails. Console log shows: 28/10/2013 12:26:23.662 pm com.apple.preferences.internetaccounts.remoteservice[73686]: [com.apple.calendar.iaplugin.log

  • How do I change the main home sharing computer?

    I just got rid of my PC and got a Mac.  My main computer for home sharing on iTunes was the PC...how do I change it over to my Mac for home sharing with my macbook and apple tv?