03hasnam 0 Junior Poster in Training

Hey Everyone, i cannot print the value of Username in the JSP. i am using a java bean, but i am instiating the bean object twice in two servlet, one for form data and one for username. the bean contains the respective setUsername and getUsername, but this is not printing in jsp. please help me print the username. thanks

SERVLET ONE

BookingBean db;  //instantiate 
        
        HttpSession session = request.getSession();
        if(!session.isNew()){
      
            db = new BookingBean();
            db.setRandom();
            db.setAdult(adults);
            db.setChildren(children);
            db.setOap(oap);
            db.setEmail(email);
            db.setDate(date);
            db.setLocation(loc);
            db.setPromo(promo);
            db.setTime(time);
            db.setfirstName(firstName);
            db.setsurName(surname);
            db.setTotal();
            session.setAttribute("formData", db);
            
                      
        } 
        
        db = (BookingBean)session.getAttribute("formData");
.........

SERVLET TWO

if(userPassword!=null && userPassword.equals(password)) {
     
       HttpSession session = request.getSession();
       BookingBean db = (BookingBean)session.getAttribute("formData"); //use existing session
       if(db == null) {
       db = new BookingBean(); }

       db.setUsername(username);
       session.setAttribute("formData", db);
      getServletContext().getRequestDispatcher("/BookingForm.jsp").forward(request, response);
        } else {

......

JSP

<jsp:useBean id="formData" class="bean.BookingBean" scope ="session">
       
        </jsp:useBean>
       
        <%BookingBean username = (BookingBean)session.getAttribute("formData");
            if(username==null)  {
                            // if session is expired, forward it to login page
               
         %>
         <jsp:forward page="Login.jsp" />
        <%}%>
            
        <p>Confirmation of Booking for the following user: <%=formData.getUsername()%><p><br><br>