Need help trying to figure this problem out.  Username validate on servlet.

Hello.
Here is my dilema. Almost everything works but the username check servlet.
I have form that gathers information that sends to a bean to validate the forms fields. If the fields check out ok it than forwards to Vusername servlet which checks the username in the database to make sure there is not one of the same username in there. If there is the servlet redirects to a retry page notifying the user that the username is already taken. If successfull the servlet forwards to another servlet which processes all the registration information into the database.
As i said everything works fine but the Vusername servlet. I dont think the problem is with my sql query which checks for an exsiting username with the one that was entered into the form.
I think the problem is with my if statements. I think they are currently checking if the sql query has ran. If true do this if false do that. Which is not right.
I need the if statments to check against the result of the sql query being true or false and than redirect depending on those variables.
Anyway any insight would be greatly appreciated.
Here is a copy of the Vusername servlet.
Thanks.
// Andy Janow
// 03/01/05
// Make sure the username is available.
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import Sql;
public class Vusername extends Sql
public void doPost( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException
     String user;
     String pass1;
     String pass2;
     String email;
     String sError = "/Error.jsp";
     String Failure = "You need to retry";
     String fUsername = "/usernameError.jsp";
     String fUserOb = "Username is in use already";
     // Get the username from the bean.
  user = req.getParameter("userName");
  pass1 = req.getParameter("password1");
  pass2 = req.getParameter("password2");
  email = req.getParameter("emailAddress");
  // Creating the string to check available username.  
  boolean isTaken = isUserNameTaken(user);
  // Creating the forward on error due to unavailable username selection.
   if (isTaken = true);
    req.setAttribute("fUserOb",fUserOb);
       RequestDispatcher rd = getServletContext().getRequestDispatcher(fUsername);
       rd.forward(req, res);
  // Creating the forward on Error page.
   if (isTaken = false);
    req.setAttribute("Failure", Failure);
       RequestDispatcher rd = getServletContext().getRequestDispatcher(sError);
       rd.include(req, res);
// Sql QUERY for username.
public boolean isUserNameTaken(String username)
    boolean isTaken = false;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try
        ps = connection.prepareStatement("SELECT userName FROM Registration WHERE userName = ?");
        ps.setString(1,username);
        rs = ps.executeQuery();
        isTaken = rs.next(); // returns true if there is a row returned
    catch (SQLException e)
        e.printStackTrace();
    finally
    { // ALWAYS clean up your resources
        try
            if (rs != null) rs.close();
        } catch (SQLException e) { /* close quietly */ }
        try
            if (ps != null) ps.close();
        } catch (SQLException e) { /* close quietly */ }
    return isTaken;
public void destroy()
  try
   connection.close(); // Closing the db connection (cleanup).
  catch( Exception e )
   System.err.println( "Problem closing the database" );
}

Thanks for the repli.
I forgot to come back here and fix the topic to issue solved.
In the past hour sience i posted i was able to work through and fix the problem.
Was with my if statment... Just an error of typing to fast i suppose and not really going through my code very thouroughly.
Think how i had the code posted i was using the
if statment to check if the sql statement was true , than another if statment to check if was false..
Thing is, is that i already was checking if the username was in the database or not in the actual sql statment block by assinging weather the it was (true) or it was not (false) to the resultset variable.
So in my if statments higher up in the code i just needed to reformat them correctly, from if true do this, and if false do this... To if some variable is present do this, else do this.
And now it works great.
Just in case anyone was wondering.
But thanks for the repli and interest :)

Similar Messages

  • Need help trying to figure this out!!!! Angle gradient???

    Hi,
    I've been working in a project where i'm not sure if the terminology is correct. But as far as my research goes
    it is refer as an angle gradient similar to the one in Photoshop. See image for idea:
    http://forums.adobe.com/thread/432656
    I would like to use the same technique and create something for complex like this:
    I already have made the path and but gradient doesn't seem to go around the paths.
    Please help!!!!!!!!! Can someone provide me with a step by a step in how to create
    a path like this?
    I'm running CS4 Ai, Ps. Anything will help.
    Thanks!!!

    This thread is 3.5 years old but here is a solution to make angle gradients in Illustrator CS6 and CC, which now have the capability to apply gradients on strokes.
    1. Make a circle and give it a stroke equal to half its size and align stroke to center.
    Example: 100px circle with  a 50px stroke.
    2. Apply a linear gradient that has the same color on the starting and ending stops (if you want a seamless gradient) and apply gradient along stroke.
    3. Apply Path > Effect > Offset Path half the amount of the stroke size and make it a negative value  so the path offsets inward.
    4. Done!

  • HT5622 I need help trying to figure out why I'm not able to purchase anythi iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

  • My MACBOOK PRO NEVER LETS ME OPEN AUTOTRADER AND WHEN I TRY TO OPEN IT GETS FROZEN AND IT FREEZES OTHER WINDOWS AS WELL. Please help me to sort this problem out asap. Thanks

    MY MACBOOK PRO NEVER LETS ME OPEN AUTOTRADER AND WHEN I TRY TO OPEN IT GETS FROZEN AND IT FREEZES OTHER WINDOWS AS WELL. Please help me to sort this problem out asap. Thanks

    To prevent this being accidentally activated in the future go to SystemPreferences>Keyboard>Keyboard Shortcuts>Universal Access and uncheck all the boxes.

  • Hello I Download Adobe Photoshop CC 2014 Last Night i INSTALLED it But it Crashes in 30-40 Sec After i Launch the Product Without Any Error Message I Need Help Can You Resolve This Problem i Tried Creative Cloud Sign Out Nd Sign iN But iT DidnT ReSolve My

    Hello I Download Adobe Photoshop CC 2014 Last Night
     i INSTALLED it But it Crashes in 30-40 Sec After i Launch the Product Without Any Error Message
    I Need Help Can You Resolve This Problem

    Lotfi are you receiving any error messages during the installation?  I would recommend reviewing your installation logs for errors.  Please see Troubleshoot install issues with log files | CC - http://helpx.adobe.com/creative-cloud/kb/troubleshoot-install-logs-cc.html for information on how to locate and interpret your installation log files.  You are welcome to post any specific errors you discover to this discussion.

  • My Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    my Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    Carlos-
    Start by signing out and back in to see if it will see the subscription: 
    How to sign in and sign out of creative cloud (activate/deactivate)
    If the apps are installed fine and close after launch see this link:
    CC applications close immediately after launch
    If the problem is something different, please let us know the error you see or what is happening on the screen so we can advise  you on a solution
    Pattie

  • Need help- trying to figure out if Spotify would work for my senior living community

    We are a senior community that has activity programs running in like 7-10 areas in the building.  Music is a big part of our day.  CD's for all these areas is getting crazy.  There has got to be a better way.  We want to be able to pick music genre, a song even to hear and have playlists.  What we have currently:  We have some laptops and desktop computer using windows.  We also have a few MP3 players, boomboxes and IPODS.  We also have Wifi.  But sometimes of course we have Wifi issues.  We have access to usually a laptop or boombox.  We could use the MP3 players/ipods.    I like the idea of playlists that we share, pulling music that is alike.  These are my quesitons or issues below: Things are my questions:1.   Can we have 1 account be made for different appliances and be on spotify at the same time?  Premium said 3 but you can't be both logged in under each account.  Is this still true?  Postings were old. 2.  With even the Spotify family can you be on to the account at the same time?  3.  What would be our best solution for this for accounts- would we have to set up different account for each device if we want to play at the same time?  Any ideas - I just really need suggestions4.  If we did our laptops, we would need speakers?  Also for boomboxes- is this possible?  I am assuming using like an MP3 player or IPOD.  Spotify work through them?  Is it certain type of MP3 players and IPODS.  I believe a few of ours are older ones. 5.  If we have tons of accounts, can I start all accounts on same computer?    Would I set them up by each device we have?6.  Can you run ipod/mp3 through large TV speakers?  or laptop music through big screen tv speakers?7. For the music itself, can you pick what exact songs in playlist?  Can you make lots of playlist per account?  I saw 3,300 songs but can you name the playlist and stay forever?  Sorry for all the questions.  I am trying to figure out if this is even possible or worth doing.  If we have seperate accounts - how much monthly is that?  Is there a deal for that many devices?  Thanks  

    Spotify has 2 different account types. You can see the difference between the two at the bottom of the homepage: http://spotify.com
    1: Each Spotify account can only play on one device at a time. You can have the account logged into as many devices as you want, but you can only play on one device at a time.
    2: With Spotify family, there are several Spotify accounts under one plan. Each account is able to play on one device at a time.
    Check out the family help guide here:
    https://support.spotify.com/learn-more/guides/#!/article/spotify-family
    Also check out this thread for information:
    https://community.spotify.com/t5/Help-Accounts-and-Subscriptions/Spotify-Family-Q-amp-A/td-p/988520
    3: Yes, as stated above
    4: You wouldn't necessarily have to have speakers hooked up to the laptop. If the laptop has speakers or you input headphones, that should work. Spotify doesn't work with MP3 players/iPods. To use Spotify you have to have the Spotify app.
    You can find a list of compatible devices here:
    https://support.spotify.com/learn-more/guides/#!/article/spotify-system-requirements
    7: Yes you can search Spotify and add any song you want to a playlist. And you can also make lots of playlists. Each playlist has a limit of 10,000 songs. The 3,333 limit you saw is for the offline limit on premium accounts. Up to 3,333 songs can be downloaded for offline listening.
    Hopefully this information helps. The family plan can have up to 5 accounts. It might end up being too expensive for what you need. The free plan has ads, but it still might be worth looking into.
     

  • I need help trying to figure out how to get deleted texts back from icloud storage. can someone help me its really important?

    really important. need help.

    If they were on your phone when it was last backed up, restoring the backup to your phone should recover them.

  • Need help trying to figure out unusual browser behavior

    Every couple of days the browser on my balckberry 9300 refuses to connect to the internet. When I type in an adress the loading bar will appear at the bottom but then it will just stop and the browser will go back to the start page.Facebool and bbm still work properly. I can solve the problem via a battery pull but the problem returns again after 2 days or so

    Spotify has 2 different account types. You can see the difference between the two at the bottom of the homepage: http://spotify.com
    1: Each Spotify account can only play on one device at a time. You can have the account logged into as many devices as you want, but you can only play on one device at a time.
    2: With Spotify family, there are several Spotify accounts under one plan. Each account is able to play on one device at a time.
    Check out the family help guide here:
    https://support.spotify.com/learn-more/guides/#!/article/spotify-family
    Also check out this thread for information:
    https://community.spotify.com/t5/Help-Accounts-and-Subscriptions/Spotify-Family-Q-amp-A/td-p/988520
    3: Yes, as stated above
    4: You wouldn't necessarily have to have speakers hooked up to the laptop. If the laptop has speakers or you input headphones, that should work. Spotify doesn't work with MP3 players/iPods. To use Spotify you have to have the Spotify app.
    You can find a list of compatible devices here:
    https://support.spotify.com/learn-more/guides/#!/article/spotify-system-requirements
    7: Yes you can search Spotify and add any song you want to a playlist. And you can also make lots of playlists. Each playlist has a limit of 10,000 songs. The 3,333 limit you saw is for the offline limit on premium accounts. Up to 3,333 songs can be downloaded for offline listening.
    Hopefully this information helps. The family plan can have up to 5 accounts. It might end up being too expensive for what you need. The free plan has ads, but it still might be worth looking into.
     

  • Need help trying to replicate this image

    Hi all,
    I'm not sure if this is the correct place to post, but i'm wondering if I could get suggestions on how to best re-create this image, but in a seamless manner (I had to erase a lot out since it had set pieces in front of it). I need to replicate this in a 6660X1080 banner.
    http://img819.imageshack.us/img819/3235/exampleg.jpg
    Thanks for any help you can be! I've seen instructions on how to make lightning and it seems pretty straight forward, but this looks a little tougher than that, no?

    Thanks for any help you can be! I've seen instructions on how to make lightning and it seems pretty straight forward, but this looks a little tougher than that, no?
    Download the demo of After Effects plus possibly the demos of some plug-ins (Sapphire, Delirium)... Tons of Lightning effects and even though it's meant for animation, nothing stops you from just rendering out a still frame for your banner. Other than that I don't see much in your sample and it could be reasonably well created even using basic Photoshop or Illustrator techniques... Really not sure what you are asking here. Sounds more like you are generalyl rather inexperienced in PS...
    Mylenium

  • Unmountable Boot Volume, need help. trying to fix the problem via lan if posible?

    any information i could recieve from Geek Squad would be appreciated.  i have my computer purchased from best buy that i'm happy with, but my cousin's computer died with the unmountable boot volume error.  i want to use my computer to fix his, or if possible fix his directly from the internet.  any assisstance in this would be nice. thank you.

    Hi AngeNeedsHelp!
    I hope your cousin got the computer fixed. However,
    this Unmountable Boot Volume error is not always fixed by simply reinstalling
    the Operating System (OS). In fact, you may need to back up the drive using an
    external USB Hard Drive Enclosure.  Even
    then the drive may not be readable if there are physical errors/damage, and
    this is nearly impossible to do over the internet since they likely cannot boot
    the computer?  If there is important
    information on the drive I would recommend taking it to a professional such as Geek
    Squad® before attempting anything.  Best
    of luck!
    Matthew|Community Advocate | Best Buy® Corporate
    Visit our Channel on
     Private Message

  • Bet you cant figure this one out...

    Card: Sound Blaster Li've 5.Video: GeForce 6600GT
    Motherboard: K7N2 Delta MSI (tried it on Asus A8... Motherboard aswell)
    Processor: AMD 3200+ XP
    Ram: 52mb ddr 3200
    Problem:
    This Sound Blaster Card freezes with a looping sound on every game I try playing on my PC. Figured it was the Sound Blaster card when I took it out the computer ran fine with the integrated sound card. Put the SB back in and updated every driver, BIOS, video driver, IRQ settings, check the voltage, EVERYTHING... Yet still freezes.
    Bought another Sound Card Audigy 2 value... Froze with no sound, and have to reboot. I am pretty frustrated now that I have switched the power supply, motherboard, processor, RAM just to figure this problem out.
    Note: The computer doesnt restart when I update stuff with the card in the PC, when the card is out of it, the computer restarts without me turning it off and back on again.
    If you know what is causing this... I will love you forever.
    Thanks

    I have the exact same problem. However, the problem didn't pop up until I upgraded Windows XP to service pack 2. I've seen others bring up this issue on a few boards, hopefully someone will shine some light on this issue instead of pointing fingers. Personally, I've done everything I know to do besides downgrading to service pack , but my PC crashing when playing games is not worth reverting back to SP (although I'm sure it is to some). Anyway, I don't know if you have the same OS & service pack, but thought I'd share just the same.

  • I have updated my phone to 4.3.3 and I was told there would be more bells and whistles. I haven't found more texting sounds. Have I updated my phone wrong or just not completed it all the way? Please help me. Still trying to figure this iphone 3G out.

    I have updated my phone to 4.3.3 and I was told there would be more bells and whistles. I haven't found more texting sounds. Have I updated my phone wrong or just not completed it all the way? Please help me. Still trying to figure this iphone 3G out.

    You have the iPhone 3GS, not the 3G. The last update to support the iPhone 3G is 4.2.1.
    iOS 4.3.3 includes bug fixes etc. There is nothing really special about this update that wasn't introduced in iOS 4.3. iOS 5 is the one to wait for - it will be released in the Autumn/Fall and includes over '200' new features/improvements.
    The additional text tines and ringtones were an iPhone 4-only feature.

  • Need urgent help. I have been trying to resolve this problem to no avail. I am able to preview my sp

    Need urgent help. I have been trying to resolve this problem to no avail. I am able to preview my sprymenu on my local browsers opera, google crome, and IE but when it is uploaded, the sprymenu squashes to the left hand side.

    Please get your checkbook ready. (Only kidding.)
    Have you ever done a hard factory reset of your Airport Express base? If not, then try it. Push down the reset button with a pen, then keep it depressed as you plug AX into the wall and keep holding it down until the green light blinks 4 times and then turns amber. Then let go. Unplug your broadband modem for a couple of minutes and shut down your Mac. First restart the modem, then the Mac. Use Airport Setup Assistant to set up a new network from scratch.
    In System Prefs > Network > Show > Network Port Configurations drop n drag Airport to the top of the list and deselect all port configurations that you do not use.
    That's a start.

  • I keep getting the message"an error occurred while trying to access the service".  does anyone know what i need to do to resolve this problem.  I am trying to convert apdf file for msword?

    I keep getting the message"an error occurred while trying to access the service".  does anyone know what i need to do to resolve this problem.  I am trying to convert a PDF file for ms word?

    Adobe Reader is free; but you may have paid for the ExportPDF service.
    Contact Adobe Customer Care and click on the Still need help? button to chat with an agent.
    [topic moved to ExportPDF forum]

Maybe you are looking for

  • How to Extract data from Cluster table  and transperant table

    Hello BW Experts , I want to extract the data from cluster table BSEG and a transperant table BKPF . The primary fields are BELNR , GJHAR and BUKRS. the fields of table BKPF to extarct is BUDAT and fields of BSEG table is HKONT , BSCHL , ZUONR and PO

  • What are the XFA properties for a drop-down list?

    I am having trouble distinguishing between the "Text" and "Value" for a drop down list. I have a data drop-down list that is being populated by a database at runtime. I am using the "addItem" event while looping though the recordset. The "addItem" ev

  • DVI-D - HDMI switcher - DVI-D

    Hey friends, I've got a fairly convoluted and confusing HDMI situation. As DVI matrix switchers are so expensive, I decided to get a HDMI switcher and HDMI to DVI cables. I have two Mac Pro towers, each with two DVI outputs, and two 24" Cinema HD dis

  • After editing a raw picture the brightness changes!??!

    Hi All, When i initially open a RAW file it gives my an initial edit screen where i can change white balance, exposure, etc.    So i get the photo exactly how i like it. When i click the 'open image' button i am taken into the main screen of elements

  • Requried Help in creating function

    Hi All, i need one help in creating function my input parameters for that function will be 1 or 1,2 or 1,2,3 my output should be If i pass as 1 as input parameter it should return 1 If i pass 1,2 as input parameter it should return 1,2 in different r