jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes Login and Sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Login and Sessions" Watch "Login and Sessions" New topic
Author

Login and Sessions

Christin Guhr
Greenhorn

Joined: Jun 13, 2002
Posts: 4
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

Joined: Jun 13, 2002
Posts: 4
ok.
so far.Login runs but I already not know how to implements Cookies and sessions.
please help.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Christin Guhr
Greenhorn

Joined: Jun 13, 2002
Posts: 4
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

Joined: Nov 07, 2000
Posts: 621
"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

Joined: Jun 13, 2002
Posts: 4
sorry
 
 
subject: Login and Sessions
 
Similar Threads
activate login button
oracle JDBC driver download
HELP!!!
login twice
problem with login to the server