|
@@ -80,16 +80,18 @@ include::hello-includes/exploring-the-secured-application.asc[]
|
|
|
|
|
|
==== Displaying the user name
|
|
|
|
|
|
-Now that we have authenticated, let's update the application to display the username. Update main.jsp to contain the following snippet:
|
|
|
+Now that we have authenticated, let's update the application to display the username if the user is authenticated. Update main.jsp to contain the following snippet:
|
|
|
|
|
|
.src/main/webapp/WEB-INF/decorators/main.jsp
|
|
|
[source,html]
|
|
|
[subs="verbatim,quotes"]
|
|
|
----
|
|
|
<div class="nav-collapse collapse">
|
|
|
- *<p class="navbar-text pull-right">
|
|
|
- <c:out value="${pageContext.request.remoteUser}"/>
|
|
|
- </p>*
|
|
|
+ *<c:if test="${pageContext.request.remoteUser != null}">
|
|
|
+ <p class="navbar-text pull-right">
|
|
|
+ <c:out value="${pageContext.request.remoteUser}"/>
|
|
|
+ </p>
|
|
|
+ </c:if>*
|
|
|
<ul class="nav">
|
|
|
<c:url var="inboxUrl" value="/"/>
|
|
|
<li><a href="${inboxUrl}">Inbox</a></li>
|
|
@@ -112,10 +114,12 @@ Now that we can view the user name, let's update the application to allow loggin
|
|
|
[subs="verbatim,quotes"]
|
|
|
----
|
|
|
<div class="nav-collapse collapse">
|
|
|
- *<c:url var="logoutUrl" value="/logout"/>
|
|
|
- <form:form class="navbar-form pull-right" action="${logoutUrl}" method="post">
|
|
|
- <input type="submit" value="Log out" />
|
|
|
- </form:form>*
|
|
|
+ *<c:if test="${pageContext.request.remoteUser != null}">
|
|
|
+ <c:url var="logoutUrl" value="/logout"/>
|
|
|
+ <form:form class="navbar-form pull-right" action="${logoutUrl}" method="post">
|
|
|
+ <input type="submit" value="Log out" />
|
|
|
+ </form:form>
|
|
|
+ </c:if>*
|
|
|
<p class="navbar-text pull-right">
|
|
|
<c:out value="${pageContext.request.remoteUser}"/>
|
|
|
</p>
|