I have a java Constant.java file in which I defined session var name like this :
package com.pakageName;
public class Config {
// name of sessions var
public static final String ATT_SESSION_USER = "session_user";
public static final String ATT_SESSION_MESSAGE = "session_message";
...
}
In Servlet file, I use the following to define session var :
session.setAttribute(Constant.ATT_SESSION_MESSAGE, "this is the content of the var I wan't to display on the page");
The Constant.java file is included in my jsp file using :
<%@ page import="com.pakageName.Config" %>
So I'm able to get the content of sessionScope var with :
// get the content of the session var
${sessionScope[Constant.ATT_SESSION_MESSAGE]}
// which return the same result as
${sessionScope.session_message}
The question is, how can I remove those session var using remove tag with Constant var value ?
I've tried the following but var attribute doesn't accept el expression ...
// throw exception because var attribute doesn't accept el
<c:remove var="${sessionScope[Constant.ATT_SESSION_MESSAGE]}" scope="session" />
<c:remove var="${Constant.ATT_SESSION_MESSAGE}" scope="session" />
// don't remove anything
<c:remove var="Constant.ATT_SESSION_MESSAGE" />
// work but the name is hard coded
<c:remove var="session_message" scope="session" />
Any idea ?
<c:remove var="Constant.ATT_SESSION_MESSAGE" scope="session" />? - Alan Hay