• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 4109
72
Hibernate Fedora Chrome
  • 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
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic