Hi,
Here is my code to login an User:

Servlet to log him in:
Code:
protected void doPost(HttpServletRequest request, HttpServletResponse response){
		// TODO Auto-generated method stub
		response.setContentType("text/html");
	    PrintWriter out;
		try {
			out = response.getWriter();
			String username = request.getParameter("main-login-username");
			String password = request.getParameter("main-login-password");
			User u =new User();
			if(u.isUsernameExists(username))
			{
				if(u.signIn(username, password, request))
				{
					out.println("YAAA");
					HttpSession session = request.getSession();
					UserData test = (UserData) session.getAttribute("userData"); 
					out.println(":"+(test==null));
					//login successful
					//response.sendRedirect("index.jsp");
				}
				else
					response.sendRedirect("index.jsp?logErr=Error%20in%20passoword");
			}
			else
			{
				response.sendRedirect("index.jsp?logErr=Error%20in%20username");
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			try {
				(response.getWriter()).println("Exception occured. Contact Admin");
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}
The Code to Sign him up.
Code:
public boolean signIn(String username,String password,HttpServletRequest request)
	{
		if(md5(password).equals(getPassword(username)))
		{
			UserData ans = new UserData();
			ans.populateData(username);
			HttpSession session = request.getSession();
			session.invalidate();
			if(session.isNew())
			{
				session.setMaxInactiveInterval(loginTimeOutTime);
				session.setAttribute("userData", ans);
			}
			return true;
		}
		return false;
	}
MY OUTPUT (for correct username/password combination)
YAAA
Now Where is my session variable going??? Its not displaying the username

Please help this is urgent

I have tested other codes and all my functions work correctly. I have tested them all... Only the session variable is missing here...