login in jsp

login in jsp

i need code for login which is verify the registeration form username and password field,if it correct user enter the next and otherwise show the failed message.

View Answers

February 22, 2011 at 12:36 PM

JSP Login Form

1)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>
<%String msg=request.getParameter("msg");
if(msg!=null){
    %>
<label><font color="red"><%=msg%></font></label> 
<%
}
    %>

2)check.jsp:

<%@page import="java.sql.*"%>

<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
            out.println("welcome "+user);
          }
          else
          {
                       response.sendRedirect("login.jsp?msg=Invalid Username or Password");
          }
%>









Related Tutorials/Questions & Answers:
JSP LOGIN
JSP LOGIN  sir....i have two user types usercategory and user and both user have userid and password in two different table and now i am making login page for which i have to retrieve usertype,userid and password from two
login in jsp
and otherwise show the failed message.   JSP Login Form 1)login.jsp: <html>...login in jsp  i need code for login which is verify the registeration...(); ResultSet rs=st.executeQuery("select * from login where username='"+user
Advertisements
JSP - Login
JSP - Login  how to disabled back button of the browser when user successfully logged
jsp login page
jsp login page  hi tell me how to create a login page using jsp and servlet and not using bean... please tell how to create a database in sql server... please tell with code
login authentication in jsp and servlet
login authentication in jsp and servlet  Hi, I am beginner in web... to make login authentication in jsp and servlet? Thanks   Hi, I to make login authentication in jsp and servlet you have to write code for database
Jsp login with Cookie - JSP-Servlet
Jsp login with Cookie  9) Create an HTML page containing the following features a. Create a login JSP page with username , password and submit... cookies to store username and password. c. Open login JSP page on a new browser
JSP LOGIN Page
JSP LOGIN Page  sir....i have two user types usercategory and user and both user have userid and password in two different table and now i am making login page for which i have to retrieve usertype,userid and password from two
jsp login page
jsp login page  Hi All, can any one tell me how to create Login page using JSP and Beans. A simple log in page. Please reply ASAP.ADS...:ADS_TO_REPLACE_2 JSP Login Using Bean Thanks   Hi,ADS_TO_REPLACE_3
login form - JSP-Servlet
login form  Q no.1:- Creat a login form in servlets?  Hi...*; import javax.servlet.http.*; public class Login extends HttpServlet...(); pw.println(""); pw.println("Login"); pw.println(""); pw.println
Login & Registration - JSP-Servlet
Login & Registration  Pls tell how can create login and registration step by step in servlet. how can show user data in servlet and how can add...://www.roseindia.net/jsp/loginbean.shtml Hope that the above links will be helpful
jsp/servlet login program
jsp/servlet login program  <%@ page language="Java" import...;/TITLE></HEAD> <BODY> <jsp:useBean id="db" scope="request" class="logbean.LoginBean" > <jsp:setProperty name="db" property="userName" value
JSP Login Page Question
JSP Login Page Question  hey..i have a login page where different users first registered and then after they can login. my question is how a user can see only his data after login where different users data are stored
Login Authentication and session in JSP - JSP-Servlet
Login Authentication and session in JSP  Hi, I am creating an small application in JSP,in which i need to check user authentication and session on each JSP page.Also how do i make logout page. Can you help me
Can Login on Fedora, cannot on Windows- JSP/Servlet for login
Can Login on Fedora, cannot on Windows- JSP/Servlet for login  I am using JSP and Servlet to perform login. When I host the website and test it works...; Please visit the following link: JSP Login Authentication
jsp/servlet login program - JSP-Servlet
jsp/servlet login program  hello sir, well i have a problem with some code(loginbean.jsp),which i actually got from ur site: i am trying to create a login program where a new user will be registered and his/her details stored
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand
login page with mysql using jsp
login page with mysql using jsp  pls i need a sample of login page to check username and password in mysql database. thanks
login
login  How to create login page in jsp
login
login  How to create login page in jsp
jsp code for storing login and logout time to an account
jsp code for storing login and logout time to an account  I need simple jsp code for extracting and storing login and logout time in a database table...://www.roseindia.net/jsp/loginstatus.shtml
Admin and User Login JSP - JSP-Servlet
Admin and User Login JSP  Respected Sir, I am R.Ragavendran.. i need a JSP based program immediately.. In the home page, there must be a login page with username and password fields.. When the username and password is "admin
how to disable submit button after login in jsp
to disable submit button after login in jsp? Thanks   Hi, You can... the Session setattribute in jsp Working with sessions JSP Login Logout Example... in learning JSP Login and session management. Thanks
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
Redirect to same jsp page on successful login
Redirect to same jsp page on successful login  Hi, I have an application where on successful login, the redirect should happen to same page with a session created for the user. On login, i have some dropdowns which are populated
Session tracking in login jsp program - JSP-Interview Questions
Session tracking in login jsp program  I have using jsp technology in my project.I want to do session tracking in my login form.After logout when i... jsp code on my email id :[email protected]  Hi Friend, Please
Login form using Jsp in hibernate - Hibernate
Login form using Jsp in hibernate   Hai Friend, As I new To hibernate, I'm facing problem in My project(JSP with hibernate).. My login form is working but the problem is ,when i enter correct user name and password
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
Direct jsp coding for gmail login page and to open mail
Direct jsp coding for gmail login page and to open mail  DEAR SIR, i'm urgently in need of jsp coding to create login page of gmail and to open mail
admin login control page - JSP-Servlet
admin login control page  how to encrypted password by using jsp... adminPage.jsp?  JSP Example code for encrypted passwordJSP Encrypted Password Example CodeadminPage.jsp<html> <title>Admin login
add cookies to login form in jsp by using struts2.0 framework
add cookies to login form in jsp by using struts2.0 framework  hi sir i implemented login.jsp page it include username and password field I used struts2.0 and hibernate3.0 and mysql database for login .jsp now i want to add
code for user registration page and login page of emails using jsp
code for user registration page and login page of emails using jsp  hiiiiiii please send me the code for user registration page and login page of email using jsp and servlets and also code for database connectivity to oracle
validating credentials and displaying error message in login .jsp if not valid
validating credentials and displaying error message in login .jsp if not valid  hi, i want to validate user name and password against my database table if not valid i have to display error message in my login page.how to do
Simplest Login and Logout example in JSP
Simplest Login and Logout example in JSP   This JSP example shows you how to login and logout the session between JSP pages. JSP provide an implicit object that is session in which use to save
login
login  how to create login page in jsp   Here is a jsp code that creates the login page and check whether the user is valid or not. 1...;tr><td></td><td><input type="submit" value="Login">
login
login  login page display an error showing failure to login even when the correct information is entered
using ajax and jsp (struts) to login and remain on same page.
using ajax and jsp (struts) to login and remain on same page.  I am a fresher... I can forward my login page to success page using struts, but I want to remain on same login page and just want to display loggers name ... I don't
login
login  how to login admin and user with the same fields(name & password) in single login page while the table for admin and user is seprate in database(mysql) please provide me solution
How to Display Username After Login in JSP
How to Display Username After Login in JSP In this section we will discuss how to display the Username and password after the successful login. In JSP it is a simple task to display the Login details just you have to create a html
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box... login"); while(rs.next()){ %> <option value="<
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in whic i should select the company name in dropdown box.... so when i login i all the three username,password and dropdown box
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in which i should select the company name in dropdown box.... so when i login i all the three username,password and dropdown box
Login Authentication using Bean and Servlet In JSP
Login Authentication using Bean and Servlet In JSP... developed a web application of login authentication using Bean  in JSP. Five... : 1). Create a webpage "login.jsp"  to login the user. 
login
login  i want to now how i can write code for form login incolude user and password in Jcreator 4.50   Hello Friend, Visit HereADS_TO_REPLACE_1 Thanks
login
java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form...(); ResultSet rs=st.executeQuery("select * from login where username='"+value1
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name

Ads