How to send redirect to JSP page in Servlet

Look at the HttpServletResponse#sendRedirect(String location) method. Use it as: response.sendRedirect(request.getContextPath() + “/welcome.jsp”) Alternatively, look at HttpServletResponse#setHeader(String name, String value) method. The redirection is set by adding the location header: response.setHeader(“Location”, request.getContextPath() + “/welcome.jsp”);

Check a collection size with JSTL

<c:if test=”${companies.size() > 0}”> </c:if> This syntax works only in EL 2.2 or newer (Servlet 3.0 / JSP 2.2 or newer). If you’re facing a XML parsing error because you’re using JSPX or Facelets instead of JSP, then use gt instead of >. <c:if test=”${companies.size() gt 0}”> </c:if> If you’re actually facing an EL parsing … Read more

jsp for business layer [closed]

Several reasons: Reusability: you can’t reuse scriptlets. Replaceability: you can’t make scriptlets abstract. OO-ability: you can’t make use of inheritance/composition. Debuggability: if scriptlet throws an exception halfway, all you get is a blank page. Testability: scriptlets are not unit-testable. Maintainability: per saldo more time is needed to maintain mingled/cluttered code logic. There are more, but … Read more