mercredi 21 mars 2018

i want to store multiple check boxes values in database using JSP in single column of database but single value in single row.

public class NewServlet extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use following sample code. */
        String Patid = request.getParameter("patientid");
        String name1 = request.getParameter("myname");
        String [] checkbok = request.getParameterValues("lang");

        for (int i = 0; i < checkbok.length; i++) 
         {
           out.println("<h1>" + checkbok[i] + "</h1>");
         }

        System.out.println(Patid+name1+checkbok[1]);
        Configuration cf = new Configuration();
        cf.configure("hibernate.cfg.xml");
        SessionFactory sf = cf.buildSessionFactory();
        Session s = sf.openSession();
        Transaction t = s.beginTransaction();
        Checkb vis = new Checkb(Patid, name1, checkbok);

        s.save(vis);
        t.commit();
        s.close();
        sf.close();

        RequestDispatcher rd = request.getRequestDispatcher("login.html");
        rd.forward(request, response);

**what is the error , i cant get value in back end please help me anyone here how to store and retrieve using jsp and servlet **




Aucun commentaire:

Enregistrer un commentaire