How to do the paging while reading from the file !!!

I've able to display the contents of the file in my jsp as a tabular form. I want to apply the paging concept in my jsp page. As i did in my database project there i's sending the next value as a parameter and it works.
But when i retrieving the value from the file then i'm not able to get particular values anyhow i'm using the concepts of getLineNumber() but unable to get the previous one worked. I want to diplay only the first 20 contents of the file then, by clicking the next button he should be able to view the next 20 contents of the file. Please help me out for this problem. If possible send me the codes too it'll very helpful for me.
in advance thanks....

I hope the following code will help u.
If your bean is:
public class yourBean
private int startIndex ;
private int pageSize ;
private int endIndex ;
public void useBean()
startIndex = 0;
pageSize = 10;
endIndex = pageSize;
public setters and getters for each of the above.
In servlet :
doGet/doPost:
yourBean uBean =
(yourBean)sess.getAttribute("urBean");
int sIndex = uBean.getStartIndex();
int eIndex = uBean.getEndIndex();
int pSize = uBean.getPageSize();
if (sIndex = 0)
//means first time
dont do anything
if ((sIndex >0)&&(sIndex <
uBean.getRecords().size())))
eIndex = sIndex + pSize - 1;
sIndex = eIndex;
//update Indexes to the bean
uBean.setStartIndex(sIndex);
uBean.setEndIndex(eIndex);
sess.setAttribute("urBean",uBean);
res.sendRedirect("yourJSP.jsp",req,res);
In yourJSP.jsp:
<jsp:useBean id="urBean" type="...." scope="session"
/>
<%
int sIndex = urBean.getStartIndex();
int eIndex = urBean.getEndIndex();
for (int
i=sIndex;(i<=eIndex)&&(i<urBean.getRecords().size()))
out.println(....);
if (eIndex >= urBean.getRecords().size())
out.println("NExt");
else
out.println("<a href=yourServlet>Next</a>");
if (sIndex <= 0)
out.println("Previous");
else
out.println("<a href=yourServlet>Previous</a>");
%>

Similar Messages

  • How to avaoid space while reading from flat file

    Dear all
    I am using forms 10g.
    I am reading data from flat file using Text_io.
    In my exception part i have written like this
    EXCEPTION
      WHEN no_data_found THEN
          CLIENT_TEXT_IO.Fclose(in_file);But if in my last line from the flat file is some other characters then it is taking that also .
    How can i avoid it ?
    Note :- Other characters means you cannot see like this , when you press SHOW ALL CHARACTERS button in the NOTEPAD++ then it will show ...

    My File is like this ABC . There is no extension like ABC.txt .
    And in the file if the last line if blank space is there then it is coming to exception part , but if TAB is there then it is not coming .

  • How to iterate through multiple records read from a file adapter?

    I am reading multiple records from a file using SyncRead file adapter.
    I want to iterate through the records to perform some action on every record. How to do this?
    I found few threads related to this..but did not get the solution.
    Please note that I am using Jdev 10.1.3.4
    Thanks

    For count expression, I am getting following error:
    <Faulthttp://schemas.oracle.com/bpel/extensionhttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>null:subLanguageExecutionFault</faultcode>
    <faultstring>business exception</faultstring>
    <faultactor>cx-fault-actor</faultactor>
    <detail>
    <code>XPathExecutionError</code>
    <summary>XPath expression failed to execute. Error while processing xpath expression, the expression is "ora:countNodes(bpws:getVariableData('Invoke_3_SynchRead_OutputVariable','EmpCollection','/ns4:EmpCollection'))", the reason is FOTY0001: type error. Please verify the xpath query. </summary>
    </detail>
    </Fault>
    I hard-coded count, in order to proceed. Then I got following error
    <Faulthttp://schemas.oracle.com/bpel/extensionhttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>null:bindingFault</faultcode>
    <faultstring>business exception</faultstring>
    <faultactor>cx-fault-actor</faultactor>
    <detail>
    <code>null</code>
    <summary>file:/C:/product/10.1.3.1/OracleAS_1/bpel/domains/default/tmp/.bpel_BPELProcess4_1.0_dc4a703c46a242f69d6cea305b2df3a3.tmp/WriteDA.wsdl [ WriteDA_ptt::insert(VbEmpCollection) ] - WSIF JCA Execute of operation 'insert' failed due to: Mapping Not Found Exception. The mapping [C1] for descriptor [class bpel___localhost_default_BPELProcess4_1_0__MD5_ad2539e1386433a9e059bcc969732f11_.WriteDA.VbEmp] could not be found. The input xml record had an element [VbEmp/C1]. ; nested exception is: ORABPEL-11627 Mapping Not Found Exception. The mapping [C1] for descriptor [class bpel___localhost_default_BPELProcess4_1_0__MD5_ad2539e1386433a9e059bcc969732f11_.WriteDA.VbEmp] could not be found. The input xml record had an element [VbEmp/C1]. Make sure that the input xml is valid relative to the xsd and that the mapping exists in the Mappings.xml. If an old version of the descriptor without this mapping has been loaded by the database adapter, you may need to bounce the app server. If the same descriptor is described in two separate Mappings.xml files, make sure both versions include this attribute/mapping. </summary>
    <detail>null</detail>
    </detail>
    </Fault>
    The bpel code is as follows (I can share entire BPEL project..But not sure how to attach to the thread :( )
    <?xml version = "1.0" encoding = "UTF-8" ?>
    <!--
    Oracle JDeveloper BPEL Designer
    Created: Wed Feb 03 18:00:26 IST 2010
    Author: administrator
    Purpose: Synchronous BPEL Process
    -->
    <process name="BPELProcess4"
    targetNamespace="http://xmlns.oracle.com/BPELProcess4"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:ns4="http://TargetNamespace.com/InboundService"
    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:client="http://xmlns.oracle.com/BPELProcess4"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/ReadFA/"
    xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns3="http://xmlns.oracle.com/pcbpel/adapter/db/top/WriteDA"
    xmlns:ns2="http://xmlns.oracle.com/pcbpel/adapter/db/WriteDA/"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <!--
    PARTNERLINKS
    List of services participating in this BPEL process
    -->
    <partnerLinks>
    <!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:BPELProcess4"
    myRole="BPELProcess4Provider"/>
    <partnerLink name="WriteDA" partnerRole="WriteDA_role"
    partnerLinkType="ns2:WriteDA_plt"/>
    <partnerLink name="ReadFA" partnerRole="SynchRead_role"
    partnerLinkType="ns1:SynchRead_plt"/>
    </partnerLinks>
    <!--
    VARIABLES
    List of messages and XML documents used within this BPEL process
    -->
    <variables>
    <!-- Reference to the message passed as input during initiation -->
    <!-- Reference to the message that will be returned to the requester-->
    <variable name="inputVariable"
    messageType="client:BPELProcess4RequestMessage"/>
    <variable name="outputVariable"
    messageType="client:BPELProcess4ResponseMessage"/>
    <variable name="Invoke_2_insert_InputVariable"
    messageType="ns2:VbEmpCollection_msg"/>
    <variable name="Invoke_3_SynchRead_InputVariable"
    messageType="ns1:Empty_msg"/>
    <variable name="Invoke_3_SynchRead_OutputVariable"
    messageType="ns1:EmpCollection_msg"/>
    <variable name="Invoke_3_SynchRead_InputVariable_1"
    messageType="ns1:Empty_msg"/>
    <variable name="Count" type="xsd:integer"/>
    <variable name="iterater" type="xsd:integer"/>
    </variables>
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    -->
    <sequence name="main">
    <!-- Receive input from requestor. (Note: This maps to operation defined in BPELProcess4.wsdl) -->
    <receive name="receiveInput" partnerLink="client"
    portType="client:BPELProcess4" operation="process"
    variable="inputVariable" createInstance="yes"/>
    <!-- Generate reply to synchronous request -->
    <invoke name="Invoke_3" partnerLink="ReadFA" portType="ns1:SynchRead_ptt"
    operation="SynchRead"
    outputVariable="Invoke_3_SynchRead_OutputVariable"
    inputVariable="Invoke_3_SynchRead_InputVariable_1"/>
    <assign name="Assign_1">
    <copy>
    <from expression="1"/>
    <to variable="iterater"/>
    </copy>
    <copy>
    <from expression="1"/>
    <to variable="Count"/>
    </copy>
    </assign>
    <while name="While_1"
    condition="bpws:getVariableData('iterater') &lt;= bpws:getVariableData('Count')">
    <sequence name="Sequence_2">
    <switch name="Switch_1">
    <case condition="bpws:getVariableData('Invoke_3_SynchRead_OutputVariable','EmpCollection','/ns4:EmpCollection/ns4:Emp/ns4:C4') = &quot;Pune&quot;">
    <sequence name="Sequence_1">
    <assign name="Assign_3">
    <copy>
    <from expression="bpws:getVariableData('Invoke_3_SynchRead_OutputVariable','EmpCollection','/ns4:EmpCollection/ns4:Emp')[bpws:getVariableData('iterater')]"/>
    <to variable="Invoke_2_insert_InputVariable"
    part="VbEmpCollection"
    query="/ns3:VbEmpCollection/ns3:VbEmp"/>
    </copy>
    </assign>
    <invoke name="Invoke_2" partnerLink="WriteDA"
    portType="ns2:WriteDA_ptt" operation="insert"
    inputVariable="Invoke_2_insert_InputVariable"/>
    </sequence>
    </case>
    <otherwise>
    <sequence name="Sequence_3">
    <empty name="Empty_1"/>
    <assign name="Transform_1">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('Transformation_3.xsl',bpws:getVariableData('Invoke_3_SynchRead_OutputVariable','EmpCollection'))"/>
    <to variable="Invoke_2_insert_InputVariable"
    part="VbEmpCollection"/>
    </copy>
    </assign>
    </sequence>
    </otherwise>
    </switch>
    <assign name="Assign_2">
    <copy>
    <from expression="bpws:getVariableData('iterater') + 1"/>
    <to variable="iterater"/>
    </copy>
    </assign>
    </sequence>
    </while>
    <reply name="replyOutput" partnerLink="client"
    portType="client:BPELProcess4" operation="process"
    variable="outputVariable"/>
    </sequence>
    </process>
    From the process flow, I can see that the array element expression works and the first employee record is correctly assigned to the Invoke_2_Input_Variable.
    However Invoke_2 is erroring out.
    Thanks
    Edited by: user8645981 on Feb 5, 2010 2:44 AM

  • How to omit unused fields while import from delimited file

    I have a problem to select and load to table only needed fields from delimited free-format file. How to do it ? Anybody know ?

    If you cannot control what gets put in the file, I imagine the best easiest way would to be to create a temporary table which includes the unwanted columns, then move the data you want into the proper table afterwards.

  • Problem while reading from text file using JDeveloper 10.1.2

    Hi,
    I am using JDeveloper 10.1.2 for my application. In this, I have one requirement to read some data from a text file. For that, I created a test file and saved along with the java file folder. From there, I am trying to read this file but it says the file not found exception.
    Application is looking the file from another location. "F:\DevSuiteHome_1\jdev\system10.1.2.1.0.1913\oc4j-config"
    But, I want to read it from my home folder. How is it possible to read from that location?
    Regards,
    Joby Joseph

    HI,
    Check followings will useful
    How to read .txt file from adfLib jar at model layer using relative path
    Accessing physical/relative path from Bean

  • How to skip first records while reading a csv file

    Hi,
    How to skip the first 5 records while reading csv file.
    I have a file which contains first 5 records as dummy records, I want to skip those records and load the rest into RDBMS.
    How to achieve this?
    Thanks,
    Naveen Suram

    Hi Guru,
    Actually I have converted an excel to CSV format, which is generating first 4 rows as some dummy records. 5th row is my header record. But in hearder record, two column names are same. Thats why while reversing it is giving an error.
    With zero in number of columns in header, I am getting the column names as C1, C2...
    If not in reversing, can we reject the first records while loading into RDMBS table using an interface?
    Thanks,
    Naveen Suram

  • Reading from a file. How to ask the user for file name at run time????

    I have the code to read from a file but my problem is how to prompt the user for the file name at run time.
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.InputMismatchException;
    import java.util.Scanner;
    public class FileRead {
        public static void main(String args[]) {
            Scanner scan = null;
            File file = new File("Results.txt");
            String number;
            try {
                scan = new Scanner(file);
                while (scan.hasNext()){
                number = scan.next();
                System.out.println(number);}
            catch (FileNotFoundException ex1){
                System.out.println("No such file");
            catch (IllegalStateException ex2){
                System.out.println("Did you close the read by mistake");
            catch (InputMismatchException ex){
                System.out.println("File structure incorrect");
            finally{
                scan.close();}
    }Any hints would be greatly appreciated. Thank you in advance

    I have read through some of the tutorials that you have directed me too and they are very useful, thank you. however there are still a few things that i am not clear about. I am using net beans 5.0 I have placed a text file named Results.txt into the project at the root so the program can view it.
    When I use the code that you provided me with, does it matter where the file is, or will it look through everywhere on the hard drive to find a match?
    This code compiles but at run time it comes up with this error
    run-single:
    java.lang.NoClassDefFoundError: NamedFile
    Exception in thread "main"
    Java Result: 1
    BUILD SUCCESSFUL (total time: 3 seconds)
    import java.util.Scanner;
    import java.io.*;
    class NamedFileInput
      public static void main (String[] args) throws IOException
        int num, square;   
        // this Scanner is used to read what the user enters
        Scanner user = new Scanner( System.in );
        String  fileName;
        System.out.print("File Name: ");
        fileName = user.nextLine().trim();
        File file = new File( fileName );     // create a File object
        // this Scanner is used to read from the file
        Scanner scan = new Scanner( file );     
        while( scan.hasNextInt() )   // is there more data to process?
          num = scan.nextInt();
          square = num * num ;     
          System.out.println("The square of " + num + " is " + square);
    }his is the code that i used. It is the same as the code you posted for me (on chapter 23 I/O using Scanner and PrintStream) Sorry im just really stuck on this!!

  • Error occured while reading from the device

    I need help!!! whenever i try to update my iphone to the new 1.1.1 version, i get an error message saying "error occured while reading from the device" the same message comes up when i try to restore it. i havent mod'd my phone in any way. does anyone know whats wrong or how to fix it?

    I have the same problem. Was a solution ever given ?

  • DPM encountered an error while reading from the recovery point used for recovery.

    Hi Guys I'm getting this error:
    DPM encountered an error while reading from the recovery point used for recovery. Either the recovery point no longer exists or, if you
    selected a share for recovery, the path to its contents is missing from the recovery point.  (265)
    The DPM Server is on Windows 2012 DPM is 2012R2 4.2.1273.0
    The Server being backed up is 2012 R2 with DPM Agent 4.2.1273.0
    The Server has 3 Data Volumes (C: Drive) and D and E its the D and E drive that i get this error if i try and recover data from DPM.  the C Drive is fine.  the D and E Drive are different
    in that 1 De-dupe is enabled and 2 the Shadow Copies for these Volumes are stored on separate Disks F and G respectively.
    I've removed the Protection from drives D and E and reinstated it but every recovery point created
    brings up the same error message. I'm not sure where to go next do I need to Protect the Disks that have the Shadow copies on also? Many thanks in advance Gordon.

    Hi,
    It seems you are in a configuration where the Windows 2012 based DPM server does not understand how to read Windows 2012 R2 Dedup data structure which is what the DPM replica volume is.
    See the DPM supported and unsupported scenarios
    here under the deduplication issues section. 
    We have a fix in DPM2012 R2 UR5 that will protect the Windows 2012 R2 dedup volume in a non-dedup state on the DPM Server, but unfortunately that will not allow previous recovery points to be read.
    KB3021791-Description of Update Rollup 5 for System Center 2012 R2 Data Protection Manager
    Backup job for dedupe-enabled volume on Windows 2012 R2 fails. For example, Data Protection Manager backup might fail for following setup:
    Data Protection Manager2012 R2 is installed on Windows Server 2012.
    Data Protection Manager is protecting a dedupe-enabled volume on Windows Server 2012 R2.
    This also applied to restores as the above was for D2D2T backup that may fail as it needs to read the recovery point to back it up to tape.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This
    posting is provided "AS IS" with no warranties, and confers no rights.

  • Error message, what does this mean: Itunes couldnt connect because an error occured while reading from the devise?!?!?! HELP

    I'm trying to connect my iPAD to my desktop but I receive an error: itunes couldnt connect because an error occured while reading from the devise?!?!?! HELP

    have you done a update for your itunes this can be the problem that it will not connect to you ipad so update you itunes and then try it again

  • HT4528 I can't seem to sync my iPhone with iTunes.  I keep getting this message:  iTunes could not connect to the iPhone because an error occurred while reading from this device.  What can I do?

    I can't seem to sync my iPhone to my computer; I keep getting this message:  "iTunes could not connect to the iPhone because an error occurred while reading from this device."  I get the same message with my iPad, even though they all share the same account.  What can I do?

    This could be caused by a USB connection issue. Make sure the iPhone is directly connected to the Mac using the USB cable it came with. Also, try disconnecting all other USB devices.
    If you haven't already try resetting the iPhone by holding the Home and Sleep/Wake buttons until you see an Apple logo as described here:http://docs.info.apple.com/article.html?artnum=305743

  • Message failing in SXMB_moni----Error while reading from the secure store

    Hi,
    The scenario is as below
    A file is picked up from a folder and processed to enrich it.This enriched file is then written back in a different folder.
    The message is failing in sxmb_moni while trying to write the file in the folder.
    The PI system is a system copy of another system and few of the configuration objects are transported through a tpz file to this PI system.The file receiver channel used to write this file is also transported through this tpz file.
    Below is the error seen in moni.:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?><!-- Call Adapter --> <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1"><SAP:Category>XIServer</SAP:Category><SAP:Code area="INTERNAL">AE_DETAILS_GET_ERROR</SAP:Code><SAP:P1/><SAP:P2/><SAP:P3/><SAP:P4/><SAP:AdditionalText>Error while reading from the secure store: ERROR_U: No service user password found for Adapter Engine</SAP:AdditionalText><SAP:Stack>Error while reading access data (URL, user, password) for the Adapter Engine
    </SAP:Stack><SAP:Retry>M</SAP:Retry></SAP:Error>
    Below is Trace log:
    <Trace level="1" type="B" name="PLSRV_CALL_ADAPTER"></Trace><!-- ************************************ -->
    <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV"></Trace><!-- ************************************ -->
    <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL"></Trace><!-- ************************************ -->
    <Trace level="1" type="B" name="CL_XMS_PLSRV_IE_ADAPTER-ENTER_PLSRV">
    <Trace level="1" type="B" name="CL_XMS_PLSRV_CALL_XMB-CALL_XMS_HTTP"></Trace><!-- ************************************ -->
    <Trace level="1" type="T">error reading secstore:Error while reading from the secure store: ERROR_UNKNOWN: System-dependent data for entry  changed:  / (SECSTORE,031) </Trace>
    <Trace level="1" type="System_Error">Error while reading access data (URL, user, password) for the Adapter Engine  </Trace>
    </Trace>
    </Trace>
    <Trace level="1" type="System_Error">Error exception return from pipeline processing! </Trace>
    <Trace level="1" type="B" name="CL_XMS_MAIN-WRITE_MESSAGE_TO_PERSIST"></Trace><!-- ************************************ -->
    Is this because  PI system is a system copy of another system ?
    Regards,
    Sneha

    Error while reading access data (URL, user, password) for the Adapter Engine
    Check out Michal's reply:
    Re: URL for Central Adapter Engine
    As you said there was a system copy it may be the case that some things were not configured properly

  • While reading from the pl/sql cursor i got "Invalid column index" exception

    Hi,
    I got the "Invalid column index" exception while reading from the cursor.
    Please advice.
    Thanks in advance
    siva

    I suppose one (or more) index in your query is in a bad state.
    Possible solutions: rebuild (with 'ALTER INDEX <index> REBUILD ...')
    drop and recreate (it's the same as above, but a little more long)

  • How do i do the replacement by reading from a file ?

    The multibyte representation in cloumn 2 in the input file is encoded in UTf8 format.
    I have the code to get the code point value from a multibyte representation.
    But i am not sure how to do the same when reading from a file.
    A better explanation of the requirement is like this,
    I have a java program ,i have a String="test";
    I traverse the string
    on encountering the character 't' i read from the input file ,the input file has the characters m to z listed in it, and it also has the UTF8 encoded multibyte representation in it.
    I then read from the file
    I search the file to get he character 't'
    on gettin the character 't' i get the corresponding multibyte representation from the input file
    Then i get the unicode code point value for the multibyte representation that i got from the input file.
    Lastly i replace the character 't' in the string with the unicode code point value 3046
    Hope the requirement is clear
    Please do help
    Any help would be very useful
    Thanking you
    khurram

    I am still not sure as to what your problem is. It would be better if you specify as to where the problem lies in the steps that you have stated and ask for a solution.
    agar yeh homework hai to log yehan par isse appreciate nahin karte. Acha hota agar requirements ki bajai problem discuss ki jati.

  • I am trying to sync iphone 5 to itunes but it says "iTunes could not connect to the iphone as an error occured while reading from the device " and the iphone is not seen on itunes........

    i am trying to sync iphone 5 to itunes but it says "iTunes could not connect to the iphone as an error occured while reading from the device " and the iphone is not seen on itunes........

    First thing to try is to reset your device. Press and hold the Home and Sleep buttons simultaneously ignoring the red slider should one appear until the Apple logo appears. Let go of the buttons and let the device restart. And then reboot your computer.
    See if that fixes your problem.

Maybe you are looking for