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.

Similar Messages

  • EHP4 flexible appraisal - How to use one coloum mutiple times

    Dear PMS gurus,
    I have a requirement as follows
    Is there a possibility to use a column many times in a criterion group or criteria. Like,
    There are five objectives created in a criterion group and all the fine objectives have to evaluated as
    1.     Target to be achieved
    2.     Actual target achieved
    For every target we need to have these columns. Is there a possibility we can do that in the standard.
    Also is there a possibility we can have the coloums in horizontal manner instead of the current vertical way the standard gives
    Thanks
    Balaji

    Hi Balaji
    Yes in a flexible appraisal template you can use a column more than once in a criterion group or criterion.
    With regards to layout of Columns , no you cannot have it vertical instead of horizontal (unless you enhance the webdynpro) . If you wish to have it vertical , you can change the layout in the offline download of form which means the users will always have to work in the offline download mode and upload the appraisal doc. Also you need to check if the ADOBE user licenses allows you to change the offline ADOBE form as it  needs ADOBE designer .
    Hope this helps
    Regards
    Urmila Pereira

  • How can i insert more than one record a time in a JSP page?

    Hi experts,
    I'm working with JDeveloper version 3.2 application server 9i.
    I want to insert more than 1 record using a jsp page and then perform a commit at the end.
    do you can help me with this problem/challenge?
    Thank you,
    Regards,
    Mario

    statement.executeBatch() maybe?

  • How to use value returned from a bean in jsp page

    Hi All,
    I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
    How do I do this?
    Many thanks :)

    thanks for your response.
    I actually used something like this:
    <% String loggedin = log.User(user,password);
    out.println(loggedin);
    %>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments?

  • How to Use tag in JDeveloper 9i for a JSP Page

    Hi ,
    I am working on JDeveloper 9i. I have a problem that i use JSP page and two tag[b] fmt and core. The uri passed to taglib is http://java.sun.com/jsp/jstl/core and http://java.sun.com/jsp/jstl/fmt. i also have two jar file standard.jar and jstl.jar. when i compile the jsp page, the errors reflect " TAG is not registered". Can any one tell me that how can i use the tags in a jsp page in jdeveloper 9i.
    Thanks

    Hi ,
    I am working on JDeveloper 9i. I have a problem that i use JSP page and two tag[b] fmt and core. The uri passed to taglib is http://java.sun.com/jsp/jstl/core and http://java.sun.com/jsp/jstl/fmt. i also have two jar file standard.jar and jstl.jar. when i compile the jsp page, the errors reflect " TAG is not registered". Can any one tell me that how can i use the tags in a jsp page in jdeveloper 9i.
    Thanks

  • Hi my mom tried my password one to many times and now i am disabled and cant get into my phone at all, it just allows for emergency calls.

    hi anyone to there know how to fix my problem. my mom tried my password one two many times and now my phone is disabled and i cant use it unless its a emergency.

    iOS: Forgot passcode or device disabled
    I hope you back up on a regular basis.

  • How to use one commandButton to execute two tasks in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is �findInspector�. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two tasks in JSF.
    Thank you
    Waheed

    Just dopublic void execute() {
        anotherAction(inputValue);
    I guess those articles might be interesting about passing params and the usage of inputHidden and also about using datatables:
    http://balusc.xs4all.nl/srv/dev-jep-com.html
    http://balusc.xs4all.nl/srv/dev-jep-dat.html

  • How to use one commandButton  to execute two task in JSF

    I have a form in JSF page which contains different faces components. These faces bind to ADF BC to insert one row in the database when the user press commandButton. Also I need to bind the value of one inputText in that form to managed bean to execute another task in the application when the user press the same commandButton.
    The code of the inputText:
    <h:inputText value="#{bindings.ProjectNumber.inputValue}"
    id="pn"
    size="10"
    required="#{bindings.ProjectNumber.mandatory}">
    The code of commandButton:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}"/>
    The managed bean is “findInspector”. I tried to insert inputHidden inside commandButton tag and assign the value of the inputText to the inputHidden as follows:
    <h:commandButton actionListener="#{bindings.Commit.execute}"
    value="Save"
    disabled="#{bindings.Commit.actionEnabled}">
    <h:inputHidden value="#{bindings.ProjectNumber.inputValue}" binding="#{findInspector.project}"/>
    </h:commandButton>
    But it was not work
    Please how can I write the code to use the value of the inputText more than one time in the JSF(one to insert one row by using ADF BC and another to use the same value to bind to a managed bean) and how to use one commandButton to execute two task in JSF.
    Thank you
    Waheed

    Yes I did
    <managed-bean>
    <description>The bean for get project No</description>
    <managed-bean-name>projectBean</managed-bean-name>
    <managed-bean-class>
    mcscm.model.ProjectBean
    </managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{bindings}</value>
    </managed-property>
    </managed-bean>
    Also I changed the method in the managed bean as follows:
    public String commandButton_action() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ValueBinding vb = fctx.getApplication().createValueBinding("#{bindings}");
    DCBindingContainer dcb = (DCBindingContainer) vb.getValue(fctx);
    OperationBinding operation = (OperationBinding) dcb.get("projectNumber");
    operation.execute();
    return null;
    where projectNumber is my method in the java class of the application module "TaskInformationImpl". I made this method to be accessed from outside of ADF BC.
    I just create a sample code for projectNumber method for testing only as:
    public void projectNumber (String data){
    System.out.print(data);
    In the page Pagedef file I added this :
    <methodAction id="projectNumber"
    InstanceName="TaskInformationDataControl.dataProvider"
    DataControl="TaskInformationDataControl"
    MethodName="projectNumber" RequiresUpdateModel="true"
    Action="999" IsViewObjectMethod="false">
    <NamedData NDName="data" NDValue = "#{bindings.ProjectNumber.inputValue}" NDType="java.lang.String"/>
    After I did all of this I get a new error like:
    javax.faces.FacesException: #{projectBean.commandButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding cannot be cast to oracle.adf.model.OperationBinding
    Is it very difficult to do this in JDeveloper?. yes ADF BC provide me a lot of facilities, but when I want to do a specific task I face a lot of troubles

  • How to use one email adress for multiple recipients

    Hello,
    I'd like to know how to use one email adress for multiple recipients. 
    this would be very useful or projects. for example;
    if i send one mail to [email protected], all people in this project get an email.
    I will add the people in this project myself. 
    I know it is possible, but I don't know how to do it ;-)
    please help me! 

    Hope this help.
    _http://technet.microsoft.com/en-us/library/cc164331(v=exchg.65) .aspx

  • I used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this?

    i used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I have created a new partition on the Mac HD for Lion as I would like to dual boot. Do I need to install Snow Leopard on that partition before installing Lion? If so, can I use one of my Time Machine backups to do this?

    I have created a new partition on the Mac HD for Lion as I would like to dual boot. Do I need to install Snow Leopard on that partition before installing Lion? If so, can I use one of my Time Machine backups to do this?

    zoominnana wrote:
    Can I set up 2 different time capsule backups? one for the lion partition and one for the snow leopard partition?
    No, you can't partition a Time Capsule's internal HD.  Both partitions will back up to the same sparse bundle. keeping the backups for each partition separate.
    Time Machine will not take the two OSX partitions as two different computers, but for best results, exclude the Snow Leopard drive from backups on the Lion partition, and exclude the Lion partition from backups on the Snow Leopard partition.
    There may be some files on the Lion partition that Time Machine on Snow Leopard won't like, among other things.  See #10 in  Time Machine - Frequently Asked Questions for details.

  • How to use one report column into the another report in obiee

    How to use one report column into the another report in obiee

    i dont want to use column as a filter for another report it should be report column for another report
    Thanks,
    Vivek

  • 2 atv's both have home sharing enabled but one asks to turn on home sharing on my pc but it is on so can only use one at a time to watch movies from my computer

    2 atv's both have home sharing enabled but one asks to turn on home sharing on my pc, but it is enabled on pc so I  can only use one at a time to watch movies from my computer

    Both atv,s are on the same network, they are wirless and the computer can see them and they are named different.
    what ever one i switch on first gets to stream from my computer and the other one asks for home sharing to be switched on, then if i switch both off and start the other one first it gets to stream and the other one which worked asks for home sharing to be turned on. i have hidden all functionality, netflix etc as these are for my 7yr old kids.

  • Context Problem when using Use One As Many

    Hi SapGuru's.
    i have got a requirement in an IDOC To File Interface where the segments in the IDOC are like E1LFA1M->E1LFM1M->E1WYT3M
    THE Test data is like below
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:IDOC_Test_Mt xmlns:ns0="urn:sap.shoprite.co.za:ecc.md">
       <ZCREMAS>
          <IDOC>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1001</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1002</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                1002
             </E1LFA1M>
             <E1LFA1M>
                <LIFNR>0000641065</LIFNR>
                <E1LFM1M>
                   <EKORG>1004</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
                <E1LFM1M>
                   <EKORG>1005</EKORG>
                   <E1WYT3M>
                      <PARVW>BA</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>LF</PARVW>
                   </E1WYT3M>
                   <E1WYT3M>
                      <PARVW>RS</PARVW>
                   </E1WYT3M>
                </E1LFM1M>
             </E1LFA1M>
          </IDOC>
       </ZCREMAS>
    </ns0:IDOC_Test_Mt>
    the Target xsd is like below :
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema targetNamespace="urn:sap.shoprite.co.za:demo.trans" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:sap.shoprite.co.za:demo.trans" xmlns:p1="urn:sap.shoprite.co.za:bluecube">
       <xsd:import namespace="urn:sap.shoprite.co.za:bluecube"/>
       <xsd:element name="Vendor_masterTest1" type="p1:Vendor_masterTest"/>
    </xsd:schema>
    the EKORG Field from source is mapping to Purchase Organisation(field) in target file .
    so here when i use one as many and iam mapping EKORG->MAP WITH DEFAULT ->USE ONE AS MANY and as in the above test data if there are multiple E1LFM1M's the first paramter of Use one as many is getting 2 ekorg's in only one context but here i want them to be created on separate context(please have a look at 4th E1LFA1M in the test data to get clear idea.
    can any of you help me in this.
    regards.
    Varma

    Hi,
    Try this.
    Source Code:
    IDOC
    --->E1LFA1M
                    -->E1LFM1M
                          --> EKORG = 1000
                          --> E1WYT3M
                          --> E1WYT3M
                    -->E1LFM1M
                    -->E1LFM1M
                          --> EKORG = 1001
                          --> E1WYT3M
                          --> E1WYT3M
                    -->E1LFM1M
                          --> EKORG = 1006
                          --> E1WYT3M
                          --> E1WYT3M
    Output:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:target xmlns:ns0="http://test">
    <Data>
       <M>1000</M>
    </Data>
    <Data>
       <M>1000</M>
    </Data>
    <Data>
       <M></M>
    </Data>
    <Data>
       <M>1001</M>
    </Data>
    <Data>
       <M>1001</M>
    </Data>
    <Data>
       <M>1006</M>
    </Data>
    <Data>
       <M>1006</M>
    </Data>
    </ns0:target>
    Use below Mapping:
    Use If then Else Function.
    1. If condition: E1WYT3M Exists
    2. Then pass E1WYT3M
    3. Else Pass E1LFM1M with "Map with Default"
    Lets Consider Output of this step as "A".
    Use One As Many.
    First Input: E1LFM1M to exists to Split By Each Value
    Second and Third Input will be Out Put of "A" (Above Step).
    Lets Consider Out put of this Step as "B"
    Use If without Else.
    If "B" is true then pass "A"  to exists.
    Out put  of this to Remove context to Target Vendor Master Node. In my sample it will be Node "Data"
    Now for Mapping of Field Purch Org/In my case field "M"
    Use If without Else.
    If "B" is true then Pass "C". Output of this to Split by each value to target.
    For C:
    Use if then else
    if E1WYT3M exists then pass EKORG else pass constant blank.
    Hope its clear!!
    -Gouri

  • Ipod disabled, changed my password but entered the wrong one too many times!

    ipod disabled, changed my password but entered the wrong one too many times!
    Didnt have a pc with ituens before either but now have one although dont quite know what to do.

    plug your ipod touch into your computer in recovery mode. (see herehttp://support.apple.com/kb/ht1808)
    Reset all data and settings
    dont restore from backup
    sync back content

Maybe you are looking for

  • Icloud calendar conversion for a family?

    For the past 8 or so years I've used a webdav server hosted on my own website for the 6-7 family calendars.  I've just upgraded to 4s's and I have 7 mac's in my house and I am hoping to use Icloud as a calendar server.  Each computer in the house see

  • Hyperlink which refer to a Visio drawing will not display the Visio drawing inside the browser

    I have a site collection of type "Publishing>>Enterprise wiki", and i have the Visio Graphics service application enabled (i have enterprise SP license). now if i open the document library , and i click on the Visio diagram the diagram will open insi

  • NO_MAPPINGPROGRAM_FOUND SOAP RFC Adapter

    Folks... Fun new problem. Details Are: --SOAP Sender Adapter to RFC Receiver Adapter --Synchronous Call --Appears to Complete all steps of the pipeline except the Response Message --Mappings for both Request and Response Messages have been declared.

  • Error message on set up on new Macbook pro

    I just bought a new Macbook Pro and I am trying to install my Cs3 on it. Yes, a few versions behind I had to transfer the set-up files from the DVD to a usb key, because the new macbook doesn't have a DVD drive. I did this, initialized the set up, an

  • Import order for events/rolls

    How does iPhoto determine the order it puts imported files in? When I import several files of photos into iPhoto, they go into Events, but they can be all over the place. I'd like the events in the same Date order as I have them listed in Finder. If