I got a page with comments. I want the user to be able to sort those comments by oldest or newest by clicking on a link that show up in the comment section.
I am already preprocessing views via the url. So when the user browses to book?id=20 it shows the book with the id of 20 from the database.
Going directly to book?id=20&sort=oldest already works. How do I get my JSP to append to the URL upon clicking?
The problem im having is that I can't hardcode them in: for example, if I just coded in <a href="book?id=${param.id}&show=newest">Newest</a> it will disrupt other query strings. What if the user is already at the URL book?id=20&stars=5 (shows comments with the rating of 5 stars).
I'd like the JSP to just append onto the URL so that it includes any current queries, so for example: user is at currently at book?id=20&stars=5, user then clicks sort by oldest, then the JSP appends &sort=oldest making it book?id=20&stars=5&sort=oldest.