How do i display every 10 Records in my JSP page??

Hi..
I have developed one web-page which shows ALL employee records fetched from a employee table and display them in my JSP page.
It has contain more than 1000's of records. I need to display first 10 Records in my page. There should be some 4 links below the records display which get me to see next 10 records or previous 10 records or first 10 records or Last 10 records.
IS it possible in JSP??
This is my sample code for your ref:
<jsp:useBean id="empOperation" class="com.venki.gen.EmployeeOperation" />
<html>
<head>
     <title>Stardeveloper : DataAccess JSP Tag</title>
     <style>
     p, td { font-family:Tahoma,Sans-Serif; font-size:8pt;
          padding-left:15; }
     </style>
</head>
<body>
<p align="center"><u>DataAccess JSP Tag</u></p>
<%
     EmployeeList empList[] = null;
     empList = empOperation.getEmployees(empName);
%>
<table align="center" border="0" width="90%" cellspacing="2" cellpadding="2">
<tr bgcolor="#CCDDEE">
     <td>EMPNO</td>
     <td>EMP Name</td>
     <td>DESIGNATION</td>
</tr>
<%if(empList!=null)
     for(int i=0; i<empList.length; i++)
      EmployeeList emp = empList;%>
     <tr bgcolor="#F7F7F7">
     <td><%= emp.getEmpNo() %></td>
     <td><%= emp.getEmpName() %></td>
     <td><%= emp.getEmpDesignation()%></td>
     </tr>
     <% }%>
</table>
</body>
</html>
It would be extremely useful,if i know the technique how to display every 10 Records thru JSP.
Waiting for You people valuable reply and code!
Regards
venki

I do it by pages. i.e. http://example.com/page.jsp?page=1 would show records 1-10, ?page=2 would show records 11-20
let's pretend each record is identified by one field in the database, `id`
then the SQL query you'd use to grab the records could be..
SELECT * FROM `your_table` WHERE `id` >= (page*10) and <= (page*10+10)or this might even work:
SELECT * FROM `your_table` ORDER BY `id` ASC LIMIT (page*10),10(all examples untested as I'm at work :P)

Similar Messages

  • How do you display images relative to a Portlet JSP page?

    For Welblogic Portal 7.0, I want to display a simple image (.gif) on a JSP page.
    The problem is that I need to use a 'hard coded' url to the image such as the following:
    <img src="portlets/test/images/test.gif" border="0" alt="Test 1">
    - OR -
    <img src="<webflow:createResourceURL resource="/portlets/test/images/test.gif" />"
    border="0" alt="Test 2">
    This makes the portlet less portable.
    My goal is to display an image relative to the current JSP Portlet page (in the test
    directory).
    Does anyone know how to accomplish this?
    In WL Portal 4.0 I used:
    <img src="<%=fixupRelativeURL(pathFromRequest(request) + "images/test.gif", request)%>"
    width=24 height=22 border=0 alt="test">
    This does not work anymore as fixupRelativeURL does not seem to exist in the 7.0
    API.
    Your help would be greatly appreciated!
    Thanks,
    Matt

    Exactly what I was looking for!
    Thank you Subbu.
    Subbu Allamaraju <subbuATBeaDOTCom> wrote:
    Matt,
    There is an indirect way to achieve this.
    (a) In your portlet JSP, get the PortletState. There is an example in
    /framework/portlet.jsp.
    (b) Get the content URL for this portlet by calling
    portletState.getUrl(Portlet.URL_CONTENT).
    Depending on where your image is (with respect to the content URL), you
    can construct a new URL to the image. For example if your content is at
    at /portlets/myportlet/foo.jsp and your image is in at
    /portlets/myportlet/images/myimage.gif, you can reconctruct the latter
    from the first one.
    Once you do this, prepend the constructed URL with the web app context
    root (request.getContextPath()).
    Hope this helps.
    Subbu
    matt wrote:
    For Welblogic Portal 7.0, I want to display a simple image (.gif) on aJSP page.
    The problem is that I need to use a 'hard coded' url to the image suchas the following:
    <img src="portlets/test/images/test.gif" border="0" alt="Test 1">
    - OR -
    <img src="<webflow:createResourceURL resource="/portlets/test/images/test.gif"/>"
    border="0" alt="Test 2">
    This makes the portlet less portable.
    My goal is to display an image relative to the current JSP Portlet page(in the test
    directory).
    Does anyone know how to accomplish this?
    In WL Portal 4.0 I used:
    <img src="<%=fixupRelativeURL(pathFromRequest(request) + "images/test.gif",request)%>"
    width=24 height=22 border=0 alt="test">
    This does not work anymore as fixupRelativeURL does not seem to existin the 7.0
    API.
    Your help would be greatly appreciated!
    Thanks,
    Matt

  • How can i hand the RowSet to the next jsp page

    In a jsp page, I get a RowSet as the following:
    <input type="hidden" name="result" value="<%=ds.getRowSet()%>">
    I want to handle with this RowSet in the next jsp page, so
    I do in the next jsp page as the following:
    <% RowSet rowset = (RowSet)request.getAttribute("result"); %>
    But I was told null error. How can i hand the RowSet to the next jsp page.Help. Thanks a lot!

    Hello Charles,
    I did the registration in the same way as in the JDeveloper 3.2.3 (see follows)
    // make sure the application is registered
    oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "ReefBC_BCPackage_BCPackageModule");
    The argument ReefBC_BCPackage_BCPackageModule is a property file (ReefBC_BCPackage_BCPackageModule.properties). After some tries, I can still use it in JDeveloper 9i R2. The reason to keep it is that there would be a lot of migration work of javabean calling if I change it to <job:DataWebBean..>. But I am wondering, do I initialize two application modules when I use registerApplicationFromPropertyFile() and <jbo:ApplicationModule..> in the same page.
    The problem in doStartTag() is found after I post "http://forums.oracle.com/forums/thread.jsp?forum=83&thread=155210&tstart=75&trange=15", by tracing into the <jbo:ApplicationModule..> after calling the OrdHttpUploadFormData. HtmlServices.getRequestParameters sends back an exception, that breaks the running of the program. It was temperorily solved by extending the ApplicationModuleTag. If <jbo:..> could use the application module initialized by registerApplicationFromPropertyFile(), I guess it may be a better workaround.
    Long postings are being truncated to ~1 kB at this time.

  • 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.
    />

  • How to display XML file(as markup) in jsp page..?

    Hi All,
    * I have to display the XML file(as markup) in jsp page (Tree Format)....
    * My XML file is an java.io.file object , and how to view this XML file on my JSP page...........
    Thanks in Advance,
    JavaImran

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • How to display result in more than one jsp page

    Hi all,
    the result is a very large it will take more than one jsp page in this senario how we will display the result in more than one jsp page.
    Thanks in Advance.

    The magic word is "paging". Look around using this keyword.
    Basically it's all about subquerying, (eventually) caching and sublisting.

  • How to display a variable(non editable)  in JSP page?

    I have this java code in my JSP and I want to print it on the JSP page with a name associated to it so that it can be passed to a Java Bean. How can I do it?
    String user = display.getOwnerName();

    whatever value you want to send it to server side, you have to put it in a "form". You can put it in HTML form input tag , JSP form, Struts form or JSF form.
    for example:
    <form action="getUserProfile.do">
    <input type="text" value="<c:out value='display.ownerName' />" />
    </form>
    kind regards

  • How to display a document content in a JSP page

    Hi friends,
    I am trying to display a document's content in a JSP page after user authentication.For that I mapped a jsp file with extension ".sens" in Content Management SDK manager,and put the file in the directory '/ifs/jsp-bin' of webstarterapp,but it is not working.Please help me to solve the probleb as earliest.
    Regards
    Prasenjit

    under view put a new tag
    <f:view>
    <ui:script url="page.js"/>
    and thats it

  • How to open a new browser window from a JSP page?

    Hi,
    I am picking up records from the database and displaying each record in a seperate text area field using the JSP code. I should be able to display the content ( available in the text area) in a seperate window if the user clicks on one icon.
    Is it possible to open a new browser window using JSP? If yes, how can I write information on the new browser window?
    Thanks in advance.

    Is it possible to open a new browser window using JSP?a JSP page is also an HTML page, this is client side stuff, you can do it with JavaScript.

  • How to use one ResultSet many times in a jsp page ?

    Hi all,
    I have .jsp page and I have used it to get data from DB and display them to users. So I have to get data from DB in number of places in this particular jsp.
    I thought that it is better to have one ResultSet for entire page and once it is done its job, the ResultSet will be closed and I can use it again and again like this.
    Resultset rs = new ResultSet();
    try{
        //My operations
    }catch(Exception ex){
       //Handle Exceptions
    }finally{
       rs.close();
    }After above code snippet I can use same ResultSet again below the page.
    I just want to know this,
    1. is this a good coding practice?
    2. Should i put rs = null; within finally clause?
    any help will be appreciated
    thank in advance,
    Dilan.

    Ok, Finally I switched my coding to use DAO and DTO, and I learned it through internet.
    I removed all of data access codes from my jsp file(lets say 'functions.jsp'). I then created one interface and two clasess.
    here is my DAO interface.
    public interface UserFunctionsDAO{
        public List<UserFunctionsDTO> selectUserList();
    }here is DTO class
    public class UserFunctionsDTO{
        private String category = "";
        private String sub_category = "";
        private int cat_id = 0;
        private int sub_cat_id = 0;
        public UserFunctionsDTO(){}
        public UserFunctionsDTO(String category, String sub_category, int cat_id, int sub_cat_id){
            this.category = category;
            this.sub_category = sub_category;
            this.cat_id = cat_id;
            this.sub_cat_id = sub_cat_id;
        //Setters and getters will go here.
    }my concrete data access class is like this.
    public class UserFunctionsDataAccess implements UserFunctionsDAO{
        MyDB dbObject = null;
       private static final String SQL_GET_DISTINCT_CAT= "SELECT DISTINCT cat FROM cat_table";
       public List<UserFunctionsDTO> selectUserList(){
           dbObject = new MyDB();
           dbObject.sqlSelect(SQL_GET_DISTINCT_CAT);
           ResultSet rs = dbObject.getResultSet();
           ArrayList list = new ArrayList();
           while(rs.next()){
               list.add(new UserFunctionsDTO(rs.getString('category'), .......................));
           return list;     
    }I think now im following good coding practices, but I have one problem.
    1. How do I retrieve this userlist from my jsp page?
    2. Should I include UserFunctionsDTO in my jsp page as a bean?
    3. If I include it, how can I get the list from it?
    thanks in advance,
    Dilan.

  • Display the "sum(getcount)* in the jsp page??

    I've this table in my database:
    [ode]
    phone ! model ! version ! count
    123 abcd sis 1
    234 asdfas sis 2
    345 werwer jad 6
    342 xcvxcv sis 3
    678 jlkj jad 2
    I want to display the the total number of count on my jsp page using jdbc connection. So, in this case the result should be 14 because the total number of count is (1+2+6+3+2). I know the SQL command as
    "select sum(count) from table_name" but how to display the result on my jsp page. Please help me out. I tried but it's not happening......
    in advance thanks.......

    Hi,
    look at my answer to your post regarding length of resultset. It is the same here.
    Statement stmt = con.createStatement() ;
    ResultSet rs = stmt.executeQuery("select sum(MYTABLE.id) from MYTABLE where MYTABLE.ID > 123") ;
    rs.next() ;
    BigDecimal bdRowCount = rs.getBigDecimal(1) ;select count or select sum return a resultset with one row. You can access this resultset like any other. The row has one field containing a number which you can access as a BigDecimal (like shown above).
    It really is not that fdifficult to do. If you have done it with count you can do it with sum, avg etc. The limit is only set by the functions your database provides. You can have something like
    select count(*), avg(colname1), sum(colname2),sum(colname3) from table,
    which would return a resultset still containing only one row, but within that row 4 fields, each a BigDecimal.

  • How can I Locate the correct filepath in a jsp page?

    In http://localhost:8080/myweb/a.jsp, I will call a java bean file which is locate in http://localhost:8080/myweb/WEB-INF/classes/haha/DBConnection.class. This java file requires to read an external file which locates in http://localhost:8080/myweb/WEB-INF/classes/haha/db.txt
    My question is how can I get the correct filepath in this environment?
    inputStream = new BufferedReader(new FileReader(????????));
    Only this will work
    inputStream = new BufferedReader(new FileReader("D:\Program Files\Apache Software Foundation\Tomcat 5.5\db.txt"));
    But no one will place the file here, and it is impossible to do this when upload to 3rd party hosting.
    Any suggestion? thx.

    Thx all, in a jsp page, calling this method is fine.
    ServletContext s = getServletContext();
    String a = s.getRealPath("/");
    In a Servlet file, below method is ready to use:
    String b = getServletConfig().getServletContext().getRealPath("/");
    My problem is, I have a jsp page, which initialize a java bean , this java file is responsible for Database Connection, which will read the external text file to get the login, password and database name. So I won't need to recompile this file every time when I place in different platform with different configuration. I only need to edit the text file is ok.
    But How can I get the absolute file path when that jsp page initialize that java bean file? Below is my error, any suggestions are thx.
    package sql;
    import java.sql.*;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DBConnection extends HttpServlet{
    public String sql = null;
    public Connection con = null;
    public Statement statement = null;
    public ResultSet rs = null;
    private BufferedReader inputStream = null;
    private static ArrayList<String> arr = new ArrayList<String>();
      public DBConnection(){
        String fs = System.getProperty("file.separator");
        ServletContext s = getServletContext();
        String realpath = s.getRealPath("/");
        String filepath = realpath + "WEB-INF"+fs+"Properties"+fs+"db.txt";
        try{
          inputStream = new BufferedReader(new FileReader(filepath));
          String l;
          while ((l = inputStream.readLine()) != null) {
            arr.add(l);
          Class.forName("com.mysql.jdbc.Driver");
          this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+arr.get(0)+"?user=" +arr.get(1)+ "&password="+arr.get(2)+"&useUnicode=true&characterEncoding=utf-8");
          this.statement = this.con.createStatement();
        }catch (Exception e){
          System.err.println(e.getMessage());
        }finally{
    }java.lang.NullPointerException
         javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
         sql.DBConnection.<init>(DBConnection.java:20)
         html.ShowCategory.<init>(ShowCategory.java:17)
         org.apache.jsp.left_jsp._jspService(left_jsp.java:66)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • How to call a concurrent program from a Custom JSP page.

    Hi,
    I have a custom JSP page which i have deployed by creating a form function with the path of the JSP Page
    and added the JSP Page to the OA_HTML top.
    Now, i need to call a concurrent program from the JSP Page, i have all the parameters in my page and i am using the standard class as below:
    ConcurrentRequest cr= new ConcurrentRequest(con);
    int requestId= cr.submitRequest("XXINV",programName,null,null,false,vec);
    I have verified my connection object and it is OK but i am getting the exception that user is not set to run the program.
    I tried the below code in my JSP page and getting -1 for all test variables :-
    int userId = wctx.getUserId();
    int respApplId = wctx.getRespApplId();
    int respId = wctx.getRespId();
    I think i need to set the context in JSP page to run the program..
    Pls help ....
    Regards
    Saurabh Jaiswal

    Hi,
    Thanks for the reply,,,
    This is a possible solution but this will allow to run the program anyhow.
    But the procedure which i call thru callable statement will start with
    fnd_global.apps_initialize (3825, 50603, 704);
    fnd_request.submit_request API call.
    Now, the values of user and Responsibilty is required in the program and it changes.
    With this approach we have to hardcode the user and resp.
    The same JSP page is attached to other responsibilities and there the concurrent program would get fired as if fired from the resp Id hardcoded as above.
    Need to capture user Id and RespId.
    How can i set the apps Context in JSP page???
    Regards
    Saurabh Jaiswal

  • How do I call a 10g report from a jsp page securly?

    How can I call a report from a jsp page securly? We are migrating from 10g forms to J2EE, and we want to keep using our reports. In forms we were able to do this using a cookie. How can I pass a users credentials to reports without the user having to connect to the database? Single Sign-on isn't an option either.
    Thanks,
    Jim

    Hi Jim,
    If you want to pass the user credentials to the report dynamically, then SSO (Single Sign-On) is the only option I can think of.
    If the user credentials can be hard-coded, then the following 2 solutions are possible:
    1. Use cgicmd.dat file, and write the user credentials in the file.
    2. In your report JSP itself, you could write the following:
    <rw:report id="report" parameters="userid=scott/tiger@mydb">
    Navneet.

  • How can I pass a variable  value from first jsp page to thired jsp page

    In my program ,threr are three jsp pages . I want the first pages's variable value in to thired page .How can I acess.
    I used the request.getparameter() ,but when I print the value , null value is getting .

    request parameters only last for one request.
    To save them longer than that you need to save them somewhere.
    Couple of alternatives
    1 - store them to session
    session.setAttribute("username", request.getParameter("username");
    2 - create a hidden field on page 2 and store the value from page 1 there. When you submit page2, you can get it on page3 with request.getParameter again.
    <input type="hidden" name="username" value="<%= request.getParameter("username") %>">

Maybe you are looking for

  • Failover Cluster testing - not working

    Hello We are trying to perform failover testing on OC4J clusters. We have two nodes clustered. On each node we have installed SOA suite - four OC4J instances (home, oc4J_soa, oc4j_wsm, and oc4j_esbdt). This is how we are performing the test: We have

  • Submitting via E-Mail Hides Subforms

    Hello Experts, I have a dynamic PDF that works as planned.  However, there is a bug in the "Submit by Email" function.  The completed form contains various subforms that depending on the Choice Pull-Down selection, specific subforms will display for

  • Error in Applying 3480000 Patch

    Hi, i am facing issue at the time of applying patch 3480000 . Please help? Error in Adpatch Log File: ATTENTION: All workers either have failed or are waiting: FAILED: file czupgpar2.sql on worker 1. FAILED: file czupgpar2.sql on worker 2. FAILED: fi

  • How does the field ABGRU-Reason for Rejection get populated in routines

    Hi All, How does the field ABGRU-Reason for Rejection get populated in routines(VOFM)? BELNR,KPOSN,etc...fields are populated through KOMK and KOMP structures, similar way what structure is used for ABGRU? by the time the control from VA01 comes to r

  • Refresh a bind to a cfdiv

    Ok so I have made a form to update my legal values table.....I have a <cfselect> with a list of the fields......I have that select box bound to a <cfdiv> with the current legal values populated on select of a field....I have a link to this from the f