This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Login and Sessions

 
Christin Guhr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody
I have huge problems to write a jsp page for a login and also compare password and username with my mySQL Database.
please help my.
I tried it for a lot of days but there is no result.
a registrationformular already exists and this one run.but not the login.
I need help!!!
 
Christin Guhr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
so far.Login runs but I already not know how to implements Cookies and sessions.
please help.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what part of your application is not working, or do you need help with? What will you be using to manage sessions cookies or httpSession. You might do youself a favour by getting a book to read up on these concepts.
 
Christin Guhr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the loginfunction run.
but no cookie or sessionhandling.
I have 2 JSP Books but they are not very well and the chapters about sessions and Cookies are very bad and short with examples which not run.
So can me sombody tell how I can manage this problem. or is there someone who can recomment my a good JSP-site, because such books are very expensive.
thanks
this my login.jsp
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<HTML>
<HEAD><TITLE>Login</TITLE>
<link rel="stylesheet" href="gip.css" type="text/css">
</HEAD>
<BODY>
<FORM name="form1" method="post" action="LoginHandler.jsp">
<TABLE border=1 cellpadding=0 cellspacing=0>
<TR>
<TD>Username: </TD>
<TD>
<INPUT type="text" name="UserIn" maxlength="10">
</TD>
</TR>
<BR>
<TR>
<TD>Passwort: </TD>
<TD>
<INPUT type="password" name="PasswortIn" maxlength="20">
</TD>
</TR>
<BR>
</TABLE>
<INPUT type="submit" name="Submit" value="Login">
</FORM>
<P>
</BODY>
</HTML>
and this is the LoginHandler.jsp
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%
Connection con;
Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql:///vlu";
con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();

String user;
String passwort;
user=request.getParameter("UserIn");
passwort=request.getParameter("PasswortIn");
boolean entrance = false;
ResultSet rs = stmt.executeQuery("SELECT * FROM user WHERE USER='"+user+"' AND PASSWORT='"+passwort+"'");
while(rs.next()){
String dbUser = rs.getString("USER");
String dbPassword= rs.getString("PASSWORT");
if ((user.equals(dbUser)) && (passwort.equals(dbPassword))){
entrance=true;
}
}
if (entrance==true){

%>
<jsp:forward page="geklappt.html"/>

<%
}
else { %>


<jsp:forward page="error.html"/>
<% }%>
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Christin",
Thanks for participating here at the Ranch. However, the name you are using does not comply with the naming convention described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name (not fictitious monikers). Please log in with a new name which meets the requirements.
Thanks.
Sean
 
Christin Guhr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic