top of page

In this hands-on you have to create a Login Servlet that accepts user email and password and display a welcome message using a Welcome Servlet if the user details are present in the database.

Solution Code -


package com.fresco.login;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

public class DbConnection {


            public static Connection getConnection() {

        Connection con = null;

                        try {

                                    con = DriverManager.getConnection("jdbc:h2:mem:testdb", "sa", "");

                        } catch (SQLException e) {



        return con;



            public static void closeConnection(Connection con) {

                        try {


                        } catch (Exception e) {






import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;



For complete Solution please Purchase the solution.

TCS HackerRank Java Developer JSP,Servlet Solution

$40.00 Regular Price
$30.00Sale Price
  • Solution is given in PDF file. You will Get all the required code in Java to qualify your exam with 100% security.

bottom of page