JSP Examples
JSP, or Java Server Pages, is a view technology for servlets. You can find tutorials and documentation all over the place, for example this tutorial or this reference
Some code snippets:
Expressions and Scriptlets (these are generally bad style)
The time is now <%= new Date() %>
<% for (int i = 0; i < 5; ++i) { %>
A circle with radius <%= i %> has area <%= i * i * 3.141592 %>
<br/>
<% } %>
</table>
You also have access to variables like pageContext, request, response, and session.
Custom Tag Libraries and JSTL-EL
JSTL Expression Language lets you write expressions between ${ and }. You can do standard math expressions, and you can reference bean properties like ${person.gender}, list elements like ${patients2}, map elements like ${map'key'}.
The "core" tag library is defined in c-rt.tld in your openmrs project or documented here. It includes tags like:
<c:forEach ...>
<c:if ...>
<c:set ...>
The core functions are defined in fn.tld in your openmrs project, and also documented here. It includes functions like length, contains, replace, substring, ...
The radius example from earlier:
<c:forEach var="i" begin="0" end="5">
A circle with radius ${ i } has area ${ i * i * 3.141592 }
<br/>
</c:forEach>
A more interesting example of more tags:
There are ${fn:length(patients)} patients.
<c:forEach var="p" items="${patients}">
<br/>
${p.personName} was born on <openmrs:formatDate date="${p.birthdate}"/>
<c:if test="${p.gender == 'M'}">
Yo, dude.
</c:if>
<c:if test="${p.gender == 'F'}">
Pleased to meet you.
</c:if>
</c:forEach>
Note that you can write your own tag libraries, like openmrs:formatDate. Look at openmrs.tld in the openmrs project, or the htmlwidgets module for an example of how to do this in a module.