Creating the JSP files
Our controller configuration references three JSP files: /WEB-INF/jsp/login.jspx, /WEB-INF/jsp/welcome.jspx and /WEB-INF/jsp/goodbye.jspx.
Login page
Our login JSP page contains the form used to submit the user's id and password. Here's the JSP document:
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:base="http://calyxo.odysseus.de/jsp/base"
version="2.0">
<jsp:directive.page contentType="text/html"/>
<base:access var="calyxo"/>
<html>
<head>
<title>Login page</title>
</head>
<body>
<h3>Login, please...</h3>
<base:form action="/login">
<table>
<tr>
<td align="right">User Id</td>
<td><input type="text" name="user"/></td>
</tr>
<tr>
<td align="right">Password</td>
<td><input type="password" name="password"/></td>
</tr>
</table>
<input type="submit" value="Submit"/>
</base:form>
<c:if test="${!empty calyxo.control.errors}">
<h3>Action errors</h3>
<ul>
<c:forEach var="message" items="${calyxo.control.errors.allMessages}">
<li>${calyxo.base.i18n.format[message]}</li>
</c:forEach>
</ul>
</c:if>
</body>
</html>
</jsp:root>
The page declares the JSTL core tag library with prefix c and the Calyxo Base tag library with prefix base. The tags from that library are:
- <base:access var="calyxo"/> This tag installs a hierarchy of accessors in request scope attribute calyxo, which can be used to navigate most of the Calyxo-related information. In our document, we use it to access and format our action error messages.
- <base:form action="/login">...</base:form> This tag is a wrapper for the HTML form tag. It takes an action path (within the current module) as an attribute. When rendered as HTML, it converts the action path to a context-relative path selecting that action.
Welcome page
Fortunately, the welcome JSP page is much shorter. It accesses the user name from session scope and provides a link to the logout action.
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:base="http://calyxo.odysseus.de/jsp/base"
version="2.0">
<jsp:directive.page contentType="text/html"/>
<base:access var="calyxo"/>
<html>
<head>
<title>Welcome page</title>
</head>
<body>
<h3>Welcome, ${user}!</h3>
Of cause, you can
<c:url var="href" value="${calyxo.base.module.path['/logout']}"/>
<a href="${href}">logout</a> again.
</body>
</html>
</jsp:root>
Again, this page uses the <base:access> tag. This time, it is used to construct a URL to point to the /logout action. The expression ${calyxo.base.module.path['/logout']} evaluates to the context-relative path of that action. For example, if our module uses extension mapping *.do, the result is /logout.do. If we used a prefix mapping like /main/*, the result would have been /main/login. Finally, the JSTL core <c:url> tag prepends the context name (and may do URL rewriting).
However, as shown in the logout page, there's an even easier way to link to actions using the <base:a> tag.
Goodbye page
The goodbye JSP page has nothing new. It just provides a link to login again.
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:base="http://calyxo.odysseus.de/jsp/base"
version="2.0">
<jsp:directive.page contentType="text/html"/>
<html>
<head>
<title>Goodbye page</title>
</head>
<body>
<h3>Goodbye!</h3>
Feel free to <base:a action="/index">login</base:a> again.
</body>
</html>
</jsp:root>
This time - as promised - we used Calyxo's <base:access> anchor tag to provide the link to our action.


