title: Using JSP C Tag within AngularJS code
body: <p>Note: I am modifying this post, after I gained more experience working with Angular and Java. This is to avoid posting a new question.</p>
  
  <p>Over the past few months, working with different models to implement reusable AngularJS parts within a JSP code, finally decided to use the jsp include directive <code>&lt;%@include file="form-part.jsp" %&gt;</code>. This works well, and the only issue now is readability problem when using <a href="http://www.javatpoint.com/jstl-core-set-tag" rel="nofollow noreferrer">C Tags</a>.</p>
  
  <p>For example, the variables are defined in Eclipse resource file as follows:</p>
  
  <h1>Resource File (.properties):</h1>
  
  <pre><code>formhtml5.jsp.photoSubjectFront=Subject Front
  formhtml5.jsp.photoSubjectStreet=Subject Street
  formhtml5.jsp.photoSubjectRear=Subject Rear
  </code></pre>
  
  <p>Then, in order to use the above variables in Angular, one way I found is as follows (since you must use the variable name inside the JSP file):</p>
  
  <h1>HTML in JSP File</h1>
  
  <pre><code>&lt;fmt:message key="formhtml5.jsp.photoSubjectFront" scope="request" var="photoSubjectFront"/&gt;
  &lt;fmt:message key="formhtml5.jsp.photoSubjectStreet" scope="request" var="photoSubjectStreet"/&gt;
  &lt;fmt:message key="formhtml5.jsp.photoSubjectRear" scope="request" var="photoSubjectRear"/&gt;
  ...
  ...
  &lt;div class="photos-container" 
      ng-init="subjectPhotos =
                              [{fieldName:'subject_front',
                                title:'${photoSubjectFront}'},
                               {fieldName: 'subject_street',
                                title: '${photoSubjectStreet}'},
                               {fieldName: ''subject_rear,
                                title: '${photoSubjectRear}'}
                              ]"&gt;
  ...
  ...
  &lt;/div&gt;
  </code></pre>
  
  <p>If you notice, the above HTML code block is not very readable.</p>
  
  <p>What is the best way to initialize the array <code>subjectPhotos</code> scope variable and use the JSP variable <code>${photoSubjectFront}</code> in the initialization?</p>
  
  <p>I was thinking if I can do that in a <code>&lt;script&gt;</code> block which is much more readable, but I was not sure to access the scope variable inside a normal script block.</p>
  
  <p>Appreciate your feedback.</p>
  
  <h1>Old Post:</h1>
  
  <p>I've been developing forms based applications using Angular for the past 3-4 months. I am preparing to move into next stage so that I can convert the developed form (HTML5 + Script) into reusable components or parts. The development was done using Eclipse, Java (JSP+Servlets) and of course, HTML5, JavaScript (Angular) and CSS.</p>
  
  <p>In the past, I've done that successfully using ASP.NET, Master Pages and User Controls.</p>
  
  <p>What I am looking for is a way to create modular and reusable form parts for both HTML5 and Code so that they can be easily reused in another form that has the same part with probably minor changes in layout and logic.</p>
  
  <p>I am currently doing that but only for code. I managed to develop Angular Directives, Services, and Controllers which are actually working up to my expectations in terms reusability. The only issue now is how to make the HTML5 (layout) also reusable.</p>
  
  <p>I've done some research and I can list some options:</p>
  
  <ol>
  <li><p>Use Java based framework which is similar to that of ASP.NET Master Pages. I've found several options.</p></li>
  <li><p>Use Angular directives and templates. The problem here is that you have to compose a very long string which will represent the HTML part. It think this is confusing. I hope there is a way to save the reusable HTML part in a separate file and include it in the directive or something like that.</p></li>
  <li><p>Use JSP to develop the reusable part, and include it in the main form. I can use the jsp include directive <code>&lt;%@include file="form-part.jsp" %&gt;</code> to include the reusable form part.</p></li>
  </ol>
  
  <p>I am evaluating the possible options to select the most appropriate one.</p>
  
  <p>I hope you can point me to some sample or tutorial that will help me achieve this requirement.</p>
  
  <p>Note: I found good <a href="https://youtu.be/7LXN0MzmDsc" rel="nofollow noreferrer">tutorial</a> which will be an excellent start.</p>
  
  <p>Appreciate your feedback.</p>
  
  <p>Tarek</p>