Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default Developing a logon screen

    Hey, i want to create a java login applet, which can be embedded in to a web page and send information such as user name and password to a servelet to be validated by a database.

    Are there any tutorials around showing this? I have had a look on the net and i cant find anything. I can create a simple login which has the user name and password embedded in to the code but im totally lost when creating a login which communicates wiht a servlet then on to a database.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    Been told we must use a applet and servlet

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I think it's better to read more about JSP/Servlet by you before doing this.

    JSP are actually Servlet. In backend JSP are compiled into Servlet. Best way is, you can keep member details in a database and validate in a Servlet.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    Thx, i have the applet passing a string (username and password) to the servlet, and i have a seperate servlet which can read from a database, (for simplicity im using access database) however i cant think how to query a username or password against a database . :(

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  8. #8
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    well what i have noticed is when you send the data, user name and password, it comes through as one string, so im trying to split that up first

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Java Code:
     <body>
            <%
    String url = "jdbc:odbc:userDSN";
    String username="";
    String password="";
    Connection conn=null;
    String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
    String usernm = username; // Validating user name
    String passwrd = password; // Validating password
        
    try{
        Class.forName(classPath);
        conn = DriverManager.getConnection(url,username,password);
        }catch(Exception exc){
            out.println(exc.toString());
        }
    %>
    <%
        Statement stm=null;
        ResultSet rst=null;
        
        stm= conn.createStatement();
        String query= "SELECT userID, password FROM user WHERE userID =" +usernm;
        
        rst = stm.executeQuery(query);
    %>
    
    <%= rst.getString("userID") %>
    <%= rst.getString("password") %>
    
    
    
    <% 
    if (usernm.equals(userID) && passwrd.equals(password)) { %>
    
    <jsp:forward page = "index.jsp"></jsp:forward>
    
    <% } else { %>
    
    <jsp:forward page = "login_handle.jsp"></jsp:forward>
    
    
    <% }
                rst.close();
                stm.close();
                conn.close();
    %> 
        </body>
    Here is a simple code I've with me on one of my application, just a part of it. I don't know how far it's clear to you. Have a look at it and try to understand what's going on there.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  11. #11
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    Cool, ive managed to split the string up in to user name and password, now all i need is to connect to an access database and compare with the results which are in that

  12. #12
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    It's a good idea to only store and transmit secure hashes of passwords, rather than the passwords themselves.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I agreed with you OD. I just trying to point-out in my code just the model of login page. Actually at the very first step, he/she don't have an idea what the technology need to use and lot more to understand.

    That's why I point the hard corded credentials there.

  14. #14
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    dont worry about password security i just need once the variables have been sent to connect to a database and compare with what is in the database. If they pass that test, then i can gain access and go in

  15. #15
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    But if they're not hashed, so can everyone else.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  16. #16
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    what do you mean by hashed?

  17. #17
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  18. #18
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    oh rite, ok, i really want to keep this simple, i dont really need anything like that in there

  19. #19
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Just as long as you know that a system where plaintext passwords are transmitted and stored is in no way secure.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  20. #20
    neosnokia is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    yep :-) maybe when i get it working i can look in to that, but for now i need to get it logging in first.

Page 1 of 2 12 LastLast

Similar Threads

  1. Blank Screen while navigating from one screen to another
    By mohana.krishna in forum Java Servlet
    Replies: 0
    Last Post: 03-03-2009, 05:03 PM
  2. developing a password vault
    By ramesh.8189 in forum Threads and Synchronization
    Replies: 6
    Last Post: 02-03-2009, 06:32 AM
  3. developing a GUI for solaris 10
    By DuceDuceExplorer in forum NetBeans
    Replies: 5
    Last Post: 08-05-2008, 06:00 AM
  4. help in email developing
    By reached in forum New To Java
    Replies: 0
    Last Post: 12-09-2007, 07:55 PM
  5. Developing for Mac
    By jmds in forum NetBeans
    Replies: 0
    Last Post: 11-25-2007, 07:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •