tags:

views:

316

answers:

2

I have the following in my jsp page (assume that client is an object )

<%
 if( client == null)
 %>
NO client
 <% 
 else
%>
<a href='page.jsp?aid=<%=client.getID()%>'> and his name is  <%=client.getName()%>

thanks

+2  A: 

You're missing the brackets:

<% if( client == null) {  %>
NO client
<% } else { %>
<a href='page.jsp?aid=<%=client.getID()%>'> and his name is  <%=client.getName()%>
<% } %>

That said, this is an example of bad JSP code. Consider using JSTL tags / expressions instead of scriptlets.

ChssPly76
+2  A: 

in jstl it would be something similar to

<c:choose>
  <c:when test="${client is null}">
NO client
  </c:when>
<c:otherwise>
  <A href="<c:url value="page.jsp" >
 <c:param name="aid" value="${client.ID}" />
           </c:url>" 
  > and his name is <c:out value="${client.name}"/>
</c:otherwise>

Peter