Creating txt file to store input username and password

Hi everyone,
I'm new to java, and have been having a hard time with this code.
My goal is to allow the user to enter in their username and password which should be concatentated as a string and stored into a text file. I am unable to link the two input fields as one string of characters. I know i'm approaching this wrong, but am uncertain of where i need to begin.
Code is as follows:
/*Purpose: To allow the user to input their desired username and password
*which will be stored in a data structure for later use; for instance when
*the user wants to use the application again their username and password
*will be assigned the same/linking locations, hence they will be validated.
*inputed username and password should be stored in a text field for later use
*of validating login possbily using a search method
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.lang.String.*;
public class TextFieldTest1 extends JFrame {
private JTextField userName;
private JPasswordField password;
private JLabel textFieldLabel, passwordFieldLabel;
// set up GUI
public TextFieldTest1()
super( "Please Login to AutoSync" );
Container container = getContentPane();
container.setLayout( new FlowLayout() );
// construct textfield with default sizing
userName = new JTextField( 10 );
//creating textfield label
textFieldLabel = new JLabel("Username");
container.add(textFieldLabel);
container.add( userName);
// construct passwordfield with default text
password = new JPasswordField( "Hidden text" );
passwordFieldLabel = new JLabel("Password");
container.add(passwordFieldLabel);
container.add( password );
// register event handlers
TextFieldHandler handler = new TextFieldHandler();
userName.addActionListener( handler );
password.addActionListener( handler );
setSize( 325, 100 );
setVisible( true );
}// end constructor TextFieldTest
//ADDED TO CREATE TEXT FILE OF USER INPUTS
//Code actually doesn't work, but i was thinking that where i have brooke
//if i should create another actionlistner to concatenate the userName and password nputs into one field, perhaps a login button which hold both those arrays then i can do writer.write("combinedfields")      
public static void main( String args[] )throws IOException
TextFieldTest1 application = new TextFieldTest1();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
// private inner class for event handling
private class TextFieldHandler implements ActionListener {
     String fileName = "SENIOR.txt" ;
FileWriter writer = new FileWriter( fileName );
writer.write(userName.addActionListener);
writer.write(password.addActionListener);
writer.close();
// process textfield events
public void actionPerformed( ActionEvent event )
String string = "";
// user pressed Enter in JTextField textField1
if ( event.getSource() == userName )
string = "userName: " + event.getActionCommand();
// user pressed Enter in JTextField passwordField
else if ( event.getSource() == password ) {
string = "password: " +
new String( password.getPassword() );
JOptionPane.showMessageDialog( null, string );
} // end method actionPerformed
} // end private inner class TextFieldHandler
//private class users to link username/password input with Array locations
private class Users{
          public String userCheck[] = new String[10];     
          public String passCheck[] = new String[10];     
private boolean validateUser(String usr, String pwd)throws IOException {
     for (int i = 0; i < userCheck.length; i++)
if (userCheck.equals(usr) && passCheck[i].equals(pwd))
return true;
               return false;
     }     //end method validateUser
}     //end class users
} // end class TextFieldTest}

Double Post
http://forum.java.sun.com/thread.jspa?threadID=631685&tstart=0

Similar Messages

  • Firefox won't store my usernames and passwords

    '''bold text'''hi there,
    firefox won't remember my usernames and passwords...
    need help.

    Do you mean names and passwords in the Password Manager or do you mean that you are no longer logged on to (remembered by) websites after closing and restarting Firefox?<br />
    If the latter happens then you have a problem with cookies that are not kept or the file that stores the cookies is corrupted.<br />
    Such details are stored in a cookie.<br />
    * Websites remembering you and automatically log you in is stored in a cookie.
    * You must allow that cookie (Tools > Options > Privacy > Cookies: Exceptions), especially for secure websites and if you let cookies expire when Firefox closes
    * Make sure that you do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences"
    *http://kb.mozillazine.org/Password_Manager
    *http://kb.mozillazine.org/User_name_and_password_not_remembered

  • Web reports prompts me to input username and password in bw

    Hi all.
      When I access web reports from bw.
      It will open a IE, then go to one url ( which is located in ITS ), and IE prompts me to input a valid username and password.
      Its very strange, because I have already logged on that BW.
      Is it possible to avoid this prompt ?

    Gu,
    Can you give us the URLs that you are using , is it that the URLs are different ?
    The URL is usually
    http://<yourserver>:port/sap......
    assuming that the URLs are
    URL 1 ( which is currently opening in IE )
    http://<yourserver1>:port/sap......
    URL 2 ( for which the login is being asked for)
    http://<yourserver2>:port/sap......
    if yourserver1 and yourserver2 are different , then a logon is required.
    Hope it helps..
    Arun
    Assign points if useful

  • Inputing Username and Password

    Does anybody in this forum know where I can input the username and password for my domain (domain1).
    I try to start the Default Server but I get a message saying I have an incorrect username or password.
    I would just like to know where I can input these two things ( I remember what I set them to, I just don't know where to input them).
    Thank you.

    Hi,
    You can use an Anonymous login as explained here:
    http://help.sap.com/saphelp_sm32/helpdata/en/cd/1aad4abcb98c4597f9e395a6b62f43/content.htm
    Or can also use Single Sign-On  from windows using SPNego:
    http://wiki.sdn.sap.com/wiki/display/EP/SingleSignOntotheJ2EEEnginefromWindows
    Thanks and Regards,
    Shyam.

  • How to create a login funtion with different usernames and password to iweb

    Hi,
    Im looking for hours for a solution to create / add a function to iweb which allows users to login to a member area with their own user names and passwords.
    Is there a simple way to realize this? So far I know there has to be a file with all the user name --> password combinations, can I add such a file to my idisk and then get it working with my iweb site?
    Is such an idea in general possible with iweb?
    Thanks for your help!
    Message was edited by: Macusar08

    One possibility may be to use the free drop.io to privately share links to your iWeb site pages and/or iDisk files. +"Each 'drop' (...) can be password-protected and set to expire after a period of time, so you can share exactly what you want with whom you want for as long as you want."+ (source).
    Note that drop.io doesn't require an email address, name or personal registration to set up a "drop". And you can place data in either one drop or multiple drops. Each drop comes with 100mb of storage for free and you can have as many drops as you want without signing up.

  • On older Mac G4, trouble loading page, just white page comes up after inputting username and password. Only seems to happen on one account.?

    older G4 trouble loading page. Trying to open bank account and when it takes the passwords and goes to page only white page comes up. Not banking prob. not prob with other inernet locals, just this one page.?

    Hi Brad,
    Is this in a Browser, if so which one?
    TenFourFox is the most up to date browser for our PPCs, they even have G4 & G5 optimized versions...
    http://www.floodgap.com/software/tenfourfox/
    SeaMonkey seems pretty fast also, with many options...
    http://www.seamonkey-project.org/
    http://www.seamonkey-project.org/releases/

  • Auto input Default Username and Password

    Hi David ,
    When I am connecting AWM 11.2.0.2A version with the AWM database and it is prompting for username and password for the target AWM schema . Can we autoinput and take the username and password defined somewhere so that once the database has been clicked it will logged in without prompting for username and password.
    Many thanks,
    Debashis

    No, there is no facility to store the username and password between sessions. Oracle's security coding policies are pretty strict on this kind of thing.

  • Remembering username and password in an unsigned applet...

    Does anyone have any ideas how my unsigned applet could remember the username and password entered by a user?
    Previously, I was using a signed applet so could store the username and password in a persistent text file, but now I need to provide an unsigned applet solution - so does anyone have any suggestions for how my applet could remember and recall the username and password?
    Many thanks,
    James

    Take global variable and store pass and user name in it .
    or getParameter() and setParameter() u can set parameter define in html file as global . so multiple applet in same webpage can access this pass and user name

  • How do you make connection password use single username and password in P/S

    Hi
    I have installed OBIEE as a standalone on a Windows 2003 server using OC4J and AUTHENTICATION_TYPE = BYPASS_NQS.
    I have created a repository using an ODBC connection to a Netezza database. The implementation we have is that we use a single username and password (readonly) to the database.
    I have created the physical, business and presentation layers and the repository is consistent and loadas up into the Presentation Server.
    When I login into presentation server as say "Administrator", the PS passes the username/password of "Administrator" instead of the username and password setup in the connection pool.
    The error is;
    -------------------- Query Status: Query Failed: [nQSError: 16001] ODBC error state: HY000 code: 108 message: Password authentication failed for user 'ADMINISTRATOR'.
    When I create a user with the same username and password as the one used in the connection pool, the requests work. Although thisd lets me work at the moment, it is not a viable solution going forward.
    Please can you advise what I need to setup for this to work correctly for me ie., make PS substitute the correct username password when connecting to the ODBC defined in the connection pool?
    Thanks in advance.
    Danish.

    Apologies if I've misunderstood, but are you trying to implement anything than standard practise, namely:
    1) Using the OBIEE security model to authenticate and log in (i.e. when you log in to Answers you are entering a username as defined in the RPD)
    2) Using a fixed username & password as defined on the database to authenticate & authorise when you read data for your reports?
    If you use BYPASS_NQS then BI Server will take your login details when you login to Answers (Presentation Server) and pass them through to the database and see if they're valid. This is what's happening when you got the error that you initially posted. With setting at BYPASS_NQS try logging into Answers with the database username&password, I bet it will work.
    If you use NQS (the default) then it checks the Answers login against users defined in the RPD, so the reason you couldn't login when you changed it to NQS is that the user/pw you logged in with didn't match what's defined in the RPD.
    Try this:
    1. Create a new user & pw in the RPD, for argument's sake call it TestRPDUser with the same pw
    2. Set authentication to NQS and restart you BI Server
    3. Log in to Answers as TestRPDUser - does it work?

  • Passing portal username and password as parameters in URL iview.

    Hi Gurus,
    i Have Created URL iView. i want to send the Username and password of portal to this url ,
    how can i access the portal username and password.
    Note: tried with j_user and j_password
    Regards
    K Naveen Kishore

    Hi,
    Jigar Oza
    Thanks for u r reply, i have tried with application integrator but there is a problem with usermapping.
    now what i have done is created HTTP System based on this system created URL iView,in application parameters username and password as MappedUser and MappedPassword every thing is working fine. user  logged in automatically when he logged into portal.
    there are tabs ,links in application .when i click on tabs or links it is assking to enter username and password of the application.
    did i do any thing wrong in creating HTTP system or URL iView,
    what are the necessary properties should be given.
    replys are highly appreciated.
    Regards
    K Naveen Kishore

  • Checkin for a specific username and password

    i have an html page where i enter username and password..now if i want that for a specific username and password only the next page say next.html is displayed otherwise the same page is diaplayed sayin that the usrename and password is to be reenterd...how can i do this servlets..also do tell me where to store the username and password

    I am sorry, I lost some code in cut and pasting it
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;   
    public class LoginServlet extends HttpServlet{
            private Connection con;
            private PreparedStatement pstmt;
            private Statement stmt;
            private ResultSet rs;
            private String pass = "";
            private String login,password,done;
            private HttpSession session;
            public void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException{
                    login = ""+request.getParameter("login");
                    password = ""+request.getParameter("password");
                    done = ""+request.getParameter("done");
                    session = request.getSession(true);
                    PrintWriter out = response.getWriter();
                    try{
                            Class.forName("oracle.jdbc.driver.OracleDriver");
                    }catch(Exception e){
                            out.println(e.getMessage());
                    try{
                            con = DriverManager.getConnection("jdbc:oracle:thin:scott/[email protected]:1521:csapw");
                            if(!(password.equals("")&&login.equals(""))){
                                    pstmt = con.prepareStatement("select password from logon where login = ?");
                                    pstmt.setString(1,login);
                                    rs = pstmt.executeQuery();
                                                         pass = "";
                                    while(rs.next()){
                                            pass = rs.getString(1);
                                    if(pass.equals(password)){
                                            session.setAttribute("login",login);
                                            if(done.equals("null")){
                                                    done = "";
                                                    pass = "";
                                                    response.sendRedirect("/ksenji/quiz2/shoponline.jsp");
                                            }else{
                                                    response.sendRedirect(done.substring(5));
                                    else{
                                            response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                            else{
                                    response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                    }catch(SQLException ex){
                            out.println(ex.getMessage());
               

  • ICloud Keychain: username and password form on separate pages

    Hello,
    I really like using iCloud Keychain. I am, however, unable to store a username and password for two web sites. Both sites use a separate page for username and password. It appears that Safari does not see the web form on each page. I have attempted to manually add the usernames and passwords to Keychain Access on my iMac, however, it had no effect. Note that I have also enabled the Safari options "Autofill usernames and passwords" and "Allow Autofill even for websites that request passwords not be saved."
    Has anyone experienced Safari not showing a prompt to save usernames/passwords and found a solution?
    Thanks,
    Bryan

    II'd rather not disclose the financial institutions i do business with, but my bank and two mutual fund websites use separate pages for username and password. I chec around, and if you go to the Bank of America website, they do it as well. Keychain does not work on any of the three sites I use.
    Thanks for your help.

  • Passing the username and password via report link

    How can I pass the username and password via the reprt link?
    thanks all.
    Ahmad Esbita

    Hi,
    Jigar Oza
    Thanks for u r reply, i have tried with application integrator but there is a problem with usermapping.
    now what i have done is created HTTP System based on this system created URL iView,in application parameters username and password as MappedUser and MappedPassword every thing is working fine. user  logged in automatically when he logged into portal.
    there are tabs ,links in application .when i click on tabs or links it is assking to enter username and password of the application.
    did i do any thing wrong in creating HTTP system or URL iView,
    what are the necessary properties should be given.
    replys are highly appreciated.
    Regards
    K Naveen Kishore

  • 802.1x without storing username and password

    I have a couple all-Mac schools that would like to begin integrating iPod touch and iPad in classroom activities.
    Our wireless network is managed at the district level and it offers to ways to log into the Internet – one is a popup window with a Java applet, and the other is 802.1x.
    Obviously the Java applet does not work on iPhone OS and I'm sure it never will. 802.1x works well with one caveat: It stores the username and password so whichever student uses it next will remain logged in as the previous student.
    Is there any way that the iPods can be forced to prompt for the 802.1x username and password each time they rejoin the network? Any other ideas?
    And before anyone asks, we have submitted requests to make the wireless network friendlier to non-traditional computing (ie. devices that are not standard PCs and Macs), but it doesn't look as if that's happening any time soon.
    Thanks!

    I don't store them, if it is a user and password. If the user entered them I keep them in instance variables. If you only have one user for the database (which is not the best IMHO) you should decrypt it in the code. The crypted can be stored whereever, but still not good.

  • Smb links username and password

    I want to be able to create a smb link, I am using safari to create them now, that pulls the username and password from the system.
    I was hoping I could use the shortname to accomplish this, but am unsure what exactly the context is.
    this is what I am doing
    smb://user:pass@server/share
    I want to know how to pull that so I don't have to hard code the link so I can give it to all my users.

    Is there a setting allowing for "Clear Text Logins" on your Windows server?
    I must admit (IMO) with this many Mac's having to access a Windows server, you would be doing yourself an enormous favor by using a product like ExtremeZ-IP. It's likely you're going to be having all kinds of strange issues reading the data via SMB.
    Please consider this very carefully working with a Windows Server:
    http://www.grouplogic.com/products/extreme/SMBSolutions.cfm
    I'd like to see you succeed with the least amount of Administration.

Maybe you are looking for

  • Adding NSSF+Pension Fund Storing in other Wage type.

    Hi Experts, I have requirement with client. I need to add two wage type for EE contribution and store in other Wage Type. Find below the details: 1. 0507: NSSF Employee contribution 2. 0630: Pension Employee Contribution 5% 3. 0631: Pension Employee

  • Accessing ODBC Database through CF and Dreamweaver

    Ok, so I have a db connection set up under the ODBC administrator.  It is using Oracle 8 or 9 (can't remember) but it is what I use so that I can connect to it through my company's Accounting Software.  I want to query it using Dreamweaver and make a

  • Which storage device to buy?

    I would greatly appreciate assistance in choosing the best storage product for me. ** I own a iMac with a 2TB hard drive ** I am looking for more storage space plus backup ** I am presently using 3 external drives - 2TB Airport Time Capsule, 2TB WD d

  • Flash CS5 - Embedded Link Character Limit

    I don't know if anyone else has encountered this, but I had a site that built in CS4, and I had to make some updates. Month and a half later I get a frantic call from my client saying a bunch of the links on the site are broken. Puzzled I opened the

  • Connectivity Question *PLEASE HELP!*

    Hi all, PROBLEM I have an Xbox 360 in my bedroom, which is on the 2nd floor of my house. My FiOS Actiontec Router is on the first floor of my house. My Xbox 360 does not connect/recognize the router, which leaves me unable to connect to Xbox Live and