In this example we will show you how to authenticate and login user against database username and password. This program consists of a JSP page and a Servlet to authenticate the user against database username and password.
User enters the username and password on the JSP page and clicks on the "Sign-In" button. On the form submit event, data is posted to the servlet for authenticating the user. Servlet makes JDBC connection and authenticate the user. Before submitting data to servlet, javascript is ensuring that none of the fields must be empty.
We are using tomcat server for running Servlet and JSP page. You can use any browser to test the application. We are using two files AuthenticLogin.jsp and LoginAuthentication.java and we are making the application in "webapps/JSPMultipleForms" in tomcat server.
Download Source Code
Showing posts with label Best Java Interface Example. Show all posts
Showing posts with label Best Java Interface Example. Show all posts
Does Interfaces Provide for Multiple Inheritance?
Often interfaces are touted as an alternative to multiple class inheritance. While interfaces may solve similar problems, interface and multiple class inheritance are quite different animals, in particular:
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the same interface may or may not be related through the class hierarchy. This is not true for multiple inheritance.
Yet, Java does allow multiple interface inheritance. That is, an interface can have multiple superinterfaces.
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the same interface may or may not be related through the class hierarchy. This is not true for multiple inheritance.
Yet, Java does allow multiple interface inheritance. That is, an interface can have multiple superinterfaces.
Best Java Interface Example ,Core Java Tutorial,Java Interview Questions
Java interface example :
In this class i implement Java shape interface in the circle class .as you will see in the following example ,up-casting for the object "circleshape" .
Note :
Interface classes , functions are public and abstract ,and fields are public and final
public class Main {
public static void main(String[] args) {
shape circleshape=new circle();
circleshape.Draw();
}
}
interface shape
{
public String baseclass="shape";
public void Draw();
}
class circle implements shape
{
public void Draw() {
System.out.println("Drawing Circle here");
}
}
In this class i implement Java shape interface in the circle class .as you will see in the following example ,up-casting for the object "circleshape" .
Note :
Interface classes , functions are public and abstract ,and fields are public and final
public class Main {
public static void main(String[] args) {
shape circleshape=new circle();
circleshape.Draw();
}
}
interface shape
{
public String baseclass="shape";
public void Draw();
}
class circle implements shape
{
public void Draw() {
System.out.println("Drawing Circle here");
}
}
Subscribe to:
Posts (Atom)