title: Disable button in jsp depending on the method return
body: <p>I have method which checking DB if user is applied to course
  if he has already applied, then the button is disabled</p>
  <p>Method which checking isStudentApplied to Course</p>
  <pre><code>public static boolean isStudentRegisteredToCourse(Student student, CourseDTO course){
          String query = &quot;SELECT EXISTS(SELECT student_of_course.student_id, student_of_course.course_id FROM student_of_course WHERE student_of_course.student_id = ? AND student_of_course.course_id=?);&quot;;
          ResultSet rs;
          int result;
          try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {
              preparedStatement.setInt(1, student.getId());
              preparedStatement.setInt(2,course.getId());
              rs = preparedStatement.executeQuery();
              while (rs.next()){
                  result=rs.getInt(1);
                  if(result==1)
                      return true;
              }
          } catch (SQLException e) {
              System.out.println(e);
          }
          return false;
      }
  </code></pre>
  <p>Servlet Method which working with sessions</p>
  <pre><code>public class CourseServlet extends javax.servlet.http.HttpServlet {
  
      protected void doPost(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response) throws ServletException, IOException {
          String action = request.getParameter(&quot;action&quot;);
          if(&quot;register&quot;.equals(action)){
              HttpSession session = request.getSession();
              Account account = (Account)session.getAttribute(&quot;loguser&quot;);
              CourseDTO courseDTO = (CourseDTO) session.getAttribute(&quot;courseDTO&quot;);
              Student student = AccountDAO.getStudentByAccountId(account);
              CourseDAO.setCourseForUser(student,courseDTO);
              request.getRequestDispatcher(&quot;/course.jsp&quot;).forward(request, response);
          }
      }
  </code></pre>
  <p>jsp</p>
  <pre><code>&lt;form  action=&quot;course&quot; method=&quot;post&quot;&gt;
      &lt;dl&gt;
          &lt;dt&gt;progress&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.progress}&lt;/dd&gt;
          &lt;dt&gt;theme&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.theme_name}&lt;/dd&gt;
          &lt;dt&gt;description&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.description}&lt;/dd&gt;
          &lt;dt&gt;teacherName&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.teacherName}&lt;/dd&gt;
          &lt;dt&gt;duration&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.duration}&lt;/dd&gt;
          &lt;dt&gt;quantity&lt;/dt&gt;
          &lt;dd&gt;${courseDTO.quantity}&lt;/dd&gt;
      &lt;dd&gt;&lt;button name=&quot;action&quot; value=&quot;register&quot;&gt;Register&lt;/button&gt;&lt;/dd&gt;
  &lt;/dl&gt;
  &lt;/form&gt;
  </code></pre>
  <p>so i wanna check is user applied to course, if he is, then <code>&lt;button name=&quot;action&quot; value=&quot;register&quot;&gt;Register&lt;/button&gt;</code> becomes <code>disabled</code>
  How it possible to do?</p>