Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2009, 02:32 AM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-14-2009, 04:30 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
JSP is much better than Applet for your requirement. What's the point of use Applet in your project?

JSP Tutorial - Java Server Pages Tutorials
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-14-2009, 12:46 PM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
Default
Been told we must use a applet and servlet
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-14-2009, 07:06 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-14-2009, 07:11 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Here is a simple example. Just look at it. May be it can helpful to you.

JSP Login Page
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-15-2009, 03:01 AM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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 .
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-15-2009, 06:31 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Ok, what you have tried(the query) to deal with the user name and the password?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-15-2009, 11:24 AM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 05-15-2009, 01:17 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 05-15-2009, 01:17 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
I think it's much better to read the following page yourself.

Understanding Login Authentication
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 05-16-2009, 01:28 AM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 05-16-2009, 01:51 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 05-16-2009, 02:26 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 05-16-2009, 12:15 PM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 05-16-2009, 08:22 PM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 05-16-2009, 09:59 PM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
Default
what do you mean by hashed?
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 05-16-2009, 10:11 PM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
Cryptographic hash function as used in digest authentication and others.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 05-16-2009, 10:20 PM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
Default
oh rite, ok, i really want to keep this simple, i dont really need anything like that in there
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 05-17-2009, 04:28 AM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #20 (permalink)  
Old 05-17-2009, 11:02 AM
Member
 
Join Date: Feb 2009
Posts: 27
Rep Power: 0
neosnokia is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +2. The time now is 04:36 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org