I Have a Login page which is a JSP and a servlet where i get the username from the Login page using request.getParameter. I now want to insert that username into a mysql DB using hibernate. In my hibernate program, how i can access the username???
My servlet is - public class LoginPage extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String username= request.getParameter("username");
System.out.println("Hi " + username);
}
}
and Hibernate program is-
public class HibernateTest {
public static void main(String args[]){
Login name = new Login();
name.setUserName("");//////This line shows error. What should be inside ""
SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(name);
session.getTransaction().commit();
session.close();
}
}
The marked line shows error when i run.What should be inside "". How can i retrieve username from the servlet???