Hello guys, In last a couple of articles, we have learned how Spring MVC framework works and what is the role of DispatcherServlet in Spring MVC. We have briefly touched another frequently asked Spring MVC interview question, how does requests are mapped to controllers in Spring MVC? In this article, we'll expand our knowledge on that. You have learned that DispatcherServlet is the front controller in Spring MVC framework, it is the single point entry and all incoming request goes through it, but instead of processing those request it just dispatches the request to the appropriate handler methods based on the request mapping, but how does it do that?
Sunday, November 26, 2023
Monday, November 20, 2023
How to secure an URL using hasRole() in Spring Security? Is it enough to hide sections of JSP to protect URL? Example?
One of the Spring security question asked to me on a recent interview was about is it enough to hide portions of JSP to protect a URL from unauthorized access in Spring security? First of all I didn't understand the question, so I ask him to clarify a bit more. He explained to me that there are different roles in his application e.g. DEVELOPER, ADMIN, TRADER, OPERATION and each role can only see the functionalities based upon their role. For example, an ADMIN has a right to add or remove new users into the system, while DEVELOPER can only see test order, but OPERATION can see all orders.
Labels:
spring
,
spring interview questions
,
spring security
Monday, November 13, 2023
How to show current logged in username in JSP using Spring Security? Example Tutorial
One of the common feature of secure Java web application to show the username as link on the top right corner of web application once user successfully logged in. Some application also show the logout or sign-out link like that but how do you display the current user or principal name in a JSP page secured using Spring security library? Well, Spring Security provides a small but userful JSP tag library which contains custom tags similar to JSTL, which can show a lot of useful authentication and authorization details of current user. For example, you can use <s:authetication> tag to display the current principal details including the username of currently logged in user. The tag name is authentication here and s is the prefix you specify while importing tag using taglib directive in JSP.
Labels:
spring
,
spring interview questions
,
spring security
Sunday, November 5, 2023
5 Ways to Update Values in ConcurrentHashMap in Java 8 - Example Tutorial
In last article, I have showed you how to update value in HashMap and today we'll learn about how to update value in a ConcurrentHashMap. Some of you may question, can we use the same technique we used to update a value in HashMap here? well, you can but you need to keep in mind the difference between an HashMap and a ConcurrentHashMap. The HashMap is only meant to be updated by one thread at a time, hence you don't need to pay any attention to thread-safety or concurrency, but ConcurrentHashMap can be updated by multiple threads at the same time, hence you need to pay special attention.
Labels:
concurrent collections
,
ConcurrentHashMap
,
HashMap
Subscribe to:
Posts
(
Atom
)