From the course: Java EE: Servlets and JavaServer Pages (JSP)

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Filters: Implement filter logic

Filters: Implement filter logic

From the course: Java EE: Servlets and JavaServer Pages (JSP)

Start my 1-month free trial

Filters: Implement filter logic

- [Instructor] Okay, so we are now inside the AFLUC. We have put a condition that we are going to restrict the access to the servlet for these two URL patterns, Order History and Get Profile Details for the two links that you've already seen on Home Page. So what do we do under this? What we need to do is on line number 27, I'm going to take the HTTP session first. So we know that if it is a previous session, if it's already a set up session, the request.get session API will just return me that existing session, right? So now here inside, I am going to do one more thing. I'm going to say, "if session.get attribute user name" okay? If this is null, it means I'm not able to get a correct username in the session which means the session is messed up. Either invalidated or malicious access or whatever. So let's go ahead and put that condition and if it is indeed null, what I'm going to do, I'm just going to take that request object, get the request dispatcher, and just ask the user to move…

Contents