title: What is the right way to create a reusable yet flexible form component in JSP/Servlet?
body: <p>I'm making my first steps with JSP and servlets, and am building some toy project. I couldn't figure out the right approach to solve the following problem -</p>
  
  <p>In the user management part of the project, there are 3 occasions where user details can be updated:</p>
  
  <ol>
  <li>When the user registers to the site (empty registration form)</li>
  <li>When the user updates own details (form with existing details)</li>
  <li>When administrator updates user details (form with details and some additional options)</li>
  </ol>
  
  <p>I can think of 3 ways to create these pages:</p>
  
  <ol>
  <li>Create a different JSP file for each case, horribly violating the DRY law, but keeping HTML and logic apart.</li>
  <li>Have a servlet or custom tag generate the form's HTML, in the appropriate way. This means a lot (?) of HTML in the Java code.</li>
  <li>Place Java logic in a single JSP, which will take care of the form's content according to the context. This means a lot (?) of Java code in the JSP (mostly <code>if</code>s, omitting or including fields and values).</li>
  </ol>
  
  <p>What is the common way of solving these problems? </p>