1. Create insert.html page. source code given below.
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
<form action="insert.jsp">
<input type="text" name="txt1">
<input type="text" name="txt2">
<input type="submit" name="btnsubmit">
</form>
</body>
</html>
2. create file insert.jsp. Source code given below
<%@ page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<h1>Insert Value in sqlite database</h1>
<%
String fname,lname;
String sDriverName = "org.sqlite.JDBC";
Class.forName(sDriverName);
String sJdbc = "jdbc:sqlite";
String sTempDb = "d:\\pu.db";
String sDbUrl = sJdbc + ":" + sTempDb;
Connection connection = DriverManager.getConnection(
sDbUrl);
fname=request.getParameter("txt1");
lname=request.getParameter("txt2");
String sMakeInsert = "INSERT INTO ajay VALUES('"+fname+"','"+lname+"')";
Statement stmt = connection.createStatement();
stmt.executeUpdate( sMakeInsert );
// ResultSet resultset = stmt.executeQuery(sMakeSelect);
3. Finally you can see value of textbox (txt1) and textbox (txt2) are stored in database.
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
<form action="insert.jsp">
<input type="text" name="txt1">
<input type="text" name="txt2">
<input type="submit" name="btnsubmit">
</form>
</body>
</html>
2. create file insert.jsp. Source code given below
<%@ page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<h1>Insert Value in sqlite database</h1>
<%
String fname,lname;
String sDriverName = "org.sqlite.JDBC";
Class.forName(sDriverName);
String sJdbc = "jdbc:sqlite";
String sTempDb = "d:\\pu.db";
String sDbUrl = sJdbc + ":" + sTempDb;
Connection connection = DriverManager.getConnection(
sDbUrl);
fname=request.getParameter("txt1");
lname=request.getParameter("txt2");
String sMakeInsert = "INSERT INTO ajay VALUES('"+fname+"','"+lname+"')";
Statement stmt = connection.createStatement();
stmt.executeUpdate( sMakeInsert );
// ResultSet resultset = stmt.executeQuery(sMakeSelect);
3. Finally you can see value of textbox (txt1) and textbox (txt2) are stored in database.