import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.mxchange.jcore.exceptions.BadTokenException;
import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
this.getLogger().debug(MessageFormat.format("item.id={0},item.itemId={1},item.itemType={2},item.amount={3}", item.getId(), item.getItemId(), item.getItemType(), item.getAmount())); //NOI18N
try {
+ // Cast to servlet request
+ HttpServletRequest servletRequest = (HttpServletRequest) request;
+
// Get session instance
- HttpSession session = ((HttpServletRequest) request).getSession();
+ HttpSession session = servletRequest.getSession();
// Debug message
this.getLogger().debug(MessageFormat.format("session={0}", session)); //NOI18N
// Register item with it
basket.addItem(item);
+
+ // Is amount null or zero?
+ if ((item.getAmount() == null) || (item.getAmount() == 0)) {
+ // Then redirect to added=0
+ ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=0"); //NOI18N
+ } else {
+ // Redirect to proper URL
+ ((HttpServletResponse) response).sendRedirect(servletRequest.getContextPath() + "/?add=1"); //NOI18N
+ }
} catch (final SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
// Continue to throw
throw new ServletException(ex);
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="basePath" value="${pageContext.request.contextPath}" />
-<%
- // Get amount from item
- Long amount = item.getAmount();
-
- // Debug message
- BaseFrameworkSystem.getInstance().getLogger().debug("amount=" + amount);
-
- // Is amount null or zero?
- if ((null == amount) || (amount == 0)) {
- // Then redirect to added=0
- response.sendRedirect(request.getContextPath() + "/?add=0");
- } else {
- // Redirect to proper URL
- response.sendRedirect(request.getContextPath() + "/?add=1");
- }
-%>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>