Sunday, March 7, 2021

Java JSP program to display account holder's details in a bank having a balance greater than 50,000/-

 //JSP file

<%-- 

    Document   : Bankjsp

    Created on : 19 Mar, 2020, 12:04:04 PM

    Author     : ashu

--%>

<%@ page import="java.io.*,java.util.*,java.sql.*"%>

<%@ page import="javax.servlet.http.*,javax.servlet.*" %>

<%@ page import="java.math.*"%>

<%@ page import="java.sql.Connection"%>

<%@ page import="java.sql.DriverManager"%>

<%@ page import="java.sql.ResultSet"%>

<%@ page import="java.sql.SQLException"%>

<%@ page import="java.sql.Statement"%>

<%@ page language="java"%>

<%@ page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

    <head>

        <title>Real Bank JSP Page</title>

    </head>

    <body>

    <center>

        <h1>Welcome to Real Bank!</h1>

        <h3>Customers with balance greater than Rs.5000/- in SB a/c </h3>

        

        <%

            try {

            String connectionURL = "jdbc:mysql://localhost/bank";

            Class.forName("com.mysql.jdbc.Driver").newInstance(); 

            Connection con = DriverManager.getConnection(connectionURL, "root", "ashutosh");

            if(con.isClosed()){

                 out.println("Successfully connected to " + "MySQL server using TCP/IP...");

            }

            Statement stmt = con.createStatement();

            ResultSet rs = stmt.executeQuery("select customerName, customerAddress, accountNum from customers where accountType='SB' and balance >= 5000.00;");

            %>

            <table border=1>

            <tr><th>Name</th><th>Address</th><th>Account Number</th></tr>

            <%

            while(rs.next()){

            %>

            <tr>

            <td><%=rs.getString(1)%></td>

            <td><%=rs.getString(2)%></td>

            <td><%=rs.getInt(3)%></td>

            </tr>

        <%   

        }

        rs.close();

        stmt.close();

        con.close();

        }catch(Exception ex){

            out.println("Unable to connect to database"+ex);

        }   

        %>

        

    </center>

    </body>

</html>

---------------------------------------------------------------------------------------------------

//Corresponding HTML file

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>Real Bank</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <center><h1>Welcome to Real Bank!</h1>
        <h2>You can bank with us for best returns and services</h2>
    <div><a href="Bank.jsp">Details of customers having greater than equal to Rs.5000/- in savings account</a></div>
    </center>
        
    </body>
</html>

----------------------------------------------------------------------------------------------------


Java Servlet program to fetch book details in a library

//The 'books.java' servlet file.

 package Library;


import java.io.IOException;

import java.io.PrintWriter; 

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import java.math.* ; // for BigDecimal and BigInteger support

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

/**

 *

 * @author ashu

 */

public class books extends HttpServlet {


    /**

     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>

     * methods.

     *

     * @param request servlet request

     * @param response servlet response

     * @throws ServletException if a servlet-specific error occurs

     * @throws IOException if an I/O error occurs

     */

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        response.setContentType("text/html;charset=UTF-8");

        PrintWriter out = response.getWriter();

    try{

        out.println("<html>");

        out.println("<head><title>Servlet JDBC</title></head>");

        out.println("<body>");

        // connecting to database

        Class.forName("com.mysql.jdbc.Driver");

        Connection con =DriverManager.getConnection ("jdbc:mysql://localhost/dbmsbooks","root","ashutosh");

        Statement stmt = con.createStatement();

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

        // displaying records

        out.println("<center>");

        out.println("<h1>IGNOU RC Varanasi website</h1>");

        out.println("<h2>"+"Following is the details of the books available in library related to DBMS: "+"</h2>");

        out.println("<table border=1>");

        out.println("<tr><th>BookID</th><th>Title</th><th>Authors</th><th>Publication</th><th>Availability</th></tr>");

        while(rs.next()){

            out.println("<tr>");

            out.println("<td>"+rs.getInt(1)+"</td>"+

                        "<td>"+rs.getString(2)+"</td>"+

                        "<td>"+rs.getString(3)+"</td>"+

                        "<td>"+rs.getString(4)+"</td>"+

                        "<td>"+rs.getString(5)+"</td>");

            out.println("</tr>");

        }

        out.println("</center></body></html>");  

  } catch (SQLException e) {

 throw new ServletException("Servlet Could not display records.", e);

  } catch (ClassNotFoundException e) {

  throw new ServletException("JDBC Driver not found.", e);

  } 

  out.close();

  }

        



    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">

    /**

     * Handles the HTTP <code>GET</code> method.

     *

     * @param request servlet request

     * @param response servlet response

     * @throws ServletException if a servlet-specific error occurs

     * @throws IOException if an I/O error occurs

     */

    @Override

    protected void doGet(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        processRequest(request, response);

    }


    /**

     * Handles the HTTP <code>POST</code> method.

     *

     * @param request servlet request

     * @param response servlet response

     * @throws ServletException if a servlet-specific error occurs

     * @throws IOException if an I/O error occurs

     */

    @Override

    protected void doPost(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        processRequest(request, response);

    }


    /**

     * Returns a short description of the servlet.

     *

     * @return a String containing servlet description

     */

    @Override

    public String getServletInfo() {

        return "Short description";

    }// </editor-fold>


}

-----------------------------------------------------------------------------------------
//The corresponding HTML file

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        
    <center>
        <h1>Welcome to the IGNOU RC Varanasi website</h1>
        <h3>Here you can have all information about counselling classes and library books</h3>

<!-- books.java is the servlet file which should get executed/invoked once below link is clicked, -->
        <div>For books availability in the library <a href="books">click here</a></div>
    </center>
    </body>
</html>

-----------------------------------------------------------------------------------------------

//Coresponding XML file

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>books</servlet-name>
        <servlet-class>Library.books</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>books</servlet-name>
        <url-pattern>/books</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>


Tuesday, March 2, 2021

Subjects learnt in my 3 years MCA programme at IGNOU from 15 April 2018 to 15 April 2021.

Things that I learned in my MCA from IGNOU completing June 2021.


Total 23 theory papers (subjects):


My favorite subjects (strengths)


1 MCS011 Programming languages like C, C++, Java, JavaScript, Python etc.

2 MCS013 Discrete Mathematics

3 MCS014 SAD (System Analysis & Design)

4 MCSL017 Web Development

5 MCS021 DSA (Data Structures & Algorithms)

6 MCS023 DBMS (Database Management Systems)

7 MCS031 DAA (Design & Analysis of Algorithms)

8 MCS032 OOAD (Object-Oriented Analysis & Design)

9 MCS033 ADM (Advanced Discrete Mathematics)

10 MCS034 Software Engineering

11 MCS041 Operating Systems

12 MCS043 Advanced DBMS



Other subjects


13 MCS012 Computer Organization & Architecture

14 MCS015 Business Communication

15 MCS022 Computer Networks

16 MCS024 Java programming

17 MCS042 Advanced Computer Networks & Data Security

18 MCS051 Advanced Java

19 MCS052 Computer Graphics

20 MCS053 MIS (Management Information Systems)

21 MCSE003 AI (Artificial Intelligence)

22 MCSE004 NSC (Numerical & Statistical Computing)

23 MCSE011 PP (Parallel Programming aka Super Computing)

I am interested more in

Python
Data Structures
Algorithms
DBMS
Web development

Django web framework

 Video tutorial https://www.youtube.com/watch?v=F5mRW0jo-U4

Django E-commerce project

 Shopping cart video tutorial https://www.youtube.com/watch?v=I6rR3Se72BU

Advanced Java Spring Boot project

 Here it is https://www.youtube.com/watch?v=TanJlGUbWNc

Basic Flask web app

 from flask import Flask app = Flask(__name__) #In Flask, URL rules can be added using either the @app.route() decorator or the app.add_url_...