Ravi Oza
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.
Duck Duck Go
- DuckDuckGo સૌપ્રથમ 2008 માં લોન્ચ કરવામાં આવ્યું હતું, ગેબ્રિયલ વેઇનબર્ગ તેના સ્થાપક અને CEO છે.
- તે હજુ પણ DuckDuckGo Inc નો માલિક છે અને તેનું સંચાલન કરે છે.
- DuckDuckGo પોતાને “સર્ચ એન્જિન જે તમને ટ્રેક કરતું નથી” તરીકે વર્ણવે છે.
- DuckDuckGo ડેટા એકત્રિત અને સંગ્રહિત કરતું નથી.મોટાભાગના સર્ચ એન્જિન સર્ચ ડેટા એકત્રિત કરે છે અને સ્ટોર કરે છે, ગૂગલ તે ડેટાને તમારા એકાઉન્ટ સાથે લિંક કરે છે.
- રેકોર્ડ કરેલી માહિતીનો ઉપયોગ તમારા શોધ પરિણામોને વ્યક્તિગત કરવા અને તમને લક્ષિત જાહેરાત બતાવવા માટે થાય છે.
- પરંતુ DuckDuckGo (DDG) તમને ટ્રેક કરતું નથી અને તમારા શોધ પરિણામોને વ્યક્તિગત ન કરવાનું પસંદ કરે છે.
- Download DuckDuckGo for Android Smartphone.
JDBC Prepared Statement Example
- The main feature of a PreparedStatement object is that, unlike a Statement object, it is given a SQL statement when it is created.
- The advantage to this is that in most cases, this SQL statement is sent to the DBMS right away, where it is compiled.
- As a result, the PreparedStatement object contains not just a SQL statement, but a SQL statement that has been precompiled.
- This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement SQL statement without having to compile it first.
How to Auto Shut Down your PC ?
Wise Auto Shutdown enables your PC to shut down, restart, power off, log off, sleep or hibernate on a regular basis or only once, at a specific time. It makes your power management much easier and more convenient.