• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

login page

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="jdbc:odbc: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>
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="jdbc:odbc: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??
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic