Struts tiles and logic


Web tier: servlets, JSP, Web frameworks: Struts tiles and logic

  1. Struts tiles and logic (2 messages)


    i have problems to implement some logic in my struts tiles template.

    I want, that different tiles are loaded, depending on the user login status.


    <tiles:definition id="news" page="Layout.jsp">
    <tiles:put name="head" value="/view/header.jsp" />

    <-- Need logic here, to decide if a user is logged in to load the specific tile

    <tiles:put name="login" value="/view/login.jsp" />
    <tiles:put name="login" value="/user/userlogged.jsp" />
    <tiles:put name="login" value="/admin/adminlogged.jsp" />


    <tiles:put name="body" value="/view/body.jsp" />
    <tiles:put name="content" value="/view/news.jsp" />
    <tiles:put name="foot" value="/view/footer.jsp" />

    This code is only an example to illustrate my problem. Every suggestion to solve this problem is welcome!



    Threaded Messages (2)

  2. Struts tiles and logic[ Go to top ]

    What we are doing is using a filter servlet that looks to see if a user is logged in and if their session has expired.
  3. RE:[ Go to top ]

    You could surround your <tiles:insert> tags with <c:if> tags that check for a page, request or session scoped variable that is set by your app when the user has logged in. This would be done on the actual jsp that contains the layout instead of your tiles xml file.