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..

View Answers

May 31, 2011 at 11:20 AM

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="http://localhost:8080/examples/Login" 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>

2)Login.java:

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Login extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { 

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try{
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();
        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("/examples/jsp/login.jsp");
          }
    }
    catch (Exception e) {
    e.printStackTrace();
    }
}
}









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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 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 page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description... table login. After successfully login user1 see only index page,if user2 login then he see only visiter page and so on. please gine me any suggession. Thanks
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... from the database. I am unable to create the session for the same 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?  how to connect jsp with sql database by netbeans in a login page
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
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
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
login page
login page  code for login page
login page
login page  pls say how to create a login page in jsp and mysql using netbaens   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://roseindia.net/jsf/netbeans/index.shtml http://roseindia.net/jsp
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 page
Login page  how to create Login page in java
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 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...;</font></label> <% } %> 2)check.jsp: <%@page import
Login Page
Login Page  Can anyone tell me the steps to create a login page in myeclipse 7.0 and validating it with login database in db2 9.7 ??? Please tell me
login page
login page  hi i'm trying to create login page using jsp. i get... the program. Following are my programs... 1.index.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> JSP Page
login page
login page  How to login as different user in php
JSP - Login
JSP - Login  how to disabled back button of the browser when user successfully logged
LOGIN PAGE
LOGIN PAGE  A java program with "login" as title,menus added, and a text field asking for firstname, lastname, and displaying current date and time
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
coding for login page
coding for login page  coding for login page
login page in php
login page in php  How to create a login page in php
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
login page - Java Beginners
login page  I have one login page in jsp that is login.jsp. Now i have validate user from database by another page validate.jsp. but if the user feeded wrong information then i want to print error massege on the first page
basic login and registration web page using jsp and servlet without using bean .....
basic login and registration web page using jsp and servlet without using bean .....  Hello Folks please i m totally beginner so guys please help me with very simple solution..... thnx
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
jsp/servlet login program
jsp/servlet login program  <%@ page language="Java" import...; </jsp:useBean> <jsp:forward page="hello"> <jsp:param name...;/TITLE></HEAD> <BODY> <jsp:useBean id="db" scope="request" class
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
login
login  How to create login page in jsp
login
login  How to create login page in jsp
login page code in asp.net
login page code in asp.net  i need front end and backend code for login page in vb asp.net using sql server....having code for submit button
SSL for login page
SSL for login page  I am trying to apply ssl cert to login page only. Does anyone know how to do this on a tomcat web server
html login page with ajax
html login page with ajax  hi all... i want to create a login page...... thanks in advance   Here is a jsp example that accepts username...=="yes"){ alert("Welcome User"); }else{ alert("Invalid Login! Please try again
login page error
login page error  How to configure in to config.xml .iam takin to one login form in that form action="/login" .when iam deployee the project... this request." please suggest me.   if your login page is prepared
how to create a login page and registration page?
how to create a login page and registration page?  hellow, pls tell me the code for how we can create a login page and registration page and how we can store the info in database.only in advance java as jsp
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
login page with image
login page with image  I am writing program for login page.It consists of a image and the login details... how to write a java program using frames that have the default positions in any of the systems.. thanks   i had
Spring Login Page Error
Spring Login Page Error  Dear Sir/Madam, I used the spring login page code. The index page is working fine. When i try to entry login and password , i am getting the below error: Please help me out in this. Let me know if i
Login page validation on ipad
Login page validation on ipad  I am using userId & password labels and their corresponding textfield. Now I want to validate the details by single sign in button and want to switch on to next page. Used two labels again
HTML login page code
HTML login page code  Hi all, I am writing my first HTML JavaScrip... the complete HTML JavaScript code for User Login Page. Thanks in Advance!   ...;td colspan=2><font size=3><center><b>HTML Login Page
how to disable submit button after login in jsp
on the back button in browser it stars displaying login page. How to prevent this? how to disable submit button after login in jsp? Thanks   Hi, You can...("loggedin", "yes"); Now in login page you can get the value of this session
login page validation
login page validation  hi could you please send me code for login validations Email validation and password email should be in correct format and valid password in java   import java.awt.*; import javax.swing.
login page php mysql example
login page php mysql example  How to create a login page for user in PHP Mysql? Please provide me a complete tutorial. Thanks in Advance
.Net and SQl 2000 Login page
.Net and SQl 2000 Login page  Please help me creating a login page using dot net using data base sql 2000

Ads