lundi 26 mars 2018

Where could we track session's statisticas in a Java EE application?

I have an use case where I need to track for each user what pages and beans they access to.

I was wondering: Where should we track the sessions' statistics?

I ask this because I am learning Java EE and I want to have some advice.

I thought to put the logic inside FrontServlet, Header.jsp or Statistics.java (a singleton session bean).

We would like a data structure like:

Map beansAccesed =
    "id1" : "Index.jsp, HomePage.jsp, AssesmentCommand.java, FrontServlet.java , AssesmentPage.jsp",
    "id2" : "Index.jsp, FrontServlet.java, CreateCourseCommand.java, CourseCreation.jsp

So I thought as pseudocode:

public static relateSessionToBeansAccessed(){
    String = session.getID();
    Map<String, String> beansAccessed = new HashMap<String,String();
    beansAccessed.put(sessionID, forEach: beanAccessed -> beanAccesed.ClassName);
}

I ask where to put the creation and updating of the map, because I thought if we were to put this into the Header.jsp, there would be two problems:

First, if we put that function into <%! %> then it would be shared, and also we could not get the session.

Second, if we put the function into <% %>, we could not do that, because it gives us a syntax error.

Could you help me please?

I have also studied:

Difference between request.getSession().getId() and request.getSession(false)?

http://codingbat.com/doc/java-map-introduction.html

Best option for Session management in Java

Thank you for yoiur help in advance.




Aucun commentaire:

Enregistrer un commentaire