Discussions

Web tier: servlets, JSP, Web frameworks: JSTL helps needed

  1. JSTL helps needed (2 messages)

    Hello,

    Can anyone plz tell me how to convert follwing piece of JSP code into JSTL

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core_rt" prefix="c_rt" %>



    <%
    String sUserName= (String)session.getAttribute("userName");
    if (sUserName != null)
    {
    %>

    The above part is all right I implemented using

    <c_rt:if test= "${sessionScope.userName != null}">


    <%
    } // this can be replaced by </c_rt:if>
    else{
    %>



    <%
    }
    %>



    Now my question is, how one can replace the else related part from my JSP, plz help me.
    Ciao
    RD

    Threaded Messages (2)

  2. JSTL helps needed[ Go to top ]

    How about:
    <c:if test="${empty sessionScope.userName}">
  3. use <c:choose>[ Go to top ]

    <c:choose>
      <c:when test="${sessionScope.userName != null}">
           <!-- your code -->
      </c:when>
      <c:otherwise>
          <!-- else part code -->
      </c:otherwise>
    </c:choose>