Want to display a result set of 100 records

I have queried from the databse and got a result set of say more than 100 records on a JSP page.Basically as the records are many I want to display 10 records at a time on the JSP page. Please suggest me how I can do it so that i need not query again and again to the database. May be I can have a "Next" button/link which shows the next 10 records on the same JSP page.. or a sequence of numbered links ( say if i have 150 records, 10records at a time I will have 15 numbered links) so that if i click on that number link i will be shown that coressponding records
How can I acheive this. Is there anything possible with Javascript?
PLease do advice me as I am new to HTML/Javascripting and JSP.
Any information will be greatly appreciated.

Take a peek at a tag based solution :
http://www.dotjonline.com/taglib/grid.jsp
Good luck.

Similar Messages

  • Need help in comparing values to display correct result set

    I have a View Object and Entity I created that point to a View on my database. This view contains a complex custom query that recovers and totals all charges and fees for all properties. However, when this result set is returned I only want to display on the initial screen the Row which contains the information for the current Property selected. However, in trying to implement this I am unsure how to:
    A) Somehow get the Property Id value of the Property currently in the JSP.
    B) Get the value of the Property Id column off each Row to compare to the value obtained in A.
    (I created an exact copy of the RowSetBrowser bean named SRIRowSetBrowser and am trying to add code to control which Rows get sent off to be added to the HTML Table)
    I can not find any documentation or source for the Row class and thus have no way to know if any methods are provided that would help me.
    Any ideas?
    Thanks

    Thats a mistake while modifying the XML.
    The Element is OpenOrder:
    so the XML goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <BOOK_PURCHASE_SR xsi:schemaLocation="http://www.mobily.com/blackberry/request request.xsd"
    xmlns="http://www.mobily.com/blackberry/request"
    xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
    <SR_HEADER>
    <Name>Java</Name>
    <Book>0000</Book>
    <Price>100</Price>
    <Purchase>Y</Purchase>
    <PurchaseDate>20070902153930</PurchaseDate>
    <Requestorname>Rashmi</Requestorname>
    <RequestorLanguage>E</RequestorLanguage>
    <OpenOrder>N</OpenOrder>
    <Chargeable>Y</Chargeable>
    <ChargeAmount>99</ChargeAmount>
    </SR_HEADER>
    <PhoneNumber>1234567890</PhoneNumber>
    <Service>shop</Service>
    <Operation>purchase</Operation>
    <CustomerType>2</CustomerType>
    </BOOK_PURCHASE_SR>

  • Displaying large result sets in Table View u0096 request for patterns

    When providing a table of results from a large data set from SAP, care needs to be taken in order to not tax the R/3 database or the R/3 and WAS application servers.  Additionally, in terms of performance, results need to be displayed quickly in order to provide sub-second response times to users.
    This post is my thoughts on how to do this based on my findings that the Table UI element cannot send an event to retrieve more data when paging down through data in the table (hopefully a future feature of the Table UI Element).
    Approach:
    For data retrieval, we need to have an RFC with search parameters that retrieves a maximum number of records (say 200) and a flag whether 200 results were returned. 
    In terms of display, we use a table UI Element, and bind the result set to the table.
    For sorting, when they sort by a column, if we have less than the maximum search results, we sort the result set we already have (no need to go to SAP), but otherwise the RFC also needs to have sort information as parameters so that sorting can take place during the database retrieval.  We sort it during the SQL select so that we stop as soon as we hit 200 records.
    For filtering, again, if less than 200 results, we just filter the results internally, otherwise, we need to go to SAP, and the RFC needs to have this parameterized also.
    If the requirement is that the user must look at more than 200 results, we need to have a button on the screen to fetch the next 200 results.  This implies that the RFC will also need to have a start point to return results from.  Similarly, a previous 200 results button would need to be enabled once they move beyond the initial result set.
    Limitations of this are:
    1.     We need to use custom RFC function as BAPI’s don’t generally provide this type of sorting and limiting of data.
    2.     Functions need to directly access tables in order to do sorting at the database level (to reduce memory consumption).
    3.     It’s not a great interface to add buttons to “Get next/previous set of 200”.
    4.     Obviously, based on where you are getting the data from, it may be better to load the data completely into an internal table in SAP, and do sorting and filtering on this, rather than use the database to do it.
    Does anyone have a proven pattern for doing this or any improvements to the above design?  I’m sure SAP-CRM must have to do this, or did they just go with a BSP view when searching for customers?
    Note – I noticed there is a pattern for search results in some documentation, but it does not exist in the sneak preview edition of developer studio.  Has anyone had in exposure to this?
    Update - I'm currently investigating whether we can create a new value node and use a supply function to fill the data.  It may be that when we bind this to the table UI element, that it will call this incrementally as it requires more data and hence could be a better solution.

    Hi Matt,
    i'm afraid, the supplyFunction will not help you to get out of this, because it's only called, if the node is invalid or gets invalidated again. The number of elements a node contains defines the number of elements the table uses for the determination of the overall number of table rows. Something quite similar to what you want does already exist in the WD runtime for internal usage. As you've surely noticed, only "visibleRowCount" elements are initially transferred to the client. If you scroll down one or multiple lines, the following rows are internally transferred on demand. But this doesn't help you really, since:
    1. You don't get this event at all and
    2. Even if you would get the event, since the number of node elements determines the table's overall rows number, the event would never request to load elements with an index greater than number of node elements - 1.
    You can mimic the desired behaviour by hiding the table footer and creating your own buttons for pagination and scrolling.
    Assume you have 10 displayed rows and 200 overall rows, What you need to be able to implement the desired behaviour is:
    1. A context attribute "maxNumberOfExpectedRows" type int, which you would set to 200.
    2. A context attribute "visibleRowCount" type int, which you would set to 10 and bind to table's visibleRowCount property.
    3. A context attribute "firstVisibleRow" type int, which you would set to 0 and bind to table's firstVisibleRow property.
    4. The actions PageUp, PageDown, RowUp, RowDown, FirstRow and LastRow, which are used for scrolling and the corresponding buttons.
    The action handlers do the following:
    PageUp: firstVisibleRow -= visibleRowCount (must be >=0 of course)
    PageDown: firstVisibleRow += visibleRowCount (first + visible must be < maxNumberOfExpectedRows)
    RowDown/Up: firstVisibleRow++/-- with the same restrictions as in page "mode"
    FirstRow/LastRow is easy, isn't it?
    Since you know, which sections of elements has already been "loaded" into the dataSource-node, you can fill the necessary sections on demand, when the corresponding action is triggered.
    For example, if you initially display elements 0..9 and goto last row, you load from maxNumberOfExpected (200) - visibleRows (10) entries, so you would request entries 190 to 199 from the backend.
    A drawback is, that the BAPIs/RFCs still have to be capable to process such "section selecting".
    Best regards,
    Stefan
    PS: And this is meant as a workaround and does not really replace your pattern request.

  • Change display of result set from 'showing data as rows, to showing data as one or more columns'

    Hi Everyone,
    I am interested in changing the way that data is displayed in my result set.
    Essentially I want to display a selection of rows (1 to n) as columns, the following diagram explains my intentions -
    Perhaps one of the greatest challenges here is the fact that I do not have a concrete number of rows (or BIN numbers).
    Each stock item could be stored in one or more BINS, which I will not know until running my query.
    Any suggestions here will be greatly appreciated.
    Kind Regards,
    David

    Can you explain on what basis you select those BinLabels? There're lots of other labels also available on your sample data so whats the rule which determines which all BinLabels should be selected?
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    Agree with Visakh16's opinion. In addition, it might be helpful if you can post your DDL here.
    Regards,
    Elvis Long
    TechNet Community Support

  • OBIEE Answers does not display the result set of a report query

    Hi,
    We have a pivot table type of report in Oracle Business Intelligence Enterprise Edition v.10.1.3.3.2 Answers that has the following characteristics:
         3 Pages
         3 Sections , 4 Columns
         18363 Rows in the result set
    As per the NQQuery.log, the query for this report executes successfully resulting in 18363 rows. However, nothing comes up in the display on Answers. Moreover, no error is reported. The instanceconfig.xml file has the following setting:
    <PivotView>
         <CubeMaxRecords>30000</CubeMaxRecords>
         <CubeMaxPopulatedCells>300000</CubeMaxPopulatedCells>
    </PivotView>
    Even with these settings, Answers just returns a blank page - nothing is displayed in the name of the result set of the report query. Has anyone encountered this problem scenario before?
    Any help is much appreciated.
    Thanks,
    Piyush

    Hi Fiston / Pradeep,
    Thanks for your inputs. A few points to note:
    -> I am actually not getting any error message in answers or the NQQuery log. Moreover I am not getting any errors related to "query governor limit exceeding in cube generation" also.
    -> I have other pivot table type of reports in the same repository that work fine. In fact the report which has this issue even works sometimes - what actually is happening is that if I alter the number of sections from 3 to 4, then the result set changes from 14755 Rows to 18363 Rows and as per the NQQuery.log in both cases the query completes successfully. However, when the result set has 14755 rows, I get to see the output in Answers; however when the result set is 18636 rows, the Answers screen just goes blank and does not show any output or error. This makes me believe that there is some parameter in instanceconfig or the NQSconfig file - I have tried a lot of changes but nothing works !
    Any help is much appreciated.
    Best Regards,
    Piyush

  • Want to display the result i n this format

    can any on eplease help me to solve this
    i have a double variable like this Price � $49.50
    in th eresult i want to display it as "49.50"
    but when i try to display if it just gives 49.5
    even if i use the DecimalFormat class

    Try this:
    import java.text.*;
    public class TestClazz {
        public static void main(String[] args) {
            String test = "49.50";
            NumberFormat nf = NumberFormat.getCurrencyInstance();
            System.out.println(nf.format(Double.parseDouble(test)));
    }

  • Remote Call to Blazeds and displaying the result set in grid

    Hi,
    I want to call a remote method using Flex application from Blazeds and display the values in DataGrid. Can anyone help in this ?
    -- I am using AMFChannel
    -- The method to be called is PolicyApnVO.getPoliciesApn()
    -- Please advice any correction if required
    Here is the mxml code :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    creationComplete="initApp()" viewSourceURL="srcview/index.html">
        <!--
        Simple client to demonstrate runtime configuration of destinations.
        The "runtime-employee" destination is configured in
        EmployeeRuntimeRemotingDestination.java.
        -->
        <mx:Script>
            <![CDATA[
                import mx.messaging.ChannelSet;
                import mx.messaging.channels.AMFChannel;
                import mx.rpc.remoting.mxml.RemoteObject;
                [Bindable]
                public var srv:RemoteObject;
                public function initApp():void
                    var channel:AMFChannel = new AMFChannel("my-amf", "http://192.168.102.208:8400/policyAnalytics/messagebroker/amf");
                    var channelSet:ChannelSet = new ChannelSet();
                    channelSet.addChannel(channel);
                    srv = new RemoteObject();
                    srv.destination="runtime-policy";   
                    srv.channelSet = channelSet;
                    srv.PolicyApnVO.getPoliciesApn();
            ]]>
        </mx:Script>
        <mx:Panel title="Policy Details" width="100%" height="100%">
            <mx:DataGrid width="100%" height="100%" dataProvider="{srv.PolicyApnVO.getPoliciesApn.lastResult.data.result}"
                         showDataTips="true">
                <mx:columns>
                    <mx:DataGridColumn headerText="APN Id" dataField="apnId"/>
                    <mx:DataGridColumn headerText="APN Name" dataField="apnName"/>
                    <mx:DataGridColumn headerText="Policy ID" dataField="policyId"/>
                    <mx:DataGridColumn headerText="Policy Name" dataField="policyName"/>
                </mx:columns>
            </mx:DataGrid>
        </mx:Panel>
    </mx:Application>

    There may be other ways to do this but here's what I would do:
    1) add a results method to the remote object:
    src.result="onResult(event.result)";
    2) add the callback method: private function onResult(event : * = null)
    :void{
                                                         if(event is
    ArrayCollection)
                                                                myData =
    ArrayCollection(event);
    3) add the variable: private var myData:ArrayCollection;
    4) make the dataProvider for the grid use the my data :
    dataProvider=""
    You can probably avoid all this by adjusting your dataProvider. I am just
    not sure what it would be without experimenting. But definitely not what
    you have. Maybe just {svc.result}.

  • PDF Off-Line Display:  how to set to 100%

    Hello,
    I have created an offline Adobe Form which is sent to the user via e-mail.  Is there a way either through the Form in SFP or my ABAP that sends to form to set the display of the PDF so it always defaults to 100%? 

    Hi Janice,
    Please check the XML Source code for selected zoom percentage. set the value over there.
    or put your values in java script editor (Palettes-> script editor).
    Regards,
    Ramya R

  • Trying to display a result set in a jsp page

    While trying to do that, i get this exception
    org.apache.jasper.JasperException: An exception occurred processing JSP page /tablasUF.jsp at line 17
    14:
    15: Connection con = src.Connect.connectMe();
    16:
    17: Statement statement = con.createStatement() ;
    18: ResultSet resultset =
    19: statement.executeQuery("select * from UF_CUSTOMER");
    20:
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.NullPointerException
    org.apache.jsp.tablasUF_jsp._jspService(tablasUF_jsp.java:68)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    River_Plate wrote:
    root cause
    java.lang.NullPointerException
    org.apache.jsp.tablasUF_jsp._jspService(tablasUF_jsp.java:68)Do you understand anyway when a NullPointerException would be thrown? Those kind of RuntimeExceptions are basic Java knowledge.
    If an object is null while you want to access it, then a NPE would be thrown. Check the line of the cause which objects could be null and fix it accordingly.

  • Browsing result set in gui

    how do i browse resulr set one by one
    i try to do
    but it place me in last row
    stat = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    res = stat.executeQuery("Select * from netTable");
              while(res.next())
              l1.setText(res.getString(1));
                    l2.setText(res.getString(2));
              }stat Statement instance,res ResultSet Instance,l1,l2 labels

    Karamjeet, my East Midlands friend, I don't think you want to display each row, 'one by one'. Rather I think you meant to say that you want to display the result set in tabular form. Whether you choose to use a JTable, an HTML table, or a piece of paper on the dining room table is up to you but my esteemed colleague georgemc is correct. Don't use that loop!
    Jai Hind.

  • Servlet could nt able to Display the Result Page By Page ( Paging Problem)

    Hi, I want to display my result set Page by page... i wrote the code but it is not working properly... just it is showing intial record page(i.e 0 to 5) and page number links, But when i click on those number hyper links, just it is coming empty pages...
    plz help me out Thanks a lot in advance..... and my code is
    package tauvex;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.sql.DriverManager.*;
    public class TauvexDataServlet extends HttpServlet {
    Connection con=null;
    Statement statement=null;
    ResultSet resultset=null;
    public void init(ServletConfig config) throws ServletException {
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost/fitstestdb","root","");
    } catch (ClassNotFoundException ex) {
    System.err.println("ClassNotFoundException: " + ex.getMessage());
    throw new ServletException("Class not found Error");
    } catch(java.lang.InstantiationException ie) {
    System.out.println("instantiation exp:"+ie);
    } catch(java.lang.IllegalAccessException ia) {
    System.out.println("illegalaccess exp:"+ia);
    } catch (SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    protected void processRequest(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    +*// From Here My problem Starts*_+ 
    // Code For Paging starts
    int pages=0;
    try{
    Connection ocon = null;
    Class.forName("com.mysql.jdbc.Driver");
    ocon = DriverManager.getConnection("jdbc:mysql://localhost/fitstestdb","root","");
    Statement stmtt = ocon.createStatement();
    ResultSet rc = stmtt.executeQuery("Select count(*) from FitsData ");
    rc.next();
    pages = rc.getInt(1);
    out.println("Count of Records : " + pages + "<br>");
    catch (ClassNotFoundException ex) {
    System.err.println("ClassNotFoundException: " + ex.getMessage());
    throw new ServletException("Class not found Error");
    } catch (SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    int cPage;
    cPage = (pages / 5) + 1;
    if ((cPage * 5) + 1 >= pages)
    cPage++;
    out.println("Count of Pages : " + (cPage - 1) + "<br><p><p>");
    int p;
    for(p = 1; p < cPage ; p++)
    out.println("<a href=TauvexDataServlet?mv=" + p + ">"+ p +"</a> | ");
    out.println("<hr>");
    // paging
    int cpage;
    int currentRs;
    String pt;
    pt = request.getParameter("mv");
    if (pt == null)
    currentRs = 0;
    else
    cpage = Integer.parseInt((String)pt);
    currentRs = 5 * (cpage - 1);
    out.println(cpage + "<br>");
    //Paging Code End here
    *// My problem ends here ...!!!*
    String RA=new String();
    String DEC=new String();
    String DATE=new String();
    String DATE1=new String();
    String FILTER=new String();
    String Radious=new String();
    String ShowRA=null;
    String ShowDEC=null;
    String ShowFile=null;
    String ShowQuery=null;
    String ObservationDates=null;
    String Telescope=null;
    String Filter=null;
    RA=request.getParameter("RA");
    DEC=request.getParameter("DEC");
    DATE=request.getParameter("DATE");
    DATE1=request.getParameter("DATE1");
    FILTER=request.getParameter("FILTER");
    Radious=request.getParameter("Radious");
    ShowRA=request.getParameter("ShowRA");
    ShowDEC=request.getParameter("ShowDEC");
    ShowFile=request.getParameter("ShowFile");
    ShowQuery=request.getParameter("ShowQuery");
    ObservationDates=request.getParameter("ObservationDates");
    Telescope=request.getParameter("Telescope");
    Filter=request.getParameter("Filter");
    String query = "SELECT * " +
    " FROM FitsData limit "+currentRs+",5;";
    try {
    Statement statement=con.createStatement();
    ResultSet resultset=statement.executeQuery(query);
    if(ShowQuery != null && "on".equals(ShowQuery))
    out.println("<font size=4 color=black>The Selected Query is :</font><br/>");
    out.println("<font>");
    out.println(query);
    out.println("</font>");
    out.println("<hr>");
    if(resultset.next()!=false) {
    out.println("<html><head>");
    out.println("</head><body>");
    out.println("<table cellspacing=1 cellpadding=1 border=1>");
    out.println("<tr>");
    if(ShowFile != null && "on".equals(ShowFile))
    out.println("<td> Filename </td>");
    if(ShowRA != null && "on".equals(ShowRA))
    out.println("<td> RA_START </td>");
    if(ShowRA != null && "on".equals(ShowRA))
    out.println("<td> RA_END </td>");
    if(ShowDEC != null && "on".equals(ShowDEC))
    out.println("<td> DEC_START </td>");
    if(ShowDEC != null && "on".equals(ShowDEC))
    out.println("<td> DEC_END </td>");
    if(Telescope!=null && "on".equals(Telescope))
    out.println("<td> TELESCOPE </td>");
    if(ObservationDates !=null && "on".equals(ObservationDates))
    out.println("<td> STARTOBS </td>");
    if(ObservationDates !=null && "on".equals(ObservationDates))
    out.println("<td> ENDOBS </td>");
    if(Filter!=null && "on".equals(Filter))
    out.println("<td> FILTER </td>");
    out.println("</tr>");
    while(resultset.next())
    Object o1 = resultset.getObject(1);
    Object o2 = resultset.getObject(2);
    Object o3 = resultset.getObject(3);
    Object o4 = resultset.getObject(4);
    Object o5 = resultset.getObject(5);
    Object o6 = resultset.getObject(6);
    Object o7 = resultset.getObject(7);
    Object o8 = resultset.getObject(8);
    Object o9 = resultset.getObject(9);
    out.println("<tr>");
    if(ShowFile != null && "on".equals(ShowFile) && o1 != null)
    out.println("<td>"+o1+"</td>");
    if(ShowRA != null && "on".equals(ShowRA) && o2 != null)
    out.println("<td>"+o2+"</td>");
    if(ShowRA != null && "on".equals(ShowRA) && o3 != null)
    out.println("<td>"+o3+"</td>");
    if(ShowDEC != null && "on".equals(ShowDEC) && o4 != null)
    out.println("<td>"+o4+"</td>");
    if(ShowDEC != null && "on".equals(ShowDEC) && o5 != null)
    out.println("<td>"+o5+"</td>");
    if(Telescope!=null && "on".equals(Telescope) && o6!=null)
    out.println("<td>"+o6+"</td>");
    if(ObservationDates !=null && "on".equals(ObservationDates) && o7!=null)
    out.println("<td>"+o7+"</td>");
    if(ObservationDates !=null && "on".equals(ObservationDates) && o8!=null)
    out.println("<td>"+o8+"</td>");
    if(Filter!=null && "on".equals(Filter) && o9!=null)
    out.println("<td>"+o9+"</td>");
    out.println("</tr>");
    out.println("</table>");
    out.println("<br>");
    out.println("</body>");
    out.println("</html>");
    else {
    out.println("NO MATCHING RECORDS FOUND");
    } catch(java.sql.SQLException sqle) {
    System.out.println("sql exception:"+sqle);
    out.close();
    protected void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    public String getServletInfo() {
    return "Short description";
    }

    I also did a Servlet Paging but I later found a Paging example that used MVC architecture which I found to be more efficient.
    This post has a good example in this link: http://forums.devshed.com/java-help-9/paging-in-jsp-85968.html?p=382695#post382695
    After I downloaded the example I made alot of changes and got rid of the scriptlets in the JSP and brought it more up to date using JSTL.
    Also check out a pre-built tag: http://displaytag.sourceforge.net/

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Returning total sum plus pivoted sums in same result set

    I want to return a result set in the following format:
    YEARMONTH Total ModelA ModelB ModelC
    200101    0     0      0      0
    200102    10    5      5      0
    200103    8     2      2      4where the total is the sum of the hours for all model types grouped by yearmonth, and the individual model columns are the sum of hours per model type grouped by yearmonth. I can get the correct results using the following query with nested selects:
            select distinct yearmonth,
         sum(a.hours) as Total,
         (select sum(b.hours) from model_hours b
             where model = 'ModelA' and a.yearmonth = b.yearmonth) as ModelA,
            (select sum(b.hours) from model_hours b
             where model = 'ModelB' and a.yearmonth = b.yearmonth) as ModelB,
            (select sum(b.hours) from model_hours b
             where model = 'ModelC' and a.yearmonth = b.yearmonth) as ModelC
        from model_hours a
        group by yearmonth
        order by yearmonthI was curious to try using the pivot function in Oracle 11 to achieve the same results, and am able to get all the results EXCEPT the total hours using the following query:
        select * from (
             select yearmonth, hours, model
             from model_hours a
        pivot
             sum(hours)
             for model in ('ModelA', 'ModelB', 'ModelC')
        order by yearmonthwhich returns this result:
    YEARMONTH  ModelA ModelB ModelC
    200101     0      0      0
    200102     5      5      0
    200103     2      2      4I have not been able to figure out how to also get the sum of the hours for all models, grouped by yearmonth, into this resultset. Is it possible? And if so, would it be likely to be more efficient than the nested selects? This particular table has some 200K rows right now.

    Hi,
    923402 wrote:
    Frank, thank you so much. I added a bunch of nvl() functions and it works now. Didn't have a chance to try it with the other answer but it looks like it would be similar.
    I'm still curious as to whether doing it this way is more efficient than my original query, using nested selects.Definitely! Scalar sub-queries, like you did in your first message, will require multiple passes through the table. SELECT ... PIVOT only requires one.
    Here's another way that should be as efficient as SELECT ... PIVOT:
    SELECT       yearmonth
    ,       SUM (hours)                                   AS total
    ,       NVL (SUM (CASE WHEN model = 'ModelA' THEN hours END), 0)     AS modela
    ,       NVL (SUM (CASE WHEN model = 'ModelB' THEN hours END), 0)     AS modelb
    ,       NVL (SUM (CASE WHEN model = 'ModelC' THEN hours END), 0)     AS modelc
    FROM       model_hours
    GROUP BY  yearmonth
    ORDER BY  yearmonth
    ;The NVLs are only necessary for display; you don't need them to get the correct total.
    I don't have access to a SQL efficiency testing program; otherwise, I'd test it myself; if you don't think you can answer I'll just give it to our overworked DBA. Ask your DBA if you can use EXPLAIN PLAN.

  • Working with result set i need a solution..... plz treat it as urgent

    i have a query which returns 12 records so the result set contains 12...
    now i want to display in the set of 5 rows... so
    out put must me
    Name Rate Name Rate Name Rate
    1 6 11
    2 7 12
    3 8
    4 9
    5 10
    how can i achieve this output...
    I guess this will clear the question......

    You create a for loop that indexes from 1 to 5. You get a row(item) from the result each time through the loop. You all check next() and break out of the loop when it returns false.

  • Newbie thread about global variables and result set

    Hello everyone this is my first post, im from colombia and now im learning about this world !! the WCC !!
    Now im doing a practice but im so noob that i cant get it so far... i wrote some of the oracle documentation.. and it was so usefull for starting.. but now im trying to do custom components builded in java + resources + services + template etcc .. all good stuff :D.
    i want to retrieve a result set coming from a custom service ... and then i want to store this result set in some kind of global variable !! why ? because i want to use this data from the result set again and again without making more call to the service !!
    ive tried to copy this resultset but i think it cant be done because i use a popUp window to display the rows from the RS.. and when i close the window .. it dies!!
    i want to use this RS for 3 custom metadata field.. but i have no idea how to do this....
    this is a part of my custom resource
    <$if fieldName like "xElaborador"$>
    <$executeService("SERVICE_ALLUSERS")$>
    <$trace(" ### executing service ###","#log")$>
    <!--i tried to copy the rs here but this is wrong i guess -->
    <$nuevoRS="usuarios_LDAP"$>
    <$endif$>
    <!-- usuarios_LDAP is the RS parameter coming from the java calss -->
    <$if rsExists("usuarios_LDAP")$>
    <$if rsFirst("usuarios_LDAP")$>
    <$loop usuarios_LDAP$>
    <$trace(" ### inside RS ###","#log")$>
    <$include each_user_LDAP$>
    <$endloop$>
    <$else$>
    <$include therearenotusers$>
    <$endif$>
    <$endif$>
    <!-- THIS CODE IS USELSS BASICALLY-->
    <$if fieldName like "xRevisor"$>
    <$if rsExists("nuevoRS")$>
    <$if rsFirst("nuevoRS")$>
    <$loop nuevoRS$>
    <$trace(" ### inside rs for revisor ###","#log")$>
    <$include each_user_LDAP$>
    <$endloop$>
    <$else$>
    <$include therearenotusers$>
    <$endif$>
    <$endif$>
    <$endif$>
    pls tell me if im too lost im all ears to learn the good practices for this tool.

    Hi ,
    One of the good resource on this topic is :
    http://jonathanhult.com/blog/2012/11/resultset-versus-dataresultset/
    Thanks,
    Srinath

Maybe you are looking for

  • Photoshop CC 2014 for Mac Error With Display Driver

    I keep receiving this error and then Photoshop crashes. Has anyone encountered this issue and if so how did you resolve it? I am using a Targus docking station and I had to download this driver: Driver Name: Video, Audio, and Ethernet Software for Ma

  • Not able to run installer when booting (Snow)Leopard on MacBook Pro Unibody

    Hi all. I would very much appreciate any help with this issue... I have recently installed an app called monolingual(stay away from it - don't touch it with a stick) - I thought I'd get a couple of GBs off my HDD by deleting the surplus languages...

  • Can't export to for publishing or upload -- error (-50)

    Trying to finish a movie project which is about 60 minutes in length (finished product). Using my older 2007 MacBook Pro which has limited memory but have emptied out almost all over non-movie files. When I click on "export movie" it seems to start t

  • Problem with USB HP webcam?

    Hi there, I am helping my client use video with Adobe Connect. She is the only one on our team who cannot make her webcam work when we are an Adobe Connect meeting. She has a Thinkpad with Windows. She also has a HP Webcam 2100 that plugs into the US

  • Best way to match colors

    I am editing in Premiere Pro CS3.  This was a two camera shoot.  The film camera had very pleasant color, the digital camera had rather flat looking colors.  What is the best means to trying and bring the viberance of the film clips to the digital cl