I'm doing one litle project with JSP for topic Library. I want to create a rating system for books in library when end-user view detail of book and rating for this book. Can anyone give hints or tutorials how to go about this?
Asked
Active
Viewed 1.4k times
1 Answers
5
I'd suggest to use the jQuery Star Rating plugin for this. Check the demo page how it all look like. The JSP/HTML basically look like this (you only need to put the necessary JS/CSS/image files in the public webcontent). The magic is done by giving the radio buttons the class name star
.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Star rating demo</title>
<link rel="stylesheet" href="jquery.rating.css">
<script src="jquery.js"></script>
<script src="jquery.rating.js"></script>
</head>
<body>
<form>
<input type="radio" name="rating" value="1" class="star">
<input type="radio" name="rating" value="2" class="star">
<input type="radio" name="rating" value="3" class="star">
<input type="radio" name="rating" value="4" class="star">
<input type="radio" name="rating" value="5" class="star">
</form>
</body>
</html>
In the server side you just use HttpServletRequest#getParameter()
to obtain the rating value.
String rating = request.getParameter("rating");
// ...
With the above example, it'll return 1, 2, 3, 4 or 5.

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
is this code still valid? star1.length always returns 1 for me. – Jonathan May 02 '12 at 20:08