Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet login and registration form using servlet and authentication through mysql
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sunita sharma
login and registration form using servlet and authentication through mysql
0 Answer(s)      7 months ago
Posted in : JSP-Servlet


i made a simple login and rgistration form using servlet and authentication through mysql and whenevr i run it on tomcat a blank page is displayed plz help here is my code...plz chk the web.xml file also

index.jsp(login form)

<%@page contentType="text/html" pageEncoding="UTF-8"%> :::LOGIN:::

Enter the Username:
Enter the Password:
Register here

login.java (servlet)

package login;

import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;

import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

public class login extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    System.out.println("test");
    String driver = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost/login";
    response.setContentType("text/html");
    String msg = " ";

    String username = request.getParameter("username");
    String password = request.getParameter("password");
    try {
        Class.forName("com.mysql.jdbc.Driver");

        Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","");  

        String strQuery = "select * from validate WHERE username='"
                + username + "' and password='" + password + "'";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(strQuery);
        if (rs.next()) {
            msg = "HELLO" + username + "! Your login is SUCESSFULL";

        } else {
            msg = "HELLO" + username + "!Your login is UNSUCESSFULL";
        }
        rs.close();
        st.close();
        System.out.println("test :" + msg);
        PrintWriter out = response.getWriter();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

sign.jsp (signup form)

<%@page contentType="text/html" pageEncoding="UTF-8"%> :::Sign Up:::

Enter the Name:
Enter the City:
Enter the Country:
Enter the Username:
Enter the Password:
Login here

signup.java(servlet)

import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement;

import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

public class signup extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response)  
        throws ServletException, IOException {  
    System.out.println("test");

response.setContentType("text/html");
PrintWriter out = response.getWriter();

String n=request.getParameter("name");
String c=request.getParameter("city");
String co=request.getParameter("country");
String u=request.getParameter("username"); String p=request.getParameter("password");

try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","");

PreparedStatement ps=con.prepareStatement("insert into registeruser values(?,?,?,?,?)");

ps.setString(1,n);
ps.setString(2,c);
ps.setString(3,co);
ps.setString(4,u);
ps.setString(5,p);

int i=ps.executeUpdate();
if(i>0)
out.print("You are successfully registered...");

System.out.println("test");
}catch (Exception e2) {System.out.println(e2);}

out.close();
}

}

web.xml

login index.html index.htm index.jsp default.html default.htm default.jsp login login login.login login /login signup signup signup signup /signup


Advertisement
View Answers

Related Tutorials/Questions & Answers:
login and registration form using servlet and authentication through mysql
login and registration form using servlet and authentication through mysql  i made a simple login and rgistration form using servlet and authentication through mysql and whenevr i run it on tomcat a blank page is displayed plz
How to Create Login/ Registration Form using PHP and MYSQL
How to Create Login/ Registration Form using PHP and MYSQL  Hi, I am learning PHP. I have some dilemma how to create a Login Form and make connectivity with HTML page using PHP and MYSQL. Is there any body can guide me
Advertisements
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
Login authentication & mysql - Java Beginners
Authentication with MySql using Java Swing: 1)Create a java class...Login authentication & mysql  Hi , Could you guide or provide sample coding for the following scenerio. I need to code authentication for user
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 and remove user only in servlet.   Hi Friend, Please visit
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
java code for registration and login pages, mysql as a bankend.
java code for registration and login pages, mysql as a bankend.  please send me the java code for registration and login pages and to store the data in mysql
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...;/body> <html> Output: Login Authentication form : After
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
how to connect the database using hibernet through servlet/jsp through form
how to connect the database using hibernet through servlet/jsp through form  plz give me the reply   Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/myfacesspring/loginRegistration.shtml Hope
Login Authentication using existing Active Directory.
Login Authentication using existing Active Directory.  I need jsp code for login authentication of username and password using already existing Active Directory. Here no need to create active directory.The JSP code should
registration form using oop concept
registration form using oop concept  I would like to write a program student registration form at kindergartens and display the information... the output?   Registration Form: import javax.swing.*; import java.awt.
user Registration form using bean
user Registration form using bean   In this code,password and confirm password does n't matches.Every time an error occured if i entered same string for both.Please help to sort my problem
Developing User Registration Form
Developing User Registration Form   ... necessary to develop the User Registration Form for our Struts, Hibernate and Spring based User Registration and Authentication Application. This section shows you
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
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
PHP MySQL Login Form
Login Form using PHP and MySQL: In any website generally it is mandatory to have a login form to keep your data secure. In this regard we need to have... will study how to create a login form, connect with the database server and login
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
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.
redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.  I am successfully able to create a session on successful login, but I want to display
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 authentication - Java Beginners
login authentication  i 've designed the jsp page for login. now i need to connect it with the bean and do authentication for the login for the "register" table in mysql. can anybody help me with the code immediately
JDbc Login Authentication
JDbc Login Authentication  Pease Please.. Send Me one Login Authentication Using ComboBox.From Servlet and jsp with sessions I am new to sessions Please Help Me... Index.jsp <form action="Clas.java" Method="post">
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
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
jsp page authentication panel using jsp/servlet?
jsp page authentication panel using jsp/servlet?  I have 10 jsp jsp forms and 7 users and i want to grant variour permission like edit,delete and save for users dynamically on forms.So please refer me code
Registration Form
Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data username,password,date of birth,Mobile number number into database. How to insert
Struts Login Authentication
Struts Login Authentication  Hi Sir, Am doing a project in a struts 1.2,i want login authentication code fro that, only authenticated user can login into application,i am using back end as Mysql.so send me code as soon
Login issue using Servlet
Login issue using Servlet  Hi all, I need a code for login using servlet where in I want to check and validate user name and password from database also I want to check candidate's class (for ex. FY, SY, TY) if candidate's class
registration form
registration form  Hii.. I have to design one registration page...;Etisalat Login Page</title> <meta name="Keywords" content="" />...="center" border=0&gt; &lt;form name="f1" action="CreateUser
User Registration Form Using JSP(JspBeans)
User Registration Form Using JSP(JspBeans)  ... of user registration form using jsp. One of the basic programming tactics... a simple registration form (register.html):       <
Advertisements
 

 

 

DMCA.com