Archive for the ‘Programming’ Category

For my web application project using ASP.NET MVC3 (C#), here is the list of my free favorite extensions:

  1. Indent Guides
  2. Javascript parser
  3. JScript Brace Matching Extension
  4. JScript Editor Extension
  5. JScript Outlining Extension
  6. JScript Word Highlighter Extension
  7. NuGet Package Manager
  8. Productivity Power Tools
  9. Spell Checker
  10. SQL Server Developer Tools, Codename “Juneau”
  11. VSCommands 2010
  12. Power Commands For Visual Studio 2010
  13. Web Standards Update for Microsoft Visual Studio 2010
  14. CSS 3 Intellisense Schema
  15. SQL Server Compact Toolbox
  16. ADO.NET C# POCO Entity Generator
  17. ReGex Editor (But somewhat buggy)

If you happen to reach this page, chance are you are facing what I just faced several minutes ago. Scratching my head to follow some programming book instruction (read: instruct me to add ninject by ‘Add Library Package Manager’ where I couldn’t find it).

I am not really sure what have changed between the author’s VS2010 and my current version. The fact is, ‘Add Library Package Manager’ somehow is not visible at my IDE. After several minutes of try and error, I manage to install Ninject by doing these steps:

  1. Right click on your project’s Reference in the Solution Explorer.
  2. Select Manage NuGet Packages.
  3. Click Online on the left side of the dialog.
  4. Search Ninject.
  5. Click Install button.
  6. Click on ‘I Accept‘ button.
  7. Done…. 😀

Note 1: Ninject can’t be added directly to Visual Studio in global manner due to its dependency on your project’s .NET version. Therefore, it has to be added on project basis.

Note 2: If your project has some compiling issue or problem, make sure your project use .NET framework version 4.

  • Select project properties mkenu item under the Project Menu
  • Change the Target Framework setting to .NET framework 4

Servlet :

package com.arham.servlet;



import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import java.sql.SQLException;

public class logincheck extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

String username = request.getParameter(“username”).toString();

String password = request.getParameter(“password”).toString();

Connection connection = null;

try {

String driverName = “”; // MySQL MM JDBC driver


String serverName = “localhost”;

String mydatabase = “arhamjava”;

String url = “jdbc:mysql://” + serverName + “/” + mydatabase; // a JDBC url

String sqlusername = “root”;

String sqlpassword = “MyP@SsW0rD”;

connection = DriverManager.getConnection(url, sqlusername, sqlpassword);


catch (ClassNotFoundException e) {

// Could not find the database driver


catch (SQLException e) {

// Could not connect to the database


Statement stmt = null;

ResultSet rs = null;

String checkUsername = null;

String checkPassword = null;

int checkAccessPower = 0;



stmt = connection.createStatement();

rs = stmt.executeQuery(“SELECT username, password, accesspower FROM account WHERE username = ‘” + username + “‘ AND id > 0”);

PrintWriter out2 = response.getWriter();



checkUsername = rs.getString(“username”);

checkPassword = rs.getString(“password”);

checkAccessPower = rs.getInt(“accesspower”);


if(checkUsername != null)




out2.println(“Welcome ” + username + “<br/> <h2>Login Success</h2>”);

if(checkAccessPower > 150)

out2.println(“Status : ADMIN”);

else if (checkAccessPower > 50)

out2.println(“Status : Normal User”);

else if (checkAccessPower < 9)

out2.println(“You have been banned by admin. Contact your administrator for clarification”);



out2.println(“<h1>Login Fail</h1> <br/> Click back to relogin!”);



out2.println(“<h2>Login Fail</h2> <br/> Reason : Your username not exist in our database.”);


catch (SQLException ex)


// handle any errors

System.out.println(“SQLException: ” + ex.getMessage());

System.out.println(“SQLState: ” + ex.getSQLState());

System.out.println(“VendorError: ” + ex.getErrorCode());



PrintWriter out = response.getWriter();

try {



out.println(“<title>Servlet Login Check </title>”);





} finally





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


protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

processRequest(request, response);



protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

processRequest(request, response);



public String getServletInfo() {

return “Short description”;

}// </editor-fold>