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.

Search: Building a servlet response

Search: Building a servlet response

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

Start my 1-month free trial

Search: Building a servlet response

- [Instructor] Now that we've added the method in the DAO let's come back to the SearchServlet and let's call the DAO from here. So, on line number 20, I'm going to make an instance of application DAO. Let's do that. And, once we do that we also call the search products method. So, I'm going to say dao.searchProducts and the search string that we have are collected on line number 21, we just going to pass that as an argument. And, collect this entire output in a list of products. Right. Now, let's look at the next step. The next step will be to build a method in the SearchServlet which is going to read the entire searchResults.html file. We talked about the portion where we need to read the entire HTML as a string. Right. That's what we are going to do now. The method is going to do a couple of jobs. One is to read the entire HTML as a string and then to replace those placeholders with the relevant data of product images and the names. And, for that, we are going to use message format…

Contents