System.out.println("Error path.");
response.sendRedirect("/home");
}
cateString = URLDecoder.decode(cateString, "UTF8");
System.out.println("Cate to search : " + cateString);
Category cate = CategoryModel.getByCateAlias(cateString);
if (cate != null) {
List<Tube> result = new ArrayList<Tube>();
int startPoint = (page - 1) * itemPerPage;
if (cate.getListTubes().size() > startPoint) {
System.out.println("Ok here.");
for (int i = startPoint; i < cate.getListTubes().size(); i++) {
if (i == (itemPerPage + startPoint)) {
break;
}
Tube tub = new Tube();
tub.transformString(cate.getListTubes().get(i)
.getValue());
result.add(tub);
}
} else {
page = 1;
for (int i = 0; i < cate.getListTubes().size(); i++) {
if (i == itemPerPage) {
break;
}
Tube tub = new Tube();
tub.transformString(cate.getListTubes().get(i)
.getValue());
result.add(tub);
}
}
request.setAttribute("url", request.getRequestURL());
request.setAttribute("listCategory",
JavaCacheHandle.getCategory());
request.setAttribute("listChannel",
JavaCacheHandle.getChannels());
request.setAttribute("result", result);
request.setAttribute("currentPage", page);
request.setAttribute("totalResult", cate.getListTubes().size());
request.setAttribute("cate", cateString);
request.setAttribute("cateString",
cateString.replaceAll("\\+", " "));
request.getRequestDispatcher("/category_show.jsp").forward(
request, response);