I'm trying to connect jsp with mongodb for the project i am working currently but how do i check wether it is connected or not?
<%@page import="com.mongodb.*"%>
<%@page import="java.util.*" %>
<%
Mongo mongoClient = new Mongo("localhost" , 27017 );
DB db = mongoClient.getDB( "emp_record" );
DBCollection collection = db.getCollection("emp");
out.println("Connected to database successfullys");
out.println(collection);
%>
How do i get data from db for this login html code?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JSP Connection</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="mongoDbServlet" class="container">
<h1 align="center" class="text-primary">JSP Connection</h1>
<hr />
<div id="login_form">
<form id="collection" name="loginForm" method="post" action="test1.jsp">
<!----- LOGIN FORM ------>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" class="form-control" id="login_id" placeholder="Enter login id ..." name="login_id" maxlength="6">
</div>
<div> </div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" class="form-control" id="login_pwd" placeholder="Enter password ..." name="login_pwd">
</div>
<div> </div>
<button id="submit_btn" type="submit" class="btn btn-primary">Confirm</button>
</form>
</div>
<h4 id="errMsg" class="text-danger" align="center">${error_message}</h4>
</div>
</body>
</html>