{"id":314,"date":"2018-07-27T08:56:12","date_gmt":"2018-07-27T08:56:12","guid":{"rendered":"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=314"},"modified":"2018-07-27T08:56:12","modified_gmt":"2018-07-27T08:56:12","slug":"jsp-with-jdbc","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/chapter\/jsp-with-jdbc\/","title":{"rendered":"JSP with JDBC"},"content":{"raw":"<div>\r\n\r\n<strong>\u00a0 \u00a0 \u00a0JDBC<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">JDBC is an application programming interface between Java programs and database management systems. JDBC is a core part of the Java platform and is included in the standard JDK distribution. The purpose of JDBC is to connect database and manipulate the data in database from a Servlet page or from a JSP page.<\/p>\r\n&nbsp;\r\n\r\n<strong>Basic Steps to Connect Database<\/strong>\r\n\r\n&nbsp;\r\n\r\n1.\u00a0 Establish a connection.\r\n\r\n2.\u00a0 Create JDBC Statements.\r\n\r\n3.\u00a0 Execute SQL Statements.\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">4.\u00a0 Get ResultSet.<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">5.\u00a0 Close connections.<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Step Description<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>1. Establish a connection<\/strong>\r\n\r\n&nbsp;\r\n\r\nA connection to MySQL is established by using the package,\r\n\r\n&nbsp;\r\n\r\nimport java.sql.*;\r\n\r\nThen load the vendor specific driver,\r\n\r\nClass.forName(\"oracle.jdbc.driver.OracleDriver\");\r\n\r\nThis code dynamically loads a driver class, for Oracle database.\r\n\r\nMake the connection,\r\n\r\nConnection conn = DriverManager.getConnection(DB_URL,USER,PASS);\r\n\r\nThis code establishes connection to database by obtaining a Connection object.\r\n\r\n&nbsp;\r\n\r\n<strong>2. Create JDBC statement(s)<\/strong>\r\n\r\n&nbsp;\r\n\r\nJDBC statements are created using the following code,\r\n\r\nStatement stmt = con.createStatement() ;\r\n\r\nThis creates a Statement object for sending SQL statements to the database.\r\n\r\n&nbsp;\r\n\r\n<strong>3. Executing SQL Statements<\/strong>\r\n\r\n&nbsp;\r\n\r\nSQL statements are executed using the query,\r\n\r\nsql = \"SELECT attributes FROM Table\";\r\n\r\n<\/div>\r\n<ol start=\"4\">\r\n \t<li><strong>Get ResultSet<\/strong><strong style=\"text-align: initial;font-size: 1em\">\u00a0<\/strong><\/li>\r\n<\/ol>\r\nThe Resultset object is obtained by the executeQuery() function,\r\n\r\n<strong>\u00a0<\/strong>\r\n\r\nResultSet rs = Stmt.executeQuery(sql);<strong>\u00a0<\/strong>\r\n<ol start=\"5\">\r\n \t<li><strong>Close Connection<\/strong><\/li>\r\n<\/ol>\r\nThe JDBC connection and SQL query execution is closed by calling the close() function,\r\n\r\ncon.close();\r\n\r\n&nbsp;\r\n\r\n<strong>Install Mysql<\/strong>\r\n\r\n&nbsp;\r\n\r\nInstall Mysql Database from MYSQL official website dev.mysql.com\r\n\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-315 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192.png\" alt=\"\" width=\"624\" height=\"242\" \/>\r\n\r\n&nbsp;\r\n\r\nSelect the Platform type (i.e Windows or Mac)and download the Installer.\r\n\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-316 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193.png\" alt=\"\" width=\"597\" height=\"250\" \/>\r\n\r\n&nbsp;\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0Steps to run JSP using Tomcat server<\/strong>\r\n\r\n&nbsp;\r\n\r\nSTEP 1: To run JSP pages, Download TOMCAT SERVER from Website<strong>.<\/strong>\r\n\r\n<strong>URL: https:\/\/tomcat.apache.org\/download-60.cgi<\/strong>\r\n\r\nSTEP 2: The tomcat folder has the following files as bin, conf, lib, logs, temp, webapps and work.\r\n\r\nSTEP 3: Create directory \u201cmyjsp\u201d under the webapps directory.\r\n\r\nSTEP 4: Save this file in shown in the given path,\r\n\r\nC:\/ Program Files\/\u2026\/\u2026\/webapps\/myjsp\/Filename.\r\n\r\nSTEP 5: Download Mysql connector jar file from the following url.\r\n\r\n<strong>URL:https:\/\/dev.mysql.com\/downloads\/connector\/j\/3.1.html<\/strong>\r\n\r\nSTEP 6:Copy the jar file to apache-tomcat\\webapps\\ROOT\\WEB-INF\\lib directory.\r\n\r\nSTEP 7: To run JSP program\r\n\r\nStart the tomcat service,\r\n\r\n<strong>Start -&gt; run -&gt; services.msc -&gt; Select Apache Tomcat -&gt; start<\/strong>\r\n\r\nOpen new tab in browser or open new window,\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">http:\/\/localhost:8080\/myjsp\/Filename.jsp<\/strong>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 \u00a0Creating a Table using JSP<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Example Code:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The following code is for creating a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQl statement \"CREATE table test (testid mediumint(8), name varchar(100))\" using the executeUpdate() function.<\/p>\r\n&nbsp;\r\n\r\n&lt;%@page contentType=\"text\/html\" pageEncoding=\"UTF-8\"%&gt; &lt;!DOCTYPE html&gt;&lt;%@ page import=\"java.sql.*\" %&gt; &lt;%@ page import=\"com.mysql.jdbc.Driver\" %&gt;\r\n\r\n&nbsp;\r\n\r\n&lt;%!String driver = \"com.mysql.jdbc.Driver\";\r\n\r\nString url = \"jdbc:mysql:\/\/localhost\/PUB\";\r\n\r\nString name = \"root\"; String pass=\"password\"; %&gt;\r\n\r\n&lt;html&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;title&gt;testJSP&lt;\/title&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;p&gt;Attempting to open JDBC connection to:... &lt;\/p&gt;&lt;%=url%&gt;\r\n\r\n&lt;%\r\n\r\ntry{\r\n\r\nString tableStr = \"CREATE table test (testid mediumint(8), name varchar(100))\"; Class.forName( driver );\r\n\r\nConnection con = DriverManager.getConnection( url, name, pass ); Statement stat = con.createStatement(); %&gt;&lt;p&gt; executing: &lt;%=tableStr%&gt;&lt;\/p&gt;<span style=\"text-align: initial;font-size: 1em\">%<\/span><span style=\"text-align: initial;font-size: 1em\">stat.executeUpdate( tableStr );<\/span><span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span><span style=\"text-align: initial;font-size: 1em\">&lt;p&gt; success.... &lt;\/p&gt;<\/span><span style=\"text-align: initial;font-size: 1em\">&lt;%<\/span><span style=\"text-align: initial;font-size: 1em\">con.close();<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">catch (SQLException sqle)<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">out.println(\"&lt;p&gt; Error opening JDBC, cause:&lt;\/p&gt; &lt;b&gt; \" + sqle + \"&lt;\/b&gt;\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">catch(ClassNotFoundException cnfe)<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">out.println(\"&lt;p&gt; Error opening JDBC, cause:&lt;\/p&gt; &lt;b&gt;\" + cnfe + \"&lt;\/b&gt;\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/html&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0Creating a Table: Database<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>OUTPUT:<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe output of the above code is shown below.\r\n\r\n<\/div>\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-317 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194.png\" alt=\"\" width=\"490\" height=\"168\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>DATABASE:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-318 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195.png\" alt=\"\" width=\"636\" height=\"188\" \/><\/p>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>SELECT Operation<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Example Code:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The following code is for selecting records from a table using a JSP page and display the records in a table format. First establish a connection to the database from the JSP page. When connection is successful, execute the SQL statement \"select * from Publisher\" using the executeQuery() function.<\/p>\r\n&nbsp;\r\n\r\n&lt;%@page contentType=\"text\/html\" pageEncoding=\"UTF-8\"%&gt; &lt;!DOCTYPE html&gt;\r\n\r\n&lt;%@ page import=\"java.sql.*\" %&gt;\r\n\r\n&lt;% Class.forName(\"com.mysql.jdbc.Driver\"); %&gt;\r\n\r\n&lt;HTML&gt;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;HEAD&gt;\r\n<\/span><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 &lt;TITLE&gt;The Publishers Database Table &lt;\/TITLE&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/HEAD&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;BODY&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;H1&gt;The Publishers Database Table &lt;\/H1&gt;<\/span>\r\n\r\n<strong style=\"text-align: initial;font-size: 1em\">&lt;%<\/strong><span style=\"text-align: initial;font-size: 1em\">Connection connection = DriverManager.getConnection(<\/span><span style=\"text-align: initial;font-size: 1em\">\"jdbc:mysql:\/\/localhost\/PUB\", \"root\", \"password\");<\/span><span style=\"text-align: initial;font-size: 1em\">Statement statement = connection.createStatement() ;<\/span><span style=\"text-align: initial;font-size: 1em\">ResultSet resultset = statement.executeQuery(\"select * from Publisher\") ; <strong>%&gt;<\/strong><\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TABLE BORDER=\"1\"&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TR&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;ID&lt;\/TH&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;Name&lt;\/TH&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;City&lt;\/TH&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;State&lt;\/TH&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;Country&lt;\/TH&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/TR&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;% while(resultset.next()){ %&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TR&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(1) %&gt;&lt;\/td&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(2) %&gt;&lt;\/TD&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(3) %&gt;&lt;\/TD&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(4) %&gt;&lt;\/TD&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(5) %&gt;&lt;\/TD&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/TR&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;% } %&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/TABLE&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/BODY&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/HTML&gt;<\/span>\r\n\r\n&nbsp;\r\n\r\n<\/div>\r\n<strong>OUTPUT:<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe output of the above code is shown below.\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-319 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196.png\" alt=\"\" width=\"432\" height=\"213\" \/><\/p>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>INSERT Operation<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Example Code:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The following code is for inserting records into a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQl statement \"INSERT<\/p>\r\n&nbsp;\r\n\r\nINTO Employees VALUES (105, 22, \u2018Jeeva', \u2018Kumar')\".\r\n\r\n&lt;%@ page import=\"java.io.*,java.util.*,java.sql.*\"%&gt;\r\n\r\n&lt;%@ page import=\"javax.servlet.http.*,javax.servlet.*\" %&gt;\r\n\r\n&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" prefix=\"c\"%&gt;\r\n\r\n&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/sql\" prefix=\"sql\"%&gt;\r\n\r\n&lt;html&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;title&gt;JINSERT Operation&lt;\/title&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;sql:setDataSource var=\"snapshot\" driver=\"com.mysql.jdbc.Driver\"\u00a0<span style=\"text-align: initial;font-size: 1em\">url=\"jdbc:mysql:\/\/localhost\/TEST\"\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">user=\"root\"\u00a0 password=\"password\"\/&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;sql:update dataSource=\"${snapshot}\" var=\"result\"&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">INSERT INTO Employees VALUES (105, 22, \u2018Jeeva', \u2018Kumar'); &lt;\/sql:update&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;sql:query dataSource=\"${snapshot}\" var=\"result\"&gt; SELECT * from Employees; &lt;\/sql:query&gt;<\/span>\r\n\r\n<\/div>\r\n<strong>\u00a0 \u00a0Output<\/strong>:\r\n\r\n&nbsp;\r\n\r\nThe output of the above code is shown below\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-320 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197.png\" alt=\"\" width=\"545\" height=\"243\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Database (Before Executing)<\/strong>:\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-321 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198.png\" alt=\"\" width=\"553\" height=\"395\" \/><\/p>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0DELETE Operation<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The following code is for deleting records from a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQL statement \"DELETE FROM Employees WHERE Id = ?\".<\/p>\r\n&nbsp;\r\n\r\n<strong>Example<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;%@ page import=\"java.io.*,java.util.*,java.sql.*\"%&gt;\r\n\r\n&lt;%@ page import=\"javax.servlet.http.*,javax.servlet.*\" %&gt;\r\n\r\n&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" prefix=\"c\"%&gt;\r\n\r\n&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/sql\" prefix=\"sql\"%&gt;\r\n\r\n&lt;html&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;title&gt;DELETE Operation&lt;\/title&gt;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/head&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;body&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;sql:setDataSource var=\"snapshot\" driver=\"com.mysql.jdbc.Driver\"<\/span><span style=\"text-align: initial;font-size: 1em\">url=\"jdbc:mysql:\/\/localhost\/TEST\"<\/span><span style=\"text-align: initial;font-size: 1em\">user=\"root\"\u00a0 password=\"password\"\/&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;c:set var=\"empId\" value=\"102\"\/&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;sql:update dataSource=\"${snapshot}\" var=\"count\"&gt; DELETE FROM Employees WHERE Id = ? &lt;sql:param value=\"${empId}\" \/&gt; &lt;\/sql:update&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;sql:query dataSource=\"${snapshot}\" var=\"result\"&gt; SELECT * from Employees;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/sql:query&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;table border=\"1\" width \"100%\"&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;tr&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Emp ID&lt;\/th&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;First Name&lt;\/th&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Last Name&lt;\/th&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Age&lt;\/th&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/tr&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;c:forEach var=\"row\" items=\"${result.rows}\"&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;tr&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=\"${row.id}\"\/&gt;&lt;\/td&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=\"${row.first}\"\/&gt;&lt;\/td&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=\"${row.last}\"\/&gt;&lt;\/td&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=\"${row.age}\"\/&gt;&lt;\/td&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/tr&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/c:forEach&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/table&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/html&gt;<\/span>\r\n\r\n<\/div>\r\n<strong>\u00a0 \u00a0 \u00a0Output:<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe output of the above code is shown below.\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-322 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199.png\" alt=\"\" width=\"622\" height=\"369\" \/><\/p>\r\n&nbsp;\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 Login Application<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>Example<\/strong>\r\n\r\n<strong>\/\/Index.html<\/strong>\r\n\r\n&nbsp;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;form action=\"Login.jsp\" method=\"post\"&gt;\r\n\r\nUser name :&lt;input type=\"text\" name=\"userid\" \/&gt; password :&lt;input type=\"password\" name=\"password\" \/&gt; &lt;input type=\"submit\" \/&gt;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/form&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">Login.jsp<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;%@ page import =\"java.sql.*\" %&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;%@ page import =\"javax.servlet.http.*\" %&gt;<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">&lt;%<\/span><span style=\"text-align: initial;font-size: 1em\">String userid=request.getParameter(\"userid\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">session.putValue(\"userid\",userid);<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">String password=request.getParameter(\"password\"); Class.forName(\"com.mysql.jdbc.Driver\"); java.sql.Connection con =<\/span><span style=\"text-align: initial;font-size: 1em\">DriverManager.getConnection(\"jdbc:mysql:\/\/localhost\/test\",\"root\",\"password\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">Statement st= con.createStatement();<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">ResultSet rs=st.executeQuery(\"select * from users where user_id='\"+userid+\"'\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">if(rs.next())<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">if(rs.getString(2).equals(password))<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">out.println(\"welcome\"+userid);<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">else<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">{<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">out.println(\"Invalid password try again\");<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">}<\/span>\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">else<\/span><span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>\u00a0 \u00a0 \u00a0Output:<\/strong>\r\n\r\n&nbsp;\r\n\r\nThe output of the above code is shown below.\r\n\r\n<\/div>\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-324 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201.png\" alt=\"\" width=\"640\" height=\"212\" \/><\/p>\r\n&nbsp;\r\n\r\n<strong>Database:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: center\"><img class=\"size-full wp-image-323 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200.png\" alt=\"\" width=\"627\" height=\"313\" \/><\/p>\r\n\r\n<div>\r\n\r\n<strong>Summary<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In this section we discussed about how to install MySQL and run JSP pages in Tomcat. The module also explains about the operational views of how to Create table, Insert and Delete data in JDBC from JSP page illustrated with needed examples. Finally, this module also demonstrates a simple login Application created using JSP with JDBC.<\/p>\r\n\r\n<\/div>\r\n<strong>Web Links<\/strong>\r\n<ul>\r\n \t<li>Herbert Schildt, \" <em>Java: The Complete Reference\", 9th Edition,<\/em> Mcgraw-Hill, 2014.<\/li>\r\n \t<li><em>https:\/\/www.tutorialspoint.com<\/em><\/li>\r\n<\/ul>\r\n&nbsp;\r\n\r\n&nbsp;","rendered":"<div>\n<p><strong>\u00a0 \u00a0 \u00a0JDBC<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">JDBC is an application programming interface between Java programs and database management systems. JDBC is a core part of the Java platform and is included in the standard JDK distribution. The purpose of JDBC is to connect database and manipulate the data in database from a Servlet page or from a JSP page.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Basic Steps to Connect Database<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>1.\u00a0 Establish a connection.<\/p>\n<p>2.\u00a0 Create JDBC Statements.<\/p>\n<p>3.\u00a0 Execute SQL Statements.<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">4.\u00a0 Get ResultSet.<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">5.\u00a0 Close connections.<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0 Step Description<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>1. Establish a connection<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>A connection to MySQL is established by using the package,<\/p>\n<p>&nbsp;<\/p>\n<p>import java.sql.*;<\/p>\n<p>Then load the vendor specific driver,<\/p>\n<p>Class.forName(&#8220;oracle.jdbc.driver.OracleDriver&#8221;);<\/p>\n<p>This code dynamically loads a driver class, for Oracle database.<\/p>\n<p>Make the connection,<\/p>\n<p>Connection conn = DriverManager.getConnection(DB_URL,USER,PASS);<\/p>\n<p>This code establishes connection to database by obtaining a Connection object.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2. Create JDBC statement(s)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>JDBC statements are created using the following code,<\/p>\n<p>Statement stmt = con.createStatement() ;<\/p>\n<p>This creates a Statement object for sending SQL statements to the database.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3. Executing SQL Statements<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>SQL statements are executed using the query,<\/p>\n<p>sql = &#8220;SELECT attributes FROM Table&#8221;;<\/p>\n<\/div>\n<ol start=\"4\">\n<li><strong>Get ResultSet<\/strong><strong style=\"text-align: initial;font-size: 1em\">\u00a0<\/strong><\/li>\n<\/ol>\n<p>The Resultset object is obtained by the executeQuery() function,<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p>ResultSet rs = Stmt.executeQuery(sql);<strong>\u00a0<\/strong><\/p>\n<ol start=\"5\">\n<li><strong>Close Connection<\/strong><\/li>\n<\/ol>\n<p>The JDBC connection and SQL query execution is closed by calling the close() function,<\/p>\n<p>con.close();<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Install Mysql<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Install Mysql Database from MYSQL official website dev.mysql.com<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-315 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192.png\" alt=\"\" width=\"624\" height=\"242\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192.png 624w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192-300x116.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192-225x87.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-192-350x136.png 350w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Select the Platform type (i.e Windows or Mac)and download the Installer.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-316 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193.png\" alt=\"\" width=\"597\" height=\"250\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193.png 597w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193-300x126.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193-65x27.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193-225x94.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-193-350x147.png 350w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>\u00a0 \u00a0Steps to run JSP using Tomcat server<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>STEP 1: To run JSP pages, Download TOMCAT SERVER from Website<strong>.<\/strong><\/p>\n<p><strong>URL: https:\/\/tomcat.apache.org\/download-60.cgi<\/strong><\/p>\n<p>STEP 2: The tomcat folder has the following files as bin, conf, lib, logs, temp, webapps and work.<\/p>\n<p>STEP 3: Create directory \u201cmyjsp\u201d under the webapps directory.<\/p>\n<p>STEP 4: Save this file in shown in the given path,<\/p>\n<p>C:\/ Program Files\/\u2026\/\u2026\/webapps\/myjsp\/Filename.<\/p>\n<p>STEP 5: Download Mysql connector jar file from the following url.<\/p>\n<p><strong>URL:https:\/\/dev.mysql.com\/downloads\/connector\/j\/3.1.html<\/strong><\/p>\n<p>STEP 6:Copy the jar file to apache-tomcat\\webapps\\ROOT\\WEB-INF\\lib directory.<\/p>\n<p>STEP 7: To run JSP program<\/p>\n<p>Start the tomcat service,<\/p>\n<p><strong>Start -&gt; run -&gt; services.msc -&gt; Select Apache Tomcat -&gt; start<\/strong><\/p>\n<p>Open new tab in browser or open new window,<\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">http:\/\/localhost:8080\/myjsp\/Filename.jsp<\/strong><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0 \u00a0Creating a Table using JSP<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example Code:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The following code is for creating a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQl statement &#8220;CREATE table test (testid mediumint(8), name varchar(100))&#8221; using the executeUpdate() function.<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;%@page contentType=&#8221;text\/html&#8221; pageEncoding=&#8221;UTF-8&#8243;%&gt; &lt;!DOCTYPE html&gt;&lt;%@ page import=&#8221;java.sql.*&#8221; %&gt; &lt;%@ page import=&#8221;com.mysql.jdbc.Driver&#8221; %&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;%!String driver = &#8220;com.mysql.jdbc.Driver&#8221;;<\/p>\n<p>String url = &#8220;jdbc:mysql:\/\/localhost\/PUB&#8221;;<\/p>\n<p>String name = &#8220;root&#8221;; String pass=&#8221;password&#8221;; %&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;testJSP&lt;\/title&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;p&gt;Attempting to open JDBC connection to:&#8230; &lt;\/p&gt;&lt;%=url%&gt;<\/p>\n<p>&lt;%<\/p>\n<p>try{<\/p>\n<p>String tableStr = &#8220;CREATE table test (testid mediumint(8), name varchar(100))&#8221;; Class.forName( driver );<\/p>\n<p>Connection con = DriverManager.getConnection( url, name, pass ); Statement stat = con.createStatement(); %&gt;&lt;p&gt; executing: &lt;%=tableStr%&gt;&lt;\/p&gt;<span style=\"text-align: initial;font-size: 1em\">%<\/span><span style=\"text-align: initial;font-size: 1em\">stat.executeUpdate( tableStr );<\/span><span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span><span style=\"text-align: initial;font-size: 1em\">&lt;p&gt; success&#8230;. &lt;\/p&gt;<\/span><span style=\"text-align: initial;font-size: 1em\">&lt;%<\/span><span style=\"text-align: initial;font-size: 1em\">con.close();<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">catch (SQLException sqle)<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">out.println(&#8220;&lt;p&gt; Error opening JDBC, cause:&lt;\/p&gt; &lt;b&gt; &#8221; + sqle + &#8220;&lt;\/b&gt;&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">catch(ClassNotFoundException cnfe)<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">out.println(&#8220;&lt;p&gt; Error opening JDBC, cause:&lt;\/p&gt; &lt;b&gt;&#8221; + cnfe + &#8220;&lt;\/b&gt;&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/html&gt;<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0Creating a Table: Database<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>OUTPUT:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The output of the above code is shown below.<\/p>\n<\/div>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-317 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194.png\" alt=\"\" width=\"490\" height=\"168\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194.png 490w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194-300x103.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194-65x22.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194-225x77.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-194-350x120.png 350w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>DATABASE:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-318 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195.png\" alt=\"\" width=\"636\" height=\"188\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195.png 636w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195-300x89.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195-65x19.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195-225x67.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-195-350x103.png 350w\" sizes=\"auto, (max-width: 636px) 100vw, 636px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>SELECT Operation<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example Code:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The following code is for selecting records from a table using a JSP page and display the records in a table format. First establish a connection to the database from the JSP page. When connection is successful, execute the SQL statement &#8220;select * from Publisher&#8221; using the executeQuery() function.<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;%@page contentType=&#8221;text\/html&#8221; pageEncoding=&#8221;UTF-8&#8243;%&gt; &lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;%@ page import=&#8221;java.sql.*&#8221; %&gt;<\/p>\n<p>&lt;% Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;); %&gt;<\/p>\n<p>&lt;HTML&gt;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;HEAD&gt;<br \/>\n<\/span><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 &lt;TITLE&gt;The Publishers Database Table &lt;\/TITLE&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/HEAD&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;BODY&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;H1&gt;The Publishers Database Table &lt;\/H1&gt;<\/span><\/p>\n<p><strong style=\"text-align: initial;font-size: 1em\">&lt;%<\/strong><span style=\"text-align: initial;font-size: 1em\">Connection connection = DriverManager.getConnection(<\/span><span style=\"text-align: initial;font-size: 1em\">&#8220;jdbc:mysql:\/\/localhost\/PUB&#8221;, &#8220;root&#8221;, &#8220;password&#8221;);<\/span><span style=\"text-align: initial;font-size: 1em\">Statement statement = connection.createStatement() ;<\/span><span style=\"text-align: initial;font-size: 1em\">ResultSet resultset = statement.executeQuery(&#8220;select * from Publisher&#8221;) ; <strong>%&gt;<\/strong><\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TABLE BORDER=&#8221;1&#8243;&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TR&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;ID&lt;\/TH&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;Name&lt;\/TH&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;City&lt;\/TH&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;State&lt;\/TH&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TH&gt;Country&lt;\/TH&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/TR&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;% while(resultset.next()){ %&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TR&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(1) %&gt;&lt;\/td&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(2) %&gt;&lt;\/TD&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(3) %&gt;&lt;\/TD&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(4) %&gt;&lt;\/TD&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;TD&gt; &lt;%= resultset.getString(5) %&gt;&lt;\/TD&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/TR&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;% } %&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/TABLE&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/BODY&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/HTML&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p><strong>OUTPUT:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The output of the above code is shown below.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-319 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196.png\" alt=\"\" width=\"432\" height=\"213\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196.png 432w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196-300x148.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196-65x32.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196-225x111.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-196-350x173.png 350w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>INSERT Operation<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example Code:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The following code is for inserting records into a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQl statement &#8220;INSERT<\/p>\n<p>&nbsp;<\/p>\n<p>INTO Employees VALUES (105, 22, \u2018Jeeva&#8217;, \u2018Kumar&#8217;)&#8221;.<\/p>\n<p>&lt;%@ page import=&#8221;java.io.*,java.util.*,java.sql.*&#8221;%&gt;<\/p>\n<p>&lt;%@ page import=&#8221;javax.servlet.http.*,javax.servlet.*&#8221; %&gt;<\/p>\n<p>&lt;%@ taglib uri=&#8221;http:\/\/java.sun.com\/jsp\/jstl\/core&#8221; prefix=&#8221;c&#8221;%&gt;<\/p>\n<p>&lt;%@ taglib uri=&#8221;http:\/\/java.sun.com\/jsp\/jstl\/sql&#8221; prefix=&#8221;sql&#8221;%&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;JINSERT Operation&lt;\/title&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;sql:setDataSource var=&#8221;snapshot&#8221; driver=&#8221;com.mysql.jdbc.Driver&#8221;\u00a0<span style=\"text-align: initial;font-size: 1em\">url=&#8221;jdbc:mysql:\/\/localhost\/TEST&#8221;\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">user=&#8221;root&#8221;\u00a0 password=&#8221;password&#8221;\/&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;sql:update dataSource=&#8221;${snapshot}&#8221; var=&#8221;result&#8221;&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">INSERT INTO Employees VALUES (105, 22, \u2018Jeeva&#8217;, \u2018Kumar&#8217;); &lt;\/sql:update&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;sql:query dataSource=&#8221;${snapshot}&#8221; var=&#8221;result&#8221;&gt; SELECT * from Employees; &lt;\/sql:query&gt;<\/span><\/p>\n<\/div>\n<p><strong>\u00a0 \u00a0Output<\/strong>:<\/p>\n<p>&nbsp;<\/p>\n<p>The output of the above code is shown below<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-320 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197.png\" alt=\"\" width=\"545\" height=\"243\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197.png 545w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197-300x134.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197-65x29.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197-225x100.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-197-350x156.png 350w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Database (Before Executing)<\/strong>:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-321 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198.png\" alt=\"\" width=\"553\" height=\"395\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198.png 553w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198-300x214.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198-65x46.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198-225x161.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-198-350x250.png 350w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>\u00a0 \u00a0DELETE Operation<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The following code is for deleting records from a table using a JSP page. First establish a connection to the database from the JSP page. When connection is successful, execute the SQL statement &#8220;DELETE FROM Employees WHERE Id = ?&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;%@ page import=&#8221;java.io.*,java.util.*,java.sql.*&#8221;%&gt;<\/p>\n<p>&lt;%@ page import=&#8221;javax.servlet.http.*,javax.servlet.*&#8221; %&gt;<\/p>\n<p>&lt;%@ taglib uri=&#8221;http:\/\/java.sun.com\/jsp\/jstl\/core&#8221; prefix=&#8221;c&#8221;%&gt;<\/p>\n<p>&lt;%@ taglib uri=&#8221;http:\/\/java.sun.com\/jsp\/jstl\/sql&#8221; prefix=&#8221;sql&#8221;%&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;DELETE Operation&lt;\/title&gt;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/head&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;body&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;sql:setDataSource var=&#8221;snapshot&#8221; driver=&#8221;com.mysql.jdbc.Driver&#8221;<\/span><span style=\"text-align: initial;font-size: 1em\">url=&#8221;jdbc:mysql:\/\/localhost\/TEST&#8221;<\/span><span style=\"text-align: initial;font-size: 1em\">user=&#8221;root&#8221;\u00a0 password=&#8221;password&#8221;\/&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;c:set var=&#8221;empId&#8221; value=&#8221;102&#8243;\/&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;sql:update dataSource=&#8221;${snapshot}&#8221; var=&#8221;count&#8221;&gt; DELETE FROM Employees WHERE Id = ? &lt;sql:param value=&#8221;${empId}&#8221; \/&gt; &lt;\/sql:update&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;sql:query dataSource=&#8221;${snapshot}&#8221; var=&#8221;result&#8221;&gt; SELECT * from Employees;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/sql:query&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;table border=&#8221;1&#8243; width &#8220;100%&#8221;&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;tr&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Emp ID&lt;\/th&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;First Name&lt;\/th&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Last Name&lt;\/th&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;th&gt;Age&lt;\/th&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/tr&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;c:forEach var=&#8221;row&#8221; items=&#8221;${result.rows}&#8221;&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;tr&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=&#8221;${row.id}&#8221;\/&gt;&lt;\/td&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=&#8221;${row.first}&#8221;\/&gt;&lt;\/td&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=&#8221;${row.last}&#8221;\/&gt;&lt;\/td&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;td&gt;&lt;c:out value=&#8221;${row.age}&#8221;\/&gt;&lt;\/td&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/tr&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/c:forEach&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/table&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/html&gt;<\/span><\/p>\n<\/div>\n<p><strong>\u00a0 \u00a0 \u00a0Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The output of the above code is shown below.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-322 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199.png\" alt=\"\" width=\"622\" height=\"369\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199.png 622w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199-300x178.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199-225x133.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-199-350x208.png 350w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>\u00a0 \u00a0 Login Application<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example<\/strong><\/p>\n<p><strong>\/\/Index.html<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;form action=&#8221;Login.jsp&#8221; method=&#8221;post&#8221;&gt;<\/p>\n<p>User name :&lt;input type=&#8221;text&#8221; name=&#8221;userid&#8221; \/&gt; password :&lt;input type=&#8221;password&#8221; name=&#8221;password&#8221; \/&gt; &lt;input type=&#8221;submit&#8221; \/&gt;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/form&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;\/body&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">Login.jsp<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;%@ page import =&#8221;java.sql.*&#8221; %&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;%@ page import =&#8221;javax.servlet.http.*&#8221; %&gt;<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">&lt;%<\/span><span style=\"text-align: initial;font-size: 1em\">String userid=request.getParameter(&#8220;userid&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">session.putValue(&#8220;userid&#8221;,userid);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">String password=request.getParameter(&#8220;password&#8221;); Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;); java.sql.Connection con =<\/span><span style=\"text-align: initial;font-size: 1em\">DriverManager.getConnection(&#8220;jdbc:mysql:\/\/localhost\/test&#8221;,&#8221;root&#8221;,&#8221;password&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">Statement st= con.createStatement();<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">ResultSet rs=st.executeQuery(&#8220;select * from users where user_id='&#8221;+userid+&#8221;&#8216;&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">if(rs.next())<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">if(rs.getString(2).equals(password))<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">out.println(&#8220;welcome&#8221;+userid);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">else<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">{<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">out.println(&#8220;Invalid password try again&#8221;);<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">}<\/span><\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">else<\/span><span style=\"text-align: initial;font-size: 1em\">%&gt;<\/span><\/p>\n<\/div>\n<div>\n<p><strong>\u00a0 \u00a0 \u00a0Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The output of the above code is shown below.<\/p>\n<\/div>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-324 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201.png\" alt=\"\" width=\"640\" height=\"212\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201.png 640w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201-300x99.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201-65x22.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201-225x75.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-201-350x116.png 350w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Database:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-323 aligncenter\" src=\"http:\/\/csp12.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200.png\" alt=\"\" width=\"627\" height=\"313\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200.png 627w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200-300x150.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200-65x32.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200-225x112.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-content\/uploads\/sites\/60\/2018\/07\/Untitled-200-350x175.png 350w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/p>\n<div>\n<p><strong>Summary<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In this section we discussed about how to install MySQL and run JSP pages in Tomcat. The module also explains about the operational views of how to Create table, Insert and Delete data in JDBC from JSP page illustrated with needed examples. Finally, this module also demonstrates a simple login Application created using JSP with JDBC.<\/p>\n<\/div>\n<p><strong>Web Links<\/strong><\/p>\n<ul>\n<li>Herbert Schildt, &#8221; <em>Java: The Complete Reference&#8221;, 9th Edition,<\/em> Mcgraw-Hill, 2014.<\/li>\n<li><em>https:\/\/www.tutorialspoint.com<\/em><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"author":4,"menu_order":31,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-m-vijayalakshmi"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-314","chapter","type-chapter","status-publish","hentry","contributor-dr-m-vijayalakshmi"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/users\/4"}],"version-history":[{"count":1,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/314\/revisions"}],"predecessor-version":[{"id":325,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/314\/revisions\/325"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapters\/314\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/media?parent=314"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/pressbooks\/v2\/chapter-type?post=314"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/contributor?post=314"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp12\/wp-json\/wp\/v2\/license?post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}