* Note: I get my user information from a session variable called user as an example.
In your JSP or HTML page:
<img src="/yourappscontextpath/PageView.servlet?page=<%=request.getRequestURI().toString()%>" style="display: none;" />
* Note: Replace the text yourappscontextpath with your actual applications context path.
In the doGet method add the following code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
User user = (User) request.getSession().getAttribute("user");
String page = request.getParameter("page");
// Add your own code here to save the user and page to the database or to a file.
}
Now you can view each time a user accesses a certain page in your application using this simple process. Enjoy!
No comments:
Post a Comment