From the course: Java EE: Servlets and JavaServer Pages (JSP)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Filters: Display error and set up filter class
From the course: Java EE: Servlets and JavaServer Pages (JSP)
Filters: Display error and set up filter class
- [Instructor] So let's pick up from where we left off. We have coded the LoginServlet. Now, let's go to the login.jsp and also display this message that we have coded out here. Okay, so let's go to login.jsp, let me open that for you, and let's come down. So this is the login form, and we are going to display that error message in case it's an invalid login right out here on line number 44. Now, how am I going to do that? I'm going to use a simple scriptlet element and say that if request, so I'm going to use the implicit object of jsp, and I'm going to say if request.getAttribute I get anything as an error. So let's say if it is not null, then I'm going to go ahead and display that error message. So I'm going to say an expression element and just take this again and assign it. So whatever is there inside that attribute of error, we'll get displayed. Let me put also a quickly here to break the line. And yeah, so that's what we're going to do. And of course, let's end the if…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
Understanding the need for filters in a web app8m 19s
-
(Locked)
Filters: User validation in a servlet9m 29s
-
(Locked)
Filters: Display error and set up filter class6m 25s
-
(Locked)
Filters: Implement filter logic10m 15s
-
(Locked)
Understanding the need for listeners in a web app5m 33s
-
(Locked)
Using listeners in a web app10m 51s
-
-
-
-