Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

login page

 
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="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
  • 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: 4107
72
Hibernate Fedora Chrome
  • 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
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic