login and registration form using servlet and authentication through mysql

Ads
 

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

View Answers

Ads









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 authentication in jsp and servlet
it with complete code: Login Authentication using Bean and Servlet In JSP JSP... With Session Login Authentication using Bean and Servlet In JSP Thanks... to make login authentication in jsp and servlet? Thanks   Hi, I to make
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
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 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
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
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
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
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
java login form using netbeans
java login form using netbeans  how to connect an access database to a login form using netbeans
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.
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
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
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
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
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 using java bean in eclipse
login form using java bean in eclipse  I have made a college community website but i need to implement beans to my login and contact us page. how can i do
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
Spring 4: Login Form using Spring MVC and Hibernate Example
Spring 4 MVC Login Example: Database driven login form using Spring MVC... is the video tutorial of "Login Form using Spring MVC and Hibernate"... login form example with backend database validation using Hibernate Framework
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... struts2.0 and hibernate3.0 and mysql database for login .jsp now i want to add cookies to above form please help me
Login Form with Java GUI using Netbeans
Login Form with Java GUI using Netbeans  Hi there! I'm a beginner...(){ super("Login Authentication"); setSize(400,300); setLocation... have different user to login? Now that I've only administrator who is able
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

Ads