Answer the question
In order to leave comments, you need to log in
How to get rid of the repeated code in the servlet in this example?
In each servlet in doGet, I repeat this code to display the user's balance on each page.
BigDecimal balance = userServlet.getBalance();
request.setAttribute("balance", balance);
Answer the question
In order to leave comments, you need to log in
You can write a filter (implemented javax.servlet.Filter
) into which to insert these lines - tutorials.jenkov.com/java-servlets/servlet-filters.html
And in general, you can put all the work with the user into the filter...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question