jfsd skill 5 question 1 task 1

Published on September 02, 2021
Last updated September 02, 2021

Using JSP Concepts try to execute the following scenario


Create a table in the database containing the columns to store book details like book name, authors, description, price, and URL (Uniform Resource Locator) of the book’s cover image. Using JSP (Java Server Pages) and JDBC retrieve the details in the table and display them on the webpage.

Video explaining the code and process in telugu language

Create book table in database

The following sql query will create a table called skill5books which contains our books data

CREATE TABLE skill5books(
    book_name VARCHAR(26) NOT NULL, 
    author VARCHAR(26) NOT NULL, 
    description VARCHAR(255) NOT NULL, 
    price NUMBER NOT NULL, 
    cover_image_url VARCHAR(255) NOT NULL);

After the table has been created in the database insert some books data into the table.

SQL command to insert data into table

INSERT INTO skill5books (book_name, author, description, price, cover_image_url) VALUES ('Harry Potter', 'J K Rowling', 'magic', 226, 'https://anreddy.in/harry.png');


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>Skill 5 question 1</title>
table, th, td {
  border:1px solid black;

	String dbUserName = "system";

	String dbUserPassword = "nikhil4u";

	Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", dbUserName, dbUserPassword);

	Statement stmt = con.createStatement();

	ResultSet rs = stmt.executeQuery("SELECT * FROM skill5books");

	if (!rs.isBeforeFirst()) {
		out.println("No books available please add one");
	} else {
	<table style="width:100%">
				<h2>Book name</h2>

				<h2>Cover Image url</h2>
		while (rs.next()) {




			<td><a href="#">Add to cart</a></td>

Tags :