• Post Reply Bookmark Topic Watch Topic
  • New Topic

login page  RSS feed

 
shreta singhal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
i made a login page and i am facing problem in its connectivity with the database (named users).
when i enter the email add. and password i should move on to home page but every time the login page displays....
please help me in dis...
the code for login.jsp is:


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:if test="${param.txtlogin ne null}">
<sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbcdbc:dsn1" var="con" scope="session" />

<sql:query dataSource="${con}" var="rs">
select * from users where email_id=? and password=?
<sql:param value="${param.txtlogin}"/>
<sql:param value="${param.txtpassword}"/>
</sql:query>
<c:if test="${rs.rowCount eq 1}">
<c:set var="name" scope="session" value="${rs.rows[0].name}"/>
<c:set var="is valid" scope="session" value="true"/>
<c:set var="email" scope="session" value="${param.txtlogin}"/>
<jsp:forward page="home.jsp"/>
</c:if>

</c:if>



<html>
<head>
<title>Login Page</title>
</head>
<body >


<form method=post >
login: <input type=text name="txtlogin" value="" size="30" /><br>
password:<input type=password name="txtpassword" value="" size="30" /><br>
<input type=submit value="login"/>
<a >register now</a>
</form>
</body>
</html>
 
Ramses Butarbutar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shreta singhal wrote:hi ,
i made a login page and i am facing problem in its connectivity with the database (named users).
when i enter the email add. and password i should move on to home page but every time the login page displays....
please help me in dis...
the code for login.jsp is:


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:if test="${param.txtlogin ne null}">
<sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbcdbc:dsn1" var="con" scope="session" />

<sql:query dataSource="${con}" var="rs">
select * from users where email_id=? and password=?
<sql:param value="${param.txtlogin}"/>
<sql:param value="${param.txtpassword}"/>
</sql:query>
<c:if test="${rs.rowCount eq 1}">
<c:set var="name" scope="session" value="${rs.rows[0].name}"/>
<c:set var="is valid" scope="session" value="true"/>
<c:set var="email" scope="session" value="${param.txtlogin}"/>
<jsp:forward page="home.jsp"/>
</c:if>

</c:if>



<html>
<head>
<title>Login Page</title>
</head>
<body >


<form method=post >
login: <input type=text name="txtlogin" value="" size="30" /><br>
password:<input type=password name="txtpassword" value="" size="30" /><br>
<input type=submit value="login"/>
<a >register now</a>
</form>
</body>
</html>


which one of your code show action of your login button when you click/press it??
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should try to move Database access code to some other class (usually DAO class). And please use code tags when posting code. Welcome to Javaranch
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!