Okay, so basically I have an enum:
public enum A {
A, B, C, D;
public static final Collection<String> displayColl = createDisplay();
private static Collection<String> createDisplay() {
// Convert enum to acceptable String display magic here...
return ImmutableCollection.copyOf(string collection);
}
}
I would like to access this collection on a JSP as menu options. I have the following four options, and would like to know which one I should use and how…
-
Place the collection in a
ServletContextattribute and access it on the jsp by calling${application.StringDisplayCollection}. -
Rip off an immutable copy of the collection whenever I need it and store it in the session, then access it on the jsp through the session scope.
-
Convert the collection to JSON and get it via ajax whenever needed on page load up.
-
Some cool way I haven’t thought of that would be better and/or simpler…
Thank you and let me know if you need any clarifications.
Suggestion: Place the collection in a ServletContext attribute and access it on the jsp by calling ${application.StringDisplayCollection}.
Not in session scope because this doesn’t change on a per user/session basis.