well, i have written this code for the problem give below. Plz help me to bring high quality to this i.e use of Hungarian Notation and commnts as required in the problem given below:
Problem:
Writing a maintainable code makes the product with High Quality. Here you are given a scenario where you have to write a maintainable code for the given problem.
Scenario:
Virtual Solutions is an IT solution provider company. It has hired you as a Software Engineer. Your job is to write code, but at the same it should be of High Quality. Your Team Lead has asked you to write a very small code of user login functionality. The code should be of High Quality.
You are required to
a. Write correct code for the user login in Java or C++
b. Make use of Hungarian Notation for coding purpose
c. Make use of Comments in the Code where required necessary.
code
<html>
<head>
<title>Khalid Mahmood </title>
</head>
<body>
<br>
<p> <h3><center>Please enter your user name and
password</center></h3></p>
<br>
<br>
<form action="process2.jsp " method = "post" >
<center>username</center>
<center><input type = "text" name=
"username"></center>
<center>password</center>
<center><input type = "password" name =
"password"></center>
<center><input type="submit" name="Submit"
value="Login"></center>
</form>
</body>
</html>
<%@ page import="java.util.*" %>
<jsp:useBean id="idHandler" class="foo.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>
<%
if (idHandler.validate()) {
%>
<jsp:forward page="success.jsp"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>
package foo;
import java.sql.*;
public class Login {
private String username = "";
private String password = "";
public Login() {
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public boolean authenticate(String username2,
String password2) {
String query="select * from Registration;";
String DbUserName="";
String DbPassword="";
String finalUser="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:register");
Statement stat=con.createStatement();
ResultSet rst=stat.executeQuery(query);
while(rst.next())
{
DbUserName=rst.getString("UserName");
DbPassword=rst.getString("password");
if (username2.equals(DbUserName) &&
password2.equals(DbPassword)) {
break;
}
}
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}}