Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2005, 09:47 AM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default prob.. in login page

hi..all of u....

i have made a login page in html page...in which two text field there..named username and password...

i want to do the stuff that if the user enter correct username and password..then it displays a pop up window mentioning that u have successfully enetered and it then directly went into the mypage.jsp page...(targeted page)

and if users enter wrong entry then it displays error in another page..

plz... do the needful for me....i am not getting any thing....

my code is as follow:


try
{

String Username = request.getParameter("msno");
String Password = request.getParameter("pass");

sql = conn.prepareStatement("SELECT * FROM login_mast WHERE name = '" + Username + "' and password='"+Password+"' ");

results = sql.executeQuery();

while(results.next())
            {

String Dbname = results.getString("name");
String Dbpassword = results.getString("password");


out.println("<TABLE >");
out.println("<TR>");
out.println("<TD><strong>Username</strong>:</TD>");
out.println("<TD><strong>Password</strong>:</TD></TR>");

out.println("<tr><td> <INPUT TYPE='TEXT' size='5' value='" + Dbname + "' readonly </td>");
out.println("<td> <INPUT TYPE='TEXT' size='5' value='" + Dbpassword + "' readonly </td></tr>");
}
}
catch (SQLException s)



 
Old February 24th, 2005, 05:08 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I do is get the password where username = username.
Then use an 'if' statement to test the password

if(Password.equals(Dbpassword));
//you cannot use = to compare strings, use .equals
{
  //open mypage.jsp
}
else
{
  //open you failed to login page
}






 
Old February 24th, 2005, 05:17 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, error in code for if statement, do not use ; at the end, use:

if(Password.equals(Dbpassword))









Similar Threads
Thread Thread Starter Forum Replies Last Post
maitenance page prob dhara_adh .NET Framework 1.x 0 May 9th, 2007 01:41 AM
Mobile refresh page Prob avrail ASP.NET 2.0 Professional 0 January 25th, 2007 12:28 PM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM
Rollover prob when Flash inserted in XHTML page socoolbrewster HTML Code Clinic 0 September 12th, 2004 12:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.