views:

55

answers:

1

I found this example in the App Engine documentation.

   1 <%
   2  UserService userService = UserServiceFactory.getUserService();
   3  if (!userService.isUserLoggedIn()) {
   4 %>
   5  Please <a href="<%=userService.createLoginURL("/newlogin.jsp")>">log in</a>>
   6 <% } else { %>
   7  Welcome, <%= userService.getCurrentUser().getNickname(); %>!
   8    (<a href="<%=userService.createLogoutURL("/")>">log out</a>>)
   9  <%
   10 }
   11 %>

Regarding the </a>> at the end of line 5 and line 8: Is that a typo?

If not, why is it supposed to be </a>> instead of </a> - which is what I expect.

+2  A: 

That's indeed syntactically invalid. I don't think that it's a typo, it's likely just incorrect use of javadoc. HTML entities in javadocs needs to be manually escaped/encoded and this is often overlooked. I also see that scriptlets aren't properly closed. Here is the fixed version:

<%
   UserService userService = UserServiceFactory.getUserService();
   if (!userService.isUserLoggedIn()) {
%>
      Please <a href="<%= userService.createLoginURL("/newlogin.jsp") %>">log in</a>
<% } else { %>
      Welcome, <%= userService.getCurrentUser().getNickname(); %>!
         (<a href="<%= userService.createLogoutURL("/") %>">log out</a>)
<%
   }
%>

Ugly code by the way. I would just have used a Filter and/or a shot of JSTL/EL for this. But that's maybe beyond the capabilities of Google App Engine. Never used it.

BalusC