Can anybody help me pls?

im having a problem with my jsp and its giving me a null pointer exception
<%
                         if(request.getParameter("username")!=null){
                              String username=request.getParameter("username");
                              String password=request.getParameter("password");     
                                   try{
                                        statement = connection.createStatement();
                                        String query ="select password,username,usergroup_name from user where username='" username.trim()"'";
                                        rs = statement.executeQuery(query);
                                             if(rs.next()){
                                                       if(password.trim().equals(rs.getString("password"))){
                                                            if(rs.getString("usergroup_name").equals("administrator")){
                                                                 session.setAttribute("the_user",rs.getString("username"));
                                                                 session.setAttribute("the_role",rs.getString("usergroup_name"));
                                                                 response.sendRedirect("adminhome.jsp");
                                                            if(rs.getString("usergroup_name").equals("user")){
                                                                 session.setAttribute("the_user",rs.getString("username"));
                                                                 session.setAttribute("the_role",rs.getString("usergroup_name"));
                                                                 response.sendRedirect("userhome.jsp");
                                                       else{ out.println("<li>Incorrect Password!</li>"); }
                                             else{ out.println("<li>Username doesn't Exist</li>");     }
                                   }catch(Exception e){ }                    
               %>
java.lang.NullPointerException
     org.apache.jsp.adminlogin_jsp._jspService(adminlogin_jsp.java:93)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Firstly, neat and orderly code is goddly when you are expecting help from others!!!
<%
  String username = request.getParameter("username");
  String password = request.getParameter("password");
  if ( username !=null && password != null )
    try
      // This assumes that a connection variable exists and is not null
      statement = connection.createStatement();
      String query ="select password,username,usergroup_name from user where username='" +username.trim()+"'";
      rs = statement.executeQuery(query);
      if ( rs.next() )
        if ( password.trim().equals(rs.getString("password")) )
          String ug = rs.getString("usergroup_name");
          // This assumes that a session variable exists and is not null
          session.setAttribute("the_user", rs.getString("username"));
          session.setAttribute("the_role", rs.getString("usergroup_name"));
          if ( ug.equals("administrator") ) response.sendRedirect("adminhome.jsp");
          if ( ug.equals("user") ) response.sendRedirect("userhome.jsp");
        else out.println("<li>Incorrect Password!</li>");
      else out.println("<li>Username doesn't Exist</li>");
    catch ( Exception e )
      // The exception stack trace will appear in the stdout.log file
      // $tomcat_home/logs
      e.printStackTrace();
%>HTH

Similar Messages

  • HT204291 Im trying to use my apple TV to see a movie from my iphone. Since i select the airplay icon on my phone, i can only hear the voice of the movie on my screen but i cant see the movie, can anybody help me pls? Tks

    Im trying to use my apple TV to see a movie from my iphone. Since i select the airplay icon on my phone, i can only hear the voice of the movie on my screen but i cant see the movie, can anybody help me pls? Tks

    Is this a movie from iTunes? If so is it a rental or one you've purchased?

  • I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    I've just downloaded a sd movie from iTunes with my ipad but the movie will only play for 13s then a msg comes up saying "could not load video! I've paid for it and downloaded the whole thing ! Can anybody help me pls?

    Hello Lcw2610,
    I would recommend deleting the affected movie from your iPad, and redownloading the movie.
    How to delete content you've downloaded from the iTunes Store, App Store, iBooks Store, or Mac App Store
    http://support.apple.com/kb/HT5772
    Download past purchases
    http://support.apple.com/kb/HT2519
    If the issue persists, please do report the issue to the folks in our iTunes Store.
    To report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase, follow these steps:
    Find the email receipt for your purchase.
    Click Report a Problem under the app that is having the issue.
    When prompted, enter the Apple ID and password you used to purchase the item, then click Report a Problem.
    Click Report a Problem next to the item you are having an issue with.
    From the Choose Problem dropdown menu, choose the appropriate issue.
    Follow the onscreen instructions and—if prompted—type a description of the problem into the text field.
    Click Submit to have your issue reviewed.
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/HT1933
    Cheers,
    Allen

  • HT3275 I am backing up my iMac using TIME MACHINE and red FAILED occured stating "unable to complete back up. an error acccured while creating back up folder" can anybody help me pls. =Mochincess

    Backing up Problem: Using time Machine to back up my iMac, and failed occured stating" unable to complete backup. An error occured while creating backup folder. Pls. help....using reformatted WD 2TB Passport

    Hello...
    https://discussions.apple.com/thread/4413173?start=0&tstart=0

  • I have an acer aspire 5935 32bit and i cant download itunes as it just keeps freezing. can anybody help pls??

    i have an acer aspire 5935 32bit and i cant download itunes as it just keeps freezing. can anybody help pls??

    Have you tried "Run" instead of "Save?"
    Do you have anti-virus software on the PC? If you do, try disabling the anti-virus for just 15minutes to allow the download to finish.
    Hope one of those helps.

  • I cannot open iCal because of a problem. Can anybody help me? The computer will not allow it to open and sends a message to apple each time. The icon has gone from the dock, but ical works on my iPad and I am afraid to sync it with my computer.?

    I cannot open iCal because of a problem. Can anybody help me? The computer will not allow it to open and sends a message to apple each time. The icon has gone from the dock, but ical works on my iPad and I am afraid to sync it with my computer in case it wipes everything .

    I have the exact same problem. I have not changed anything. This is probably a bug or something that has gone bad with Mac OS X (10.7.2). I have not found any solution for this on the web.
    MacBook Pro, Mac OS X (10.7.2).

  • I desperately to uninstall adobe reader from my Mac book air. I sent adobe reader to trash and afterwards look for internet plugs in in library but the folder is empty. Can anybody help me?

    I desperately need to uninstall adobe reader from my Mac book air. I sent adobe reader to trash and afterwards look for internet plugs in  library but this folder is empty in my library. Can anybody help me?

    I looked for plugs in in my library but the folder internet plugs in is empty

  • My ipad just won't let me enter my apple password on FaceTime or iMessage, it works fine on my iPhone, I have tried numerous things but nothing works, can anybody help please, will a bug fix sort this out when they finally make one

    My ipad just won't let me sign in with my apple password on FaceTime or iMessage since updating to ios7 it says check my network connection, even though my iPhone works fine with the same password, can anybody help please, I have tried numerous things but nothing  works.  Will I have to wait for a bug fix to sort this? I hear they are working on one a the minute, I hate ios7

    Try a Restart.
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
    Resetting your settings
    You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
    Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple.
    Here is a link to their contacts with most of the information below.
    http://www.apple.com/contact/

  • I have an iPhone 3gs and it used to show up on my computer, but now it shows up on my screen that it is charging however, does not appear in iTunes or My Computer so i can't sync it. Can anybody help? Thanks

    I have an iPhone 3gs and it used to show up on my computer, but now it shows up on my screen that it is charging however, does not appear in iTunes or My Computer so i can't sync it. Can anybody help? Thanks.

    Did you already make sure that Apple Mobile Device Service is installed and active on your computer?
    http://support.apple.com/kb/TS1567
    More troubleshooting about your device not recognized in Windows can be found here: http://support.apple.com/kb/TS1495

  • My Bluetooth USB wireless transmitter for my portable speakers has quit working.  Preferences says, "The selected device has no output controls", it used to work just fine.  Can anybody help?

    My Bluetooth USB wireless transmitter for my portable BT speakers has quit working.  Preferences says, "The selected device has no output controls", it used to work just fine.  The internal and a pair of wired external speakers work fine.  Can anybody help?

    Just tested something and it worked.
    If I put the headphones all the way in, the mac recognizes it as a digital output.
    But if i don't put it all the way in, it recognizes it as headphones and works perfectly.
    It's probably this crappy headphones.
    If anyone has the same problem, try this out.

  • I have been trying to put music I bought on I tunes on my Samsung Note 2 phone but it won't play.I try to convert them to mp3 format so I can play them on my phone but it won't let me convert them because it says they are protected. Can anybody help me?

    I have been trying to put music I bought on Itunes on my Samsung Note 2 but my media player won't play m4p files so I tried to convert the files to mp3 but I couldn't, because a message says they are protected files. I then tried downloading different media player apps to see if they would play them but had no success.Can anybody help with a solution to this problem?

    First quit iTunes and look in your iTunes folder.
    On Windows, the iTunes folder is in your My Music folder.
    On Mac, the iTunes folder is in your Music folder.
    Follow this path:    iTunes > iTunes Media > Music >
    Here there should be all your music folders. Open the folders containing the music that is not playing. Right click "get info" (mac) or right click "properties" (windows).
    This window will tell you the file type. iTunes will play music in AAC, MP3, and Lossless, etc.
    If the files are .wma you will need to convert them into ACC or MP3 format for it to play on an iPod. In iTunes, highlight the tracks that you want to convert, then on the menu bar, Advanced > Create AAC/MP3 version and the tracks will convert. Delete the old files.
    If the file extenstion is anything like .exe .txt .rar  then you don't have an audio file.

  • My ipod is 8gb and it wont let me download anymore songs, i currently have 1200 and i thought an 8gb ipod would hold at least 1700, can anybody help?

    I have an 8gb ipod which has only 1200 songs on it, no photo's, no apps and no video's and it's telling me that my storage is full, can anybody help/

    The number of songs that any iDevice will store depends on both the length/duration of songs and on the audio format(s) used.  The figure of "1700" is nothing more than an estimate ... probably based on 3-minute songs and low bit-rates.  There is no definitive number - your iPod's capacity is based on available memory (which, for an 8Gb iPod is actually around 7Gb).  Best way to manage the content of your iPod is to create one or more playlists that are then used as the basis for sync operations (set this up when your iPod is connected).

  • HT201304 Why is it not letting me download free apps on my iPad when ? It's asking for my bank details again and when I type my security number in its says its been declined from a previous purchase? Can u help me pls!

    Why is t not letting me download free apps on my iPad when it's asking for my security number and when I type it in my details on my iCloud account it's saying its been declined and asking for another payment card ? Can some1 help me pls!!

    You will need to contact iTunes support to get that sorted out: http://www.apple.com/support/itunes/contact/

  • I have a problem while typing in my MacBook pro. it is showing different characters when i type. for example: qw`e§r]t[y=   this is how when we type "qwerty|" can anyone help me pls?

    I have a problem while typing in my MacBook pro. it is showing different characters when i type. for example: qw`e§r]t[y=   this is how when we type "qwerty|" can anyone help me pls?

    You could just try changing your Input Sources under System Preferences>Language & Text:
    But I kind of doubt that's going to work. It may be a hardware problem or a system problem. If you take it into Apple they might be able to determine which and might advise a reinstallation of System software. I would take it to an Apple Store or an AASP but, first, make sure that you have a backup just in case they suggest a clean install of the system.
    Good luck,
    Clinton

  • Hi all! I was updating the software on i pad to ios6, update was interrupted(apple update server is unavailable...). iTunes Diagnostics shows that "secure link to I tunes store failed". I use Windows 7 Home Premium 64 bit. Can anybody help please?

    Hi all! I was updating the software on i pad to ios6, update was interrupted(apple update server is unavailable...). iTunes Diagnostics shows that "secure link to I tunes store failed". I use Windows 7 Home Premium 64 bit. Can anybody help please?
    The following was done so far:
    1. Windows Firewall - new rule created for itunes.
    2. iTunes - latest version installed.
    3. LAN setting : automatic detection of proxy is enabled;
    4. iTunes diagnostics shows:
    Microsoft Windows 7 x64 Home Premium Edition (Build 7600)
    TOSHIBA Satellite L655
    iTunes 11.0.2.26
    QuickTime 7.7.3
    FairPlay 2.3.31
    Apple Application Support 2.3.3
    iPod Updater Library 10.0d2
    CD Driver 2.2.3.0
    CD Driver DLL 2.1.3.1
    Apple Mobile Device 6.1.0.13
    Apple Mobile Device Driver 1.64.0.0
    Bonjour 3.0.0.10 (333.10)
    Gracenote SDK 1.9.6.502
    Gracenote MusicID 1.9.6.115
    Gracenote Submit 1.9.6.143
    Gracenote DSP 1.9.6.45
    iTunes Serial Number 003FB880034B7720
    Current user is not an administrator.
    The current local date and time is 2013-04-23 11:01:14.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is supported.
    Core Media is supported.
    Video Display Information
    Intel Corporation, Intel(R) HD Graphics
    **** External Plug-ins Information ****
    No external plug-ins installed.
    iPodService 11.0.2.26 (x64) is currently running.
    iTunesHelper 11.0.2.26 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    **** Network Connectivity Tests ****
    Network Adapter Information
    Adapter Name:          {1CB5BBC2-8124-4664-899A-CE0A4683E3B4}
    Description:          Realtek RTL8188CE Wireless LAN 802.11n PCI-E NIC
    IP Address:          0.0.0.0
    Subnet Mask:          0.0.0.0
    Default Gateway:          0.0.0.0
    DHCP Enabled:          Yes
    DHCP Server:
    Lease Obtained:          Thu Jan 01 08:00:00 1970
    Lease Expires:          Thu Jan 01 08:00:00 1970
    DNS Servers:
    Adapter Name:          {8140112A-43D0-41D6-8B36-BE146C811173}
    Description:          Atheros AR8152/8158 PCI-E Fast Ethernet Controller (NDIS 6.20)
    IP Address:          10.5.7.196
    Subnet Mask:          255.255.0.0
    Default Gateway:          10.5.0.1
    DHCP Enabled:          Yes
    DHCP Server:          172.18.255.2
    Lease Obtained:          Tue Apr 23 10:14:40 2013
    Lease Expires:          Tue Apr 23 22:14:40 2013
    DNS Servers:          121.97.59.7
                        121.97.59.2
                        121.97.59.3
    Active Connection:          LAN Connection
    Connected:          Yes
    Online:                    Yes
    Using Modem:          No
    Using LAN:          Yes
    Using Proxy:          No
    Firewall Information
    Windows Firewall is on.
    iTunes is NOT enabled in Windows Firewall.
    Connection attempt to Apple web site was successful.
    Connection attempt to browsing iTunes Store was unsuccessful.
    The network connection timed out.
    Connection attempt to purchasing from iTunes Store was successful.
    Connection attempt to iPhone activation server was successful.
    Connection attempt to firmware update server was unsuccessful.
    The network connection timed out.
    Connection attempt to Gracenote server was successful.
    The network connection timed out.
    Last successful iTunes Store access was 2013-03-22 10:05:31.
    @@@. iTunes IS ENABLED THROUGH THE FIREWALL , even though diagnostics says "NOT enabled"

    hours after the first post i somehow got this to work. dont know how, but i do tried the dns clear cache, the clear host file, oh and i did the check automatically detech dns AND THEN se-check it again before i got this to work.

Maybe you are looking for