i'm working on my jsp page, and i have a link with 2 parameters: shop.jsp:
<a href="<c:url value="/boutique?achat=${module.id}&token=${module.token}" />" class=" modal-action modal-close waves-effect waves-green btn-flat">Oui</a>
So i have 2 if in my servlet, to work on the two parameters: shop.java:
public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException
{
httpServletRequest.setAttribute("page", "boutique");
HttpSession session = httpServletRequest.getSession(true);
int tokens = moduleDAO.getTokens(session.getAttribute("sessionPlayer"));
List<Module> modules = moduleDAO.select();
httpServletRequest.setAttribute("modules", modules);
httpServletRequest.setAttribute("tokens", tokens);
if(httpServletRequest.getParameter("achat") != null)
{
inventoryDAO.addInventory(session.getAttribute("sessionPlayer"), Integer.parseInt(httpServletRequest.getParameter("achat")));
}
if(httpServletRequest.getParameter("token") != null)
{
inventoryDAO.changeToken(session.getAttribute("sessionPlayer"), Integer.parseInt(httpServletRequest.getParameter("token")));
}
getServletContext().getRequestDispatcher("/WEB-INF/shop.jsp").forward(httpServletRequest, httpServletResponse);
}
But i want to refresh my page after clicked on the lick with the 2 parameters because in my shop.jsp page i have a value: ${tokens}, which it doesn't refresh, because when i click on the link i still on th eurl with the 2 parameters.
So how i can refresh the page, after clicking on the link ?
Thanks!
I did:
if(httpServletRequest.getParameter("token") != null)
{
inventoryDAO.changeToken(session.getAttribute("sessionPlayer"), Integer.parseInt(httpServletRequest.getParameter("token")));
String referer = httpServletResponse.getHeader("/WEB-INF/boutique.jsp");
httpServletResponse.sendRedirect(referer);
}
getServletContext().getRequestDispatcher("/WEB-INF/shop.jsp").forward(httpServletRequest, httpServletResponse);
But i get an error: Cant use forward after response getted