CS122B: Projects in Databases and Web Applications Winter 2019 Professor Chen Li Department of Computer Science UC Irvine Notes 05: Pagination, Caching, Sort, Search, Browse
Pagination Show results in different pages
SQL Support SELECT columns FROM table LIMIT 20 OFFSET 10
Embedding parameters in GET requests Example: https://www.autotrader.com/cars-for-sale/Sedan/Irvine+CA-92604?zip=92604&startYear=1981&numRecords=25&sortBy=derivedpriceDESC&vehicleStyleCodes=SEDAN&firstRecord=0&endYear=2019&searchRadius=10
Caching in Tomcat Store the query results as an object Later requests can be served using the cache without querying the database
Caching in Tomcat Pros: Cons: Less traffic on DB Low response time Memory overhead in web server Results may be obsolete
Searching/Browsing
Different queries Browsing: SELECT * FROM Movies, genres, genres_in_movies WHERE genres.name = “action” Searching: SELECT * FROM Movies WHERE title LIKE “%term%”;
Same page of movie list Implement a Java Servlet program by taking a SQL query as a parameter Show the results of the query as a list of movies.
Sorting Frontend GET request includes a sorting parameter such as “DESC” and “ASCE”; Use “ORDER BY” in SQL to sort the results