Retrieving All Objects From Session

I'm developing a JSP shopping cart application, i have problem with sessions. A user can add a product to their cart, this adds the product name and the product price to the cart using:
<%
session.setAttribute("pname", pname);
session.setAttribute("pprice", pprice);
%>
The problem I have is viewing the cart. The page must display all items the user has added to the cart. I need to retrieve all the objects from the users session.
session.getAttribute("pname") will only return the last object which was added to the session. Is there a method or mechansim to loop through all the objects in a users session?
Any suggestions appreciated.

session.getAttribute("pname") will only return the
last object which was added to the session. Is there a
method or mechansim to loop through all the objects in
a users session?You can't use session.setAttribute("pname",pname); repeatedly. Each time it will overwrite contents of existing attribute. Thats the reason why you are always getting last added value.
You can do one thing. Add pname to the Vector or Hashtable, like this,Vector v = (Vector) session.getAttribute("pname"); // Get the existing Vector in the session.
if(v == null) v = new Vector(); //If there is no attribute "pname" in the session, create an object of Vector.
v.add(pname) //add item to the Vector.
session.setAttribute("pname",v); //Now add this vector to the session.Hope this helps.
Sudha

Similar Messages

  • Re: [iPlanet-JATO] Re: Retrieving all Values from a Tiled View

    Todd,
    Let me try to explain you this time. I have a text field in a TiledViewBean.
    When I display the page, the text field
    html tag is created with the name="PageDetail.rDetail[0].tbFieldName" say
    five times/rows with same name.
    The html tags look like this.
    <input type=text name="PageDetail.rDetail[0].tbFieldName" value=""
    maxlength=9 size=13>
    <input type=text name="PageDetail.rDetail[0].tbFieldName" value=""
    maxlength=9 size=13>
    <input type=text name="PageDetail.rDetail[0].tbFieldName" value=""
    maxlength=9 size=13>
    When the form is submitted, I want to get the text field values using the
    method getTbFieldName().getValues() which
    returns an array object[]. This is in case where my TiledViewBean is not
    bound and it is working fine.
    Now in case when my TiledView is bound to a model, it creates the html tags
    as follows.
    <input type=text name="PageDetail.rDetail[0].tbFieldName" value=""
    maxlength=9 size=13>
    <input type=text name="PageDetail.rDetail[1].tbFieldName" value=""
    maxlength=9 size=13>
    <input type=text name="PageDetail.rDetail[2].tbFieldName" value=""
    maxlength=9 size=13>
    Now when I say getTbFieldName().getValues() it returns only the first
    element values in the object[] and the rest of the
    values are null.
    May be we need to create a utility method do get these values from
    requestContext.
    raju.
    ----- Original Message -----
    From: Todd Fast <toddwork@c...>
    Sent: Saturday, July 07, 2001 3:52 AM
    Subject: Re: [iPlanet-JATO] Re: Retrieving all Values from a Tiled View
    Raju.--
    I wanted to know how the getValues() method works the reason being,
    when the tiled view is NOT bound to a model, it populates all the
    fields with the same name as some thing likeI'm afraid I don't understand your point--can you please clarify? Do you
    mean "value" instead of "name"?
    What are you trying to do? What behavior are you expecting but notseeing?
    >
    Without further clarification, I can say that the setValues() methodsNEVER
    populates data on multiple rows of a (dataset) model, nor does it affect
    multiple fields on the same row. Perhaps what you are seeing is theeffect
    of default values. Model that derive from DefaulModel have the ability to
    carry forward the values set on the first row to other rows in lieu ofdata
    in those other rows. This behavior is for pure convenience and can be
    turned off, and it is turned off for the SQL-based models.
    Todd
    [email protected]

    Hi,
    I wanted to know how the getValues() method works the reason being,
    when the tiled view is NOT bound to a model, it populates all the
    fields with the same name as some thing like
    PageDetail.rDetail[0].tbFieldValue
    PageDetail.rDetail[0].tbFieldValue
    in which case, the getValues() method works fine.
    But in case where the tiled view is bound to a model, it populates
    with different field names such as,
    PageDetail.rDetail[0].tbFieldValue
    PageDetail.rDetail[1].tbFieldValue
    in this case, the getValues() doesn't work. Any soultion to this?
    We are using Moko 1.1.1.
    thanks in advance,
    raju.
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    Does anyone know of is there a single method to get all values of a
    display
    field in a tiled view without having to iterate through all the
    values ie
    resetTileIndex() / nextTile() approach.
    ie Something that returns an Object[] or Vector just like ND returned a
    CspVector. I tried using the getValues() methods but that allways returns
    a
    single element array containing the first element.
    (I think now, that method is used for multi selecteable ListBoxes)Actually, no. We can add this in the next patch, but for now, I'd recommend
    creating a simple utility method to do the iteration on an arbitrary model
    and build the list for you.
    Todd

  • Retrieving all values from hashmap in order you put them in

    Hi guys,
    I want to retrieve all values from a HashMap in the order I put them in.
    So I can't use the values() method that gives back a collection and iterate over that.
    Do you guys know a good way to do that ?

    You can just do something like this:
    class OrderedMap
        private final Map  m_rep = new HashMap();
        private final List m_keys = new ArrayList();
        public Object get( final Object key )
            return m_rep.get( key );
        public Object put( final Object key, final Object value )
            final Object result = m_rep.put( key, value );
            if ( result != null )
                m_keys.add( key );
            return result;
        public Object remove( final Object key )
            final Object result = m_rep.remove( key );
            if ( result != null )
                m_keys.add( key );
            return result;
        public Iterator keyIterator()
            return m_rep.iterator();
    }Then use it like this:
       for ( Iterator it = map.keyIterator(); it.hasNext(); )
           final Object value = map.get( it.next() );
       }This will be in the order you put them in. However, if you want to do this correctly, you should implement the Map interface and add all the methods. Another thing you can do is download the JDK 1.4 source, learn how they did and do it the same way for 1.2.
    R.

  • How to retrieve all fields from Entiy Bean

    Is there a simpler way to retrieve all fields from the entity bean than calling each individual get method?
    I need to retrieve the entire record not the contents of the entire table.
    Though, I may eventually need to do that also.
    I have 56 fields on this table. It does not make sense to code a get statement for every field.
    If you can direct me to sample code that would be good.
    Also, are there any good examples out there of how to create an entity bean or session bean using a local interface?
    Thanks,
    Jim

    I think you are confusing an EJB with a DAO.
    If you want to access the database why not just use JDBC?

  • How to remove an object from session with JSF 2.0 + Faceletes

    hi all,
    I have a facelets page which calls a backing bean of session scope. Now when ever i click on this page i want the existing bean object to be removed from the session . In my existing jsp i have a logic something like this to remove the object from session
         <% if (request.getParameter("newid") != null) {
              request.getSession().removeAttribute("manageuserscontroller");
    %>
    Now i have to refactor my jsp to use facelets and i should not be using scriplets anymore . I did try with JSTL but the <c:remove> tag is not supported by facelets.
    Can someone help me how can i refactor this code to work for my facelets?
    I really appreciate your help in advance
    Thank you

    r035198x wrote:
    Redesign things so that the remove is done in a backing bean method rather than in a view page.Exactly that. I tend to cleanup session variables at the start and at the end of a page flow; generally the end is some sort of save or cancel action being invoked through a button but that is application specific.

  • Retrieving ALL values from a single restricted user property

    How can I retrieve ALL values of a single restricted user property from within
    a .jpf file?
    I want to display a dropdown list within a form in a JSP which should contain
    all the locations listed in the property 'locations'. I ever get just the default
    value when I access the property via
    ProfileWrapper pw = userprofile.getProfileForUser(user);
    Object prop = pw.getProperty("ClockSetup", "Locations");

    Well, the code you've got will retrieve the single value of the property
    for the current user. You're getting the default value because the
    current user doesn't have Locations property set, so the ProfileWrapper
    returns the default value from the property set.
    I assume you want to get the list of available values that you entered
    into the .usr file in Workshop. If so, I've attached a
    SetColorController.jpf, index.jsp, and GeneralInfo.usr (put in
    META-INF/data/userprofiles) I wrote for an example that does just this.
    It uses the PropertySetManagerControl to retrieve the restricted values
    for a property, and the jsp uses data-binding to create a list from that
    pageflow method.
    For a just-jsps solution, you can also use the
    <ps:getRestrictedPropertyValues/> tag. I've attached a setcolor-tags.jsp
    that does the same thing.
    Greg
    Dirk wrote:
    How can I retrieve ALL values of a single restricted user property from within
    a .jpf file?
    I want to display a dropdown list within a form in a JSP which should contain
    all the locations listed in the property 'locations'. I ever get just the default
    value when I access the property via
    ProfileWrapper pw = userprofile.getProfileForUser(user);
    Object prop = pw.getProperty("ClockSetup", "Locations");
    [att1.html]
    package users.setcolor;
    import com.bea.p13n.controls.exceptions.P13nControlException;
    import com.bea.p13n.property.PropertyDefinition;
    import com.bea.p13n.property.PropertySet;
    import com.bea.p13n.usermgmt.profile.ProfileWrapper;
    import com.bea.wlw.netui.pageflow.FormData;
    import com.bea.wlw.netui.pageflow.Forward;
    import com.bea.wlw.netui.pageflow.PageFlowController;
    import java.util.Collection;
    import java.util.Iterator;
    * @jpf:controller
    * @jpf:view-properties view-properties::
    * <!-- This data is auto-generated. Hand-editing this section is not recommended. -->
    * <view-properties>
    * <pageflow-object id="pageflow:/users/setcolor/SetColorController.jpf"/>
    * <pageflow-object id="action:begin.do">
    * <property value="80" name="x"/>
    * <property value="100" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action:setColor.do#users.setcolor.SetColorController.ColorFormBean">
    * <property value="240" name="x"/>
    * <property value="220" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="action-call:@page:index.jsp@#@action:setColor.do#users.setcolor.SetColorController.ColorFormBean@">
    * <property value="240,240,240,240" name="elbowsX"/>
    * <property value="144,160,160,176" name="elbowsY"/>
    * <property value="South_1" name="fromPort"/>
    * <property value="North_1" name="toPort"/>
    * </pageflow-object>
    * <pageflow-object id="page:index.jsp">
    * <property value="240" name="x"/>
    * <property value="100" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="forward:path#success#index.jsp#@action:begin.do@">
    * <property value="116,160,160,204" name="elbowsX"/>
    * <property value="92,92,92,92" name="elbowsY"/>
    * <property value="East_1" name="fromPort"/>
    * <property value="West_1" name="toPort"/>
    * <property value="success" name="label"/>
    * </pageflow-object>
    * <pageflow-object id="forward:path#success#begin.do#@action:setColor.do#users.setcolor.SetColorController.ColorFormBean@">
    * <property value="204,160,160,116" name="elbowsX"/>
    * <property value="201,201,103,103" name="elbowsY"/>
    * <property value="West_0" name="fromPort"/>
    * <property value="East_2" name="toPort"/>
    * <property value="success" name="label"/>
    * </pageflow-object>
    * <pageflow-object id="control:com.bea.p13n.controls.ejb.property.PropertySetManager#propSetMgr">
    * <property value="31" name="x"/>
    * <property value="34" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="control:com.bea.p13n.controls.profile.UserProfileControl#profileControl">
    * <property value="37" name="x"/>
    * <property value="34" name="y"/>
    * </pageflow-object>
    * <pageflow-object id="formbeanprop:users.setcolor.SetColorController.ColorFormBean#color#java.lang.String"/>
    * <pageflow-object id="formbean:users.setcolor.SetColorController.ColorFormBean"/>
    * </view-properties>
    public class SetColorController extends PageFlowController
    * @common:control
    private com.bea.p13n.controls.ejb.property.PropertySetManager propSetMgr;
    * @common:control
    private com.bea.p13n.controls.profile.UserProfileControl profileControl;
    /** Cached possible colors from the User Profile Property Set definition.
    private String[] possibleColors = null;
    /** Get the possible colors, based upon the User Profile Property Set.
    public String[] getPossibleColors()
    if (possibleColors != null)
    return possibleColors;
    try
    PropertySet ps = propSetMgr.getPropertySet("USER", "GeneralInfo");
    PropertyDefinition pd = ps.getPropertyDefinition("FavoriteColor");
    Collection l = pd.getRestrictedValues();
    String[] s = new String[l.size()];
    Iterator it = l.iterator();
    for (int i = 0; it.hasNext(); i++)
    s[i] = it.next().toString();
    possibleColors = s;
    catch (P13nControlException ex)
    ex.printStackTrace();
    possibleColors = new String[0];
    return possibleColors;
    /** Get the user's favorite color from their profile.
    public String getUsersColor()
    try
    ProfileWrapper profile = profileControl.getProfileFromRequest(getRequest());
    return profileControl.getProperty(profile, "GeneralInfo", "FavoriteColor").toString();
    catch (P13nControlException ex)
    ex.printStackTrace();
    return null;
    // Uncomment this declaration to access Global.app.
    // protected global.Global globalApp;
    // For an example of page flow exception handling see the example "catch" and "exception-handler"
    // annotations in {project}/WEB-INF/src/global/Global.app
    * This method represents the point of entry into the pageflow
    * @jpf:action
    * @jpf:forward name="success" path="index.jsp"
    protected Forward begin()
    return new Forward("success");
    * @jpf:action
    * @jpf:forward name="success" path="begin.do"
    protected Forward setColor(ColorFormBean form)
    // set the color in the user's profile
    try
    ProfileWrapper profile = profileControl.getProfileFromRequest(getRequest());
    profileControl.setProperty(profile, "GeneralInfo", "FavoriteColor", form.getColor());
    catch (P13nControlException ex)
    ex.printStackTrace();
    return new Forward("success");
    * FormData get and set methods may be overwritten by the Form Bean editor.
    public static class ColorFormBean extends FormData
    private String color;
    public void setColor(String color)
    this.color = color;
    public String getColor()
    return this.color;
    [GeneralInfo.usr]
    [att1.html]

  • How do I retrieve all data from a table and display it on a text area?

    I want to retrieve all the data from one of my MS Access data table and display them all in a text area. how do i go among doing this?
    In my car table i have the fields lined up like this..
    license,color,doors and year_made
    I have an Object class called CAR that will contain methods to set the data from these fields when it gets retrieved.
    here's what i go so far.....
    statement = getDBConnection().createStatement();
         rs = statement.executeQuery("select * from car");
         boolean moreRS = rs.next();
    if(moreRS)
    car.setLicense(rs.getLong(1));
         car.setColor(rs.getString(2));
         car.setDoors(rs.getString(3));
    car.setYearMade(rs.getString(4));
    //but this will only get me one car. How do I get more car data?
    HELP!!

    Vector cars = new Vector();
    while (rs.next()) {
      String license = rs.getLong(1);
      String color = rs.getLong(2);
      String doors = rs.getLong(3);
      String year = rs.getLong(4);
      myTextArea.append(license+"\t"+color+"\t"+doors+"\t"+year+"\n");
      Car car = new Car();
      car.setLicense(license);
      car.setColor(color);
      car.setDoors(doors);
      car.setYearMade(year);
      cars.add(car);
    }t=tab
    n=newline
    Vector: http://java.sun.com/j2se/1.4.1/docs/api/java/util/Vector.html

  • How to obtain a session object from session id

    Hi all,
    let say that I have a list of session ids, and I want by scheduald task to check whether the session is alive\active.
    I saw that the HttpSessionContext was deprecated. (see: http://javasolution.blogspot.com/2007/08/getting-session-object-using-session-id.html)
    Is there any other way to check if the session is alive?

    Do it the other way: let the session itself notify that it is not alive anymore.
    Implement a HttpSessionListener which adds the session to list/set/map on create and removes the session from it on destroy, register it in the web.xml and run it.

  • Retrive an object from session throw class not found at findClassOnDisk exception

    java.lang.ClassNotFoundException: not found at findClassOnDisk
    at com.iplanet.ias.classloader.IasAppClassLoader.findClassOnDisk(Unknown Source)
    at com.iplanet.ias.classloader.IasAppClassLoader.findClass(Unknown Source)
    at com.iplanet.ias.classloader.IasAppClassLoader.loadClass(Unknown Source)
    at com.iplanet.ias.classloader.IasAppClassLoader.loadClass(Unknown Source)
    at com.iplanet.ias.classloader.IasAppClassLoader.loadClass(Unknown Source)
    at com.iplanet.ias.classloader.AppClassLoaderController.loadClass(Unknown Source)
    at com.netscape.server.deployment.AppComponentDescriptor.classForName(Unknown Source)
    at com.kivasoft.util.Util.classForName(Unknown Source)
    at com.kivasoft.eb.EBHelper.classForName(Unknown Source)
    at com.kivasoft.util.NASObjectInputStream.resolveClass(Unknown Source)
    at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:918)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
    at java.io.ObjectInputStream.inputArray(ObjectInputStream.java:1014)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:374)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2263)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1412)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2263)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1412)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
    at java.util.ArrayList.readObject(ArrayList.java:531)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:2214)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1411)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
    at com.netscape.server.servlet.platformhttp.PlatformNASSession.getMemberValue(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformNASSession.getValue(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformNASSession.getAttribute(Unknown Source)
    at jsp.APPS.tsws_war.jsp.attachment.updateFile._jspService(updateFile.java:246)
    at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown Source)
    Description:
    1) We are using iplanet distributed session
    2) We put a ArrayList of object into the session
    3) Retrieve it from session immediately - no problem
    4) display jsp on user browser
    5) browser submit another request
    6) retrieve it from session again, the above error show up. (other session attribute was able to retrieve so it is not session timeout)
    if we can save the object into the session. The object 's class should be avaliable ?!?!
    (currently using iplanet 6.5 with mp1 tested both on
    solaris machine and win2000 machine)

    I guess, the problem is due to the distributed session.
    Make the session lite and check, if it works, then we can confirm that it is due to the guessed reason. Then please let me know.
    Mean time I also try to reproduce the problem, and find out the solution.
    Thanks and best of luck,
    Rakesh.

  • Adobe Form with XML interface cannot retrieve all data from SAP

    hi all
    I want to use the Adobe forms for the real estate module.
    I had seen that adobe forms can have an interface with XML input and output as parameter.
    In the interface type only the /DOCPARAMS an the DOCXML are INPUT parameters which are available.
    No other INPUT parameter can be added to it.
    When i try to retrieve the data in real estate there are some default function modules for retrieving the data from real estate.
    But this function modules also are going to find out if the form which asks for this information has a IMPORT parameter
    for the required data. For example, the SENDER data is retrieved, but before the default function module retrieve this data
    the function module checks if the form has a INPUT parameter SENDER.
    And that is not the case. And i cannot create the SENDER parameter to it, because this INTERFACE type does not allow it.
    Does anybody know a solution herefore?
    kind regards,
    Anton Pierhagen

    Hi Bhaskar
    It is a long time ago, almost 2 years.
    I created my own custom development for calling the Adobe form. This custom development uses the correct function module interface with the IMPORT XML.
    The XML which i sent as IMPORT PARAMETER to the form is also created by own custom development. Via the default XML class of SAP
    So that was my solution
    Kind regards,
    Anton Pierhagen

  • Error message- "LR has encountered problems reading this photo" after installing LR 5.6 on new computer and retrieving all contents from old HD from external HD.

    Hi-
    I got a new PC laptop, retrieved all old HD contents from my external HD, installed LR 5.6 (5.4 on previous PC) and when I tried to open up my old Lightroom catalog it has an error saying "Lightroom has encountered problems reading this photo.  You will not be able to make adjustments to this photo".  I tried to open the catalog straight from my external HD with the same error message. I've read about four billion forum threads to try to figure it out- files do not seem to be missing as most threads indicate.  The other threads suggest there is a corruption with the file, but I don't THINK that is the case.  Are there any other suggestions?   If the file is corrupted, how do I find out for sure?  Have I lost all my edits?? 
    Thanks for your help and time!
    sarah

    Hi-
    I got a new PC laptop, retrieved all old HD contents from my external HD, installed LR 5.6 (5.4 on previous PC) and when I tried to open up my old Lightroom catalog it has an error saying "Lightroom has encountered problems reading this photo.  You will not be able to make adjustments to this photo".  I tried to open the catalog straight from my external HD with the same error message. I've read about four billion forum threads to try to figure it out- files do not seem to be missing as most threads indicate.  The other threads suggest there is a corruption with the file, but I don't THINK that is the case.  Are there any other suggestions?   If the file is corrupted, how do I find out for sure?  Have I lost all my edits?? 
    Thanks for your help and time!
    sarah

  • How can I retrieve all texts from lost iPhone 6 plus left in lost mode?

    How can I retrieve all new texts going to my  lost iPhone 6 plus left in lost mode, through a browser or my wifi iPad ?

    Not through a browser.  If iMessage, set iPad to receive messages sent to your cell number:
    Settings > Messages > Send & Receive > You can be reached by iMessage at >
    SMS/MMS - no

  • Retrieving all FK from child table in a resultset

    I have a parent and its child table.In child table there are many records containing the same PK of the parent as a foreign key(one to many relationship).Now how can I get all those values (in a resultset) of child table containing the same FK .The code i produced can fetch the first record of the same PK of the parent.But how can I get all with a single SQl statement and iterate through them as necessary.
    String sql1="SELECT * FROM ChildTableName WHERE id= ' 100 ' ; //100 is the PK of Parent table // there are many records in Child Table having 100 as foreign key resultset = statement.executeQuery(sql1); resultset .next();      try{          System.out.println("Data> "+resultset.getString(1));         System.out.println("Data> "+resultset.getString(2));         System.out.println("Data> "+resultset.getString(3));   }catch(SQLException sqle){System.out.println("ERROR REFRESH : " + sqle); }{code} Edited by: Tanvir007 on Apr 17, 2008 4:35 AM Edited by: Tanvir007 on Apr 17, 2008 4:37 AM Edited by: Tanvir007 on Apr 17, 2008 4:40 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    duffymo wrote:
    First of all,ARE U BLIND brother, didn't you see what I wrote-
    String sql= "SELECT Flat_Rent.rent_id,Flat_Rent.flat_name FROM Month_Rent INNER JOIN Flat_Rent ON Month_Rent.rent_id = Flat_Rent.rent_id WHERE Flat_Rent.rent_id = '4-2008'" ;      
    Actually, I did see that. It makes me wonder why you were asking in the first place and what the problem is now.In the first place, I didnt use join,I did it later as u advised.But u asked me later about the join.Why?
    >
    People who have empty catch blocks are fools. If you don't want to be one, log or print the stack trace. It's good information to have, and it'll help you avoid problems in the future.People are fools for many reasons LIKE - even if I told u that I can retrieve record (but only the first record),there is no question of throwing an exception.And I DID fill catch block in the first place,look back.Later, it wasnt that much necessary bcos no exception throws at all.
    However brother many thanks for an attempt to help me.I think I have solved the problem-
    try{
    String sql= "SELECT flat_name,flat_rent,elec_bill FROM Month_Rent INNER JOIN Flat_Rent ON Month_Rent.rent_id = Flat_Rent.rent_id WHERE Flat_Rent.rent_id = '4-2008'" ;      
                             resultset = statement.executeQuery(sql);               
                             resultset .next();
                             do
                                  System.out.println("Flat Name>> " + resultset .getString(1));
                                  System.out.println("Rent>> " + resultset .getString(2));
                                  System.out.println("Elec Bill>> " + resultset .getString(3));
                             while(rs.next());
                        }catch(SQLException sqle){ sqle.printStackTrace();           }But the problem is, The fields in my DB are in this serial- rent_id,flat_name,flat_rent,elec_reading,elec_bill,total_rent,status
    But as you can see from the code that I get the Flat name in 1,Rent in 2 and bill in 3 which should be 2,3,5 respectively.Can you tell me why it is so?

  • Retrieve all values from project type when project type combo box is null

    Hi,
    We are facing a tight situation here. We have a scenario where we have 2 filter options.
    1) Department ID
    2) Project type
    When department ID is selected all the department IDs should be populated in the combo box and the project type combo box should be empty.
    Similarly, when project type is selected all the project types should be populated in the combo box and the department ID combo box should be empty.
    Then, when more than one value is selected from department ID box and all the values from project type must be retrieved from query level (as per business logic).
    How do we do this? Kindly help us with this situation.

    Basically my situation slightly different.
    I am trying to do a bulk insert on SQL Server table using prepared statement, during that time i am getting the exception. I am using JDBC-ODBC driver. However, if i do individual record insertion, it is working.
    Any idea about this type of problem ?
    Regards
    Ramesh

  • How To Retrieve All Data From a Submitted h:dataTable ... ?

    I have a table together with a button displayed in the browser. Upon click on the button, an action is invoked.
    I would like to retrieve the data in the entire table in this action.
    Because the displayed table is created by a managed bean class ListAction, "personnel" is the property of the bean class, and the "personnel" is a List, when I try to retrieve the data this way:
                                              ListAction listAction = new ListAction();
              DataModel personnelData = listAction.getPersonnel();
             List personnel = (List)personnelData.getWrappedData();The compiler says that a List cannot be converted to DataModel.
    What should I do? I need guidance.

    Thanks for the reply. I tried to follow your advice. Somehow, I ran into a runtime ClassCastException.
    In my xxx.jsp I have
    <h:dataTable value="#{arrival.personnel}" var="pInfo">
    <h:commandButton id="Depart" value="DEPART" action="#{departure.updateDeparturePersonnel}"/>The "personnel" is the List that builds the xxx.jsp and it is also the List I try to access after the button in the xxx.jsp is clicked. Here in my configuration file:
    <managed-bean>
      <managed-bean-name>arrival</managed-bean-name>
      <managed-bean-class>processAction.DepartureManagementBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
      <managed-bean-name>departure</managed-bean-name>
      <managed-bean-class>processAction.DepartureManagementBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>when the updateDeparturePersonnel() method is called in the DepartureManagementBean.java, I got run-time ClassCastException. And I am unable to see the problems in my code.
    quote:
    java.lang.ClassCastException
    com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
    javax.faces.component.UICommand.broadcast(UICommand.java:312)
    javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
    javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
    com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    This is my DepartureManagementBean.java:
    package processAction;
    import java.util.ArrayList;
    import java.util.List;
    import processDelegate.ListPersonnel;
    import processDelegate.PersonnelBean;
    public class DepartureManagementBean
        private List personnel = new ArrayList();
        private List departurePersonnel = new ArrayList();
        // The constructor part and the creation of the "personnel" List has been successfully tested
        public DepartureManagementBean()
         // instantiate the business delegate
         ListPersonnel listPersonnel = new ListPersonnel();
         personnel = listPersonnel.getPersonnelInfo();
         public List getPersonnel()
              return personnel;
         public void setPersonnel( List personnel )
              this.personnel = personnel;
         public List updateDeparturePersonnel( )
            // Iterate through the data rows ...
            for ( int index = 0; index < personnel.size(); index++ )
                PersonnelBean personnelBean = new PersonnelBean();
                 personnelBean = ( PersonnelBean )personnel.get(index);
                     // If this row is selected, add all data fields the corresponding message
                     if ( personnelBean.isSelectedPersonnel() )
                         departurePersonnel.add( personnelBean );
            return departurePersonnel;
        public List getDeparturePersonnel()
          return departurePersonnel;
        public void setDeparturePersonnel( List departurePersonnel )
          this.departurePersonnel = departurePersonnel;
    }// End DepartureManagementBean.java

Maybe you are looking for