Click the above link for example
JDBC
Dynamic Login 👤 Example using Servlet in Java
DynamicLogin.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Static Login</title>
<!-- www.raviroza.com -->
</head>
<body>
<h1>Static Login Information</h1>
<hr>
<form action="dlogin" method="post">
<p>
Username <input type="text" name="txtuser">
</p>
<p>
Password <input type="password" name="txtpass">
</p>
<p>
<input type="submit" value="Login" />
</p>
</form>
</body>
</html>
DynamicLoginServlet.java
package RROExamples;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/dlogin")
public class DynamicLoginServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
//create table tbluser (username varchar2(30), password varchar2(30));
//response.getWriter().append("Served at: ").append(request.getContextPath());
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String user = request.getParameter("txtuser");
String pass = request.getParameter("txtpass");
String QRY = "select * from tbluser where ";
QRY += " username = '"+ user +"' and ";
QRY += " password = '"+ pass +"' ";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","hjd");
if(conn.createStatement().executeQuery(QRY).next())
{
pw.print("Welcome, Master : "+user);
response.sendRedirect("home.html");
}
else
{
pw.print("Sorry, My Lord ");
pw.println("<br><a href='signup.html'> Sign Up Here </a> ");
}
}
catch(Exception e)
{
pw.print("Error : "+e.toString());
}
}
}
JDBC Callable Statement Theory
- CallableStatement interface is used to call the stored procedures or functions.
- We can have business logic on the database by the use of stored procedures and functions that will make the performance better because they are precompiled.
- For example we need to retrieve the age of the student based on birth date, one may create a function that receives date as INPUT and returns age of the student as the OUTPUT.
Watch “Steps to Create DSN file & JDBC Connection to MS Access Database in Java 8” on YouTube
#RaviROza #Jdk #Java #AdvanceJava #DSNFile #JDBCConnectionToMsAccessDatabase #Gujarati
Video features the following:
- How to define Data Source Name (DSN) file in Windows 10 to connect with support database using ODBC driver.
- Connecting with MS Access database in Java 8 using third party database driver called UCanAccess.
OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7
Follow me @
https://raviroza.wordpress.com/
https://raviroza.blogspot.com/
https://www.facebook.com/ravi.oza.it
https://twitter.com/raviozaIT
https://www.youtube.com/user/ravioza101
Watch “JSP Part-2 | JSP Login example (Gujarati)” on YouTube
Jdk #Java #JSP #JavaServerPages #Scriplet #Delimiters #JSPLogin #LoginExampleUsingJSP #Gujarati #RaviROza
Video features the combination of following
- Scriplet tag example in JSP
- Expression tag example in JSP
- Comment tag example in JSP
Following are the files used in the JSP login example
- index.jsp
- login.jsp
- welcome.jsp
- sorry.jsp
Overall process of example:
index.jsp page contains user interface to accept username and password from client side, when client submits the control transfer to the login.jsp file which contains the logic to validate username and password. If the client information is validated the control is transfer to welcome.jsp otherwise to sorry.jsp.
OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7
follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it
Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101
Watch “Introduction to RMI – Remote Method Invocation (Gujarati)” on YouTube
RMI #RemoteMethodInvocation #Jdk #Java #Gujarati #RemoteProcedureCall #Stub #Skeleton #RaviROza
RMI Introduction:
RMI is an API that provides a mechanism to develop distributed app, objects on different computers can interact in a distributed network.
It allows an object to invoke methods on an object running in another JVM.
RMI is the Java version of what is generally known as a remote procedure call (RPC), but with the ability to pass one or more objects along with the request.
The object can include information that will change the service that is performed in the remote computer.
The RMI provides remote communication between the applications using two objects stub and skeleton.
- various sources
OS : Windows 10
Jdk : Version 8
follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it
Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101
Watch “Servlet Part-24 | Login and Logout using Http Session & JDBC (Gujarati)” on YouTube
Servlet #SignUp #JDBC #MySql #Eclipse #MySqlWorkBench #ApacheTomcat #Jdk #Java #DynamicLogin #Gujarati #RaviROza #CreateReadUpdateAndDelete #CRUD #Create #read #update #delete #LogIn #LogOut #SignIn # SignOut
Steps to perform the example:
- Login
- Define HttpSession when user info. (id/password) is validated
- Add attributes to newly created session object
- Logout
- Define a servlet for user to Logout
- Retrieve current session object
- Remove attributes from session
- Call invalidate() method on session object
OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Database : MySQL using MySql Workbench 5.2 CE
Server : Apache Tomcat 7
follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it
Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101