// request.setAttribute("url", request.getRequestURL());
// request.getRequestDispatcher("/tube_detail.jsp").forward(
// request, response);
List<Tube> list = new ArrayList<Tube>();
list.add(tub);
TubesFeed result = new TubesFeed();
result.setCurrentPage(1);
result.setTotalResult(1);
result.setListTube(list);
request.setAttribute("url", request.getRequestURL());
request.setAttribute("result", result);
request.setAttribute("key", tub.getTitle().getValue());
request.getRequestDispatcher("/tube_show.jsp").forward(request,
response);
} else {
}
} else {
// search by input key.
String[] splitted = request.getRequestURI().split("/");
String key = null;
int currentPage = 1;
if (splitted.length == 3) {
key = URLDecoder.decode(splitted[2], "UTF-8");
} else if (splitted.length == 4) {
key = URLDecoder.decode(splitted[2], "UTF-8");
try {
currentPage = Integer.parseInt(splitted[3]);
} catch (Exception e) {
currentPage = 1;
}
} else {
response.sendRedirect("/home");
}
try {
System.out.println("Keyword to search : " + key);
TubesFeed result = TubeService.searchByKey(key, currentPage, 1);
request.setAttribute("url", request.getRequestURL());
request.setAttribute("result", result);
request.setAttribute("key", key);
request.getRequestDispatcher("/tube_show.jsp").forward(request,
response);