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

Filters: Display error and set up filter class

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

Start my 1-month free trial

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…

Contents