Anyone shed some light on this???

Hi there,
I have a class that returns a value based on a calculation with in the class
2 of the variables are called from a database, which is working however when I try to output the result on a jsp page ie. calling the property 'rating' I am told it is "null" on the page....
was wondering if sombody could review my code and make any suggestions as to where my problem lies .....
The variable amount is inputted by the user...
This is the class for calculating:
* Pressup.java
* Created on 29 April 2007, 13:03
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
* @author Hegstatic
*/package fitness;
import java.sql.*;
import java.text.*;
public class Pressup {
    /** Creates a new instance of Pressup */
   int age;
   int amount;
   String rating;
   String gender;
   Connection con;
   String error;
  public int getAge(String userName) throws SQLException, Exception{
                 if(con != null){
                 try{
                ResultSet rs;
                Statement stmt = con.createStatement();
               rs = stmt.executeQuery("SELECT age FROM gymuser WHERE Username= 'userName' ");
                while (rs.next()) {
               age = rs.getInt("age");
               return age;
               } catch(SQLException sqle){
               error = "SQLException: could not search gymuser";
                throw new Exception(error, sqle);
               catch(Exception e){
               error = "An exception occured while searching gymuser";
               throw new Exception(error);
                } else {
               error = "Exception: connection to database was lost";
               throw new Exception(error);}
    public void setAge(int age)
        this.age = age;
        System.out.println(age);
    public String getGender(String userName) throws SQLException, Exception{
                 if(con != null){
                 try{
                ResultSet rs;
                Statement stmt = con.createStatement();
               rs = stmt.executeQuery("SELECT gender FROM gymuser WHERE Username= 'userName' ");
                while (rs.next()) {
               gender = rs.getString("gender");
               return gender;
               } catch(SQLException sqle){
               error = "SQLException: could not search gymuser";
                throw new Exception(error, sqle);
               catch(Exception e){
               error = "An exception occured while searching gymuser";
               throw new Exception(error);
                } else {
               error = "Exception: connection to database was lost";
               throw new Exception(error);}
                public void setGender(String gender){
                    this.gender = gender;
   public int getAmount()
    return amount;
   public void setAmount(int amount)
       this.amount = amount;
   public String getRating()
   { if (String.valueOf(gender) == "male")
            if (age>= 0 && age <= 29 && amount >=55 ) {
                rating = "Excellent";
            } else if (age>= 0 && age <= 29 && amount >=45 && amount <=54 ) {
                rating = "Good";
            } else if (age>= 0 && age <= 29 && amount >=35 && amount <=44 ) {
                 rating = "Average";
            } else if (age>= 0 && age <= 29 && amount >=20 && amount <=34 ) {
                rating = "Fair";
            }else if (age>= 0 && age <= 29 && amount >=0 && amount <=19 ) {
                 rating = "Poor";
            } else if(age>= 30 && age <=39 && amount >=45) {
                rating = "Excellent";
            } else if(age>= 30 && age <=39 && amount >=35 && amount <=44) {
                rating = "Good";
            } else if(age>= 30 && age <=39 && amount >=25 && amount <=34) {
                rating = "Average";
            } else if(age>= 30 && age <=39 && amount >=15 && amount <=24) {
                rating = "Fair";
            } else if(age>= 30 && age <=39 && amount >=0 && amount <=14)  {
                rating = "Poor";
            } else if(age>= 40 && age >=49 && amount >=40) {
                rating = "Excellent";
            } else if(age>= 40 && age <=49 && amount >=30 && amount <=39) {
                rating = "Good";
            } else if(age>= 40 && age <=49 && amount >=20 && amount <=29) {
                rating = "Average";
             } else if(age>= 40 && age <=49 && amount >=12 && amount <=19) {
                rating = "Fair";   
            } else if(age>= 40 && age <=49 && amount >=0 && amount <=11) {
                rating = "Poor";
            } else if(age>= 50 && age <=59 && amount >=35) {
                rating = "Excellent";
            } else if(age>= 50 && age <=59 && amount >=25 && amount <=34) {
                rating = "Excellent";
              } else if(age>= 50 && age <=59 && amount >=15 && amount <=24) {
                 rating = "Average";
                 else if(age>= 50 && age <=59 && amount >=8 && amount <=14) {
                   rating = "Fair";
                } else if(age>= 50 && age <=59 && amount >=0 && amount <=7) {
                    rating = "Poor";
                }  else if(age>= 60 && age <=79 && amount >=30) {
                    rating = "Excellent";
                 } else if(age>= 60 && age <=79 && amount >=20 && amount <=29) {
                    rating = "Good";
                 } else if(age>= 60 && age <=79 && amount >=10 && amount <=19) {
                    rating = "Average";
                } else if(age>= 60 && age <=79 && amount >=5 && amount <=9) {
                rating = "Fair";
                } else if(age>= 60 && age <=79 && amount >=0 && amount <=4) {
                rating = "Poor";
     else if (String.valueOf(gender) == "female")
                if (age>= 0 && age <=29 && amount >=49) {
                rating = "Excellent";
                }else if (age>= 0 && age <=29 && amount >=34 && amount <=48) {
                rating = "Good";
                }else if (age>= 0 && age <=29 && amount >=17 && amount <=33) {
                 rating = "Average";
                }else if (age>= 0 && age <=29 && amount >=6 && amount <=16) {
                rating = "Fair";
                }else if (age>= 0 && age <=29 && amount >=0 && amount <=5) {
                rating = "Poor";
                }else if (age>= 30 && age <=39 && amount >=40) {
                rating = "Excellent";
                }else if (age>= 30 && age <=39 && amount >=25 && amount <=35) {
                rating = "Good";
                }else if (age>= 30 && age <=39 && amount >=12 && amount <=24) {
                 rating = "Average";
                }else if (age>= 30 && age <=39 && amount >=4 && amount <=11) {
                rating = "Fair";
                }else if (age>= 30 && age <=39 && amount >=0 && amount <=3) {
                rating = "Poor";
                }else if (age>= 40 && age <=49 && amount >=35) {
                rating = "Excellent";
                }else if (age>= 40 && age <=49 && amount >=20 && amount <=34) {
                rating = "Good";
                }else if (age>= 40 && age <=49 && amount >=8 && amount <=19) {
                rating = "Average";
                }else if (age>= 40 && age <=49 && amount >=3 && amount <=7) {
                rating = "Fair";
                 }else if (age>= 40 && age <=49 && amount >=0 && amount <=2) {
                rating = "Poor";
                }else if (age>= 50 && age <=59 && amount >=30) {
                rating = "Excellent";
                }else if (age>= 50 && age <=59 && amount >=15 && amount <=29) {
                rating = "Good";
                }else if (age>= 50 && age <=59 && amount >=6 && amount <=14) {
                rating = "Average";
                } else if (age>= 50 && age <=59 && amount >=2 && amount <=5) {
                rating = "Fair";
                }else if (age>= 50 && age <=59 && amount >=0 && amount <=1) {
                 rating = "Poor";
                }else if (age>= 60 && age <=69 && amount >=30) {
                rating = "Excellent";
                }else if (age>= 60 && age <=69 && amount >=20 && amount <=29) {
                rating = "Good";
                }else if (age>= 60 && age <=69 && amount >=11 && amount <=19) {
                rating = "Average";
                }else if (age>= 60 && age <=69 && amount >=5 && amount <=10) {
                rating = "Fair";
                }else if (age>= 60 && age <=69 && amount >=0 && amount <=4) {
                rating = "Poor";
            return rating;
       public void setRating(String rating)
           this.rating = rating;
   }This is the jsp page im calling the value from :
<!--Here the user calls either the newEmployer or newStudent methhods from the DBQuery, depending on the user type-->
<%@page contentType="text/html"%>
<%@page import="java.sql.*, fitness.*"%>
<jsp:useBean id="pressup" scope= "session" class="fitness.Pressup" />
<jsp:useBean id="currentuser" scope="session" class="fitness.currentuserBean" />
<jsp:setProperty name="pressup" property="amount" param="amount" />
<html>
    <head><title>Press up</title></head>
    <body>
                Your Pressup rating is<jsp:getProperty name="pressup" property="rating" />
               <form action="Pressupupdate.jsp" method = post /> <input type="submit"  value="Save and Move on" />
   </form>
         </body>
     </html>The comes up reading "Your Pressup rating is null"
Again any help would be greatly appreciated....
Thanks,
Heg

rs = stmt.executeQuery("SELECT gender FROM gymuser WHERE Username= 'userName' ");
in this line i think there is some error put it like this
rs = stmt.executeQuery("SELECT gender FROM gymuser WHERE Username= '"+userName+"' ");
Try to put some SOPs in between, so that u can check in logs(if using tomcat)where u r making mistake.

Similar Messages

  • So I  downloaded acrobat XI Standard from the Adobe website, when I go to install it, it says "Adobe XI Pro" at the top left corner. Can anyone shed some light on this for me? I have a volume license for XI Std. so I would like to use the Std. version.

    So I  downloaded acrobat XI Standard from the Adobe website, when I go to install it, it says "Adobe XI Pro" at the top left corner. Can anyone shed some light on this for me? I have a volume license for XI Std. so I would like to use the Std. version.

    login and download your software from the adobe volume licensing website, Customer resources | Adobe Buying Programs

  • Plugged in Apple TV, Apple symbol appears the a view of the rear of the box with a USB lead going to an iTunes symbol? Can anyone shed some light on this oh and it doesn't go past this point

    Plugged in Apple TV, Apple symbol appears the a view of the rear of the box with a USB lead going to an iTunes symbol? Can anyone shed some light on this oh and it doesn't go past this point

    You need to grab a micro usb cable and restore via iTunes
    http://support.apple.com/kb/HT4367?viewlocale=en_US&locale=en_US

  • When registering my iphone on itunes the message - the sim card insertedin this iphone does not appear to be supported - can anyone shed some light on this and tell me a way around this problem?

    when registering my iphone on itunes the message - the sim card insertedin this iphone does not appear to be supported - can anyone shed some light on this and tell me a way around this problem? the phone itself is an english phone and tried to register with a spanish sim and that message appeard, so i tried with my iphone sim which is english and the same message appeared!
    thanks

    Is the English sim from the original carrier as that is usually the message you get with a carrier locked phone.

  • HT1338 I am trying to register my Appliances and when I try to click on "Save" or "Submit" I am unable on my MacBook pro. I have tried different browsers yet still same problem.  Can anyone shed some light on this please.

    I am trying to register my Appliances and when I try to click on "Save" or "Submit" I am unable on my MacBook pro. I have tried different browsers yet still same problem.  Can anyone shed some light on this please.

    Thanks for that 'sberman' - because my iPhone is backed-up to my work computer (only at this stage) I have had to call our IT Department in Adleaide. (4 times this morning). The last guy managed to get the phone into 'DFU Mode' - no more recovery mode screen - (kind of 'asleep' perhaps) from my understanding of same. I am awaiting a call again from IT so they can get my computer to actually recognise my iPhone on the C Drive. This also happened to  one of my colleagues in Newman (WA). She got so frustrated with the whole process that she bought another phone the next time she was in 'civilisation.' She hasn't had any problems since. (Cross fingers).
    Thanks again, Sandra2474.

  • Ever since my last update I have been unable to add songs from my i tunes library onto my i phone.  The "add to" button does not appear for me when I connect my i phone.  Can anyone shed some light on this for me?

    Ever since my last update I have been unable to add songs from my i tunes library onto my i phone.  The "add to" button does not appear for me when I connect my i phone.  Can anyone shed some light on this for me?

    Thanks for that 'sberman' - because my iPhone is backed-up to my work computer (only at this stage) I have had to call our IT Department in Adleaide. (4 times this morning). The last guy managed to get the phone into 'DFU Mode' - no more recovery mode screen - (kind of 'asleep' perhaps) from my understanding of same. I am awaiting a call again from IT so they can get my computer to actually recognise my iPhone on the C Drive. This also happened to  one of my colleagues in Newman (WA). She got so frustrated with the whole process that she bought another phone the next time she was in 'civilisation.' She hasn't had any problems since. (Cross fingers).
    Thanks again, Sandra2474.

  • Mac test number 4SNS/1/40000001:VPOR-6.054 anyone shed some light on this?

    Just done a hardware test from my USB stick and this number cam up as a hardware fault found ...4SNS/1/40000001:VPOR-6.054
    MacBook Air late 2010 model A1369 serial number ---------DR1
    Any help in deciphering this would be great
    Kind regards and thanks in advance
    Steve

    Connect its power adapter and run AHT again: Mac notebooks: Apple Hardware Test may report SNS alert when power adapter is not connected

  • HT200100 I ran this update and now 2011 outlook for Mac will not load, it indicates its not compatible with this operating system, can anyone shed some light on this?

    I ran the update for 10.7.4 and now my 2011 outlook will not load, I've reloaded the application and it still won't load, any help is so appreciated!

    Run all available Office 2011 software updates using Microsoft Auto Update program.

  • Can anyone shed some light on this?

    We are having problems running two iPhones.  When a setting is changed on one one it changed the other.

    Hey I know I'm new, but I'm running 3 iPhones and an iPad all using my one apple id, I've never had any problems with the setting's syncing between them.  Why would they need a whole new apple id?  Can they not just change the cloud settings on the individual phones so that they don't sync?  That's what I did, I sync my phone with my PC and my wife's phone & iPad sync to the cloud for most things.  before I made these changes she was getting my calender notifications but everything else was working perfectly and still does.
    I personally don't think you need a new apple id,  maybe the phones need to be named differently, and cloud settings need to be adjusted to your personal needs.
    I like having everything under the same id, since I can purchase apps for all my devices and we share the photo stream between all devices so I get to check out pictures she takes with the kids while i'm at work and vice versa.  Also love being able to use findmyiPhone to track her location (and vice versa).
    Sorry if I'm stepping on your toes Eric, but I just think that there is a better solution for the OP than creating a whole new apple id.

  • The Apple instructions with no luck. Grateful if anyone can shed some light on this !

    I seem to be unable to locate or play iTunes Radio in iTunes. I have followed the Apple instructoins with no luck. Grateful if anyone can shed some light on this !

    Thanks very much. Now I feel stupid!!

  • Woke up to my iPhone 4 being completely blank. I've tried restarting and resetting it as well as charging it and plugging into my computer. Can anyone shed some light as to what may be wrong or how to fix it? Thanks

    Woke up to my iPhone 4 being completely blank. I've tried restarting and resetting it as well as charging it and plugging into my computer. Can anyone shed some light as to what may be wrong or how to fix it? Thanks

    Hello there, Kyle.Kuz.
    The following Knowledge Base article that provides some helpful pointers to help resolve your issue is:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Specifically:
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIsand corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 15 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

  • Can anyone shed some light on the OS X icon "irregularity?"

    Had expected icons (Mail, Reminders, Calendar, etc.) would update to those of iOS 7 with the Mavericks update. They did not (for me)! Should I be doing something in order to see the updated icons in Applications and Dock? I noticed the icons changed in iCloud. This obviously is not a major issue just an observation. Can anyone shed some light on the OS X "irregularity?"

    When I upgraded to Mavericks... The Calendar and Notes icons were updated also.
    After the first reboot... they reverted back to the last generation.

  • I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    Argh - once again, I find my solution right after posting this. Left out one modification to the SWIG script, now it runs in 29 seconds vs C 16 seconds, I can live with that.

  • HT204492 can someone help me ? My iMac remote control isn't working properly , well all buttons are working apart from the MENU button !! Can anyone shed any light on this ?

    can someone help me ? My iMac remote control isn't working properly , well all buttons are working apart from the MENU button !! Can anyone shed any light on this ?

    As this is the forum for PPC (pre-2006, non Intel) iMacs I assume that is what you have.
    Try pairing the remote again:
    How to Pair your Remote to your Mac:
    http://support.apple.com/kb/HT1619?viewlocale=en_US

  • Safari cannot open the specified address as OS X does not recognise the internet address starting with "aam". Please please can someone shed some light on this, its driving me MAD!!!

    when i try to download the software onto my mac, i receive a message saying that safari cannot open the specified address as OS X does not recognise the internet address starting with "aam". Please please can someone shed some light on this, its driving me MAD!!!

    Try and download the Desktop Application First before trying to install any other Adobe Product. The link for AAM is Safari looking for Desktop Application in your machine.
    Creative Cloud Help | Creative Cloud for desktop

Maybe you are looking for

  • It will not download itunes 64 bit,

    How do I put itunes on my PC. It will not download 64 bit, but won't use any other either.

  • Newbie: Joining internal tables

    I would like to join two internal tables, but it looks like I cannot run INNER JOIN / LEFT OUTER JOIN statements on internal tables. Is there an efficient way of achieving the same result or would I be better off creating physical tables and join the

  • Poker Applications - Games

    We enjoy planning the texas hold-em poker with other real life players on MSN games.   No for real money but for fun.     I don't want to have to install Windows on my Macbook Air in order to do this.   Is there a game similar to this for Mac?

  • Can you change iMessage to not use the enter key to send a message on a macbook pro?

    I'm using a mac with OS X Yosemite version 10.10.1 and I'm wondering if you can somehow change the settings of iMessage so that when you press the enter key it doesn't send the message. Thanks if you can help.

  • Can I download and use celtx script software on the Blackberry Playbook?

    Can I download and use celtx script software on the Blackberry Playbook?  I really love the program and was looking at buying a playbook but would only do it if I could download that software.