Servlet Ders10 - HttpSession
Session sunucu tarafında saklanan istemciye ait bilgilerdir.Session istemcilerin birbirinden ayırt edilebilmesi için kullanılır. Ön Bilgi //session nesnesi oluşturma HttpSession session=request.getSession(); //session nesnesinin x attributeüne y değerini verme session.setAttribute("x", "y"); //daha önces oluşturulan session nesnesini alma //false değeri daha önce oluşturulan nesne yoksa //yeniden nesne oluşturmasını engeller. HttpSession session=request.getSession(false); //x isimli attribute değerini alma String x=(String) session.getAttribute("x"); index.html <!DOCTYPE html> <html> <head> <meta charset= "UTF-8" > <title> index.html </title> </head> <body> <form action= "Servlet" > Ad <br/> <input type= "text" name= "ad" /><br/><br/> <input type= "submit" value= "gonder" />