0

I have account.jsp which opens depending on username and password dialog form.

  <sql:query dataSource = "${snapshot}" var = "korisnici">
    SELECT * FROM clanovi WHERE    username='<%=request.getParameter("user")%>' AND lozinka='<%=request.getParameter("pass")%>' and id_naloga !='1';
</sql:query>

And it goes with for-each loop and shows all the info about that user in the html form.

When I press update(type=submit) it does form action on another samostalno_azuriranje.jsp page which updates the info.

    UPDATE clanovi SET ime='<%=request.getParameter("name")%>', prezime    ='<%=request.getParameter("last_name")%>',username='<%=request.getParameter("username1")%>',lozinka= '<%=request.getParameter("password")%>',email= '<%=request.getParameter("email1")%>', datum_rodjenja= '<%=request.getParameter("date")%>',pol= '<%=request.getParameter("gender")%>',adresa='<%=request.getParameter("address")%>',broj_tel='<%=request.getParameter("phone")%>' ,slika='<%=request.getParameter("slika")%>' where id_clan=<%=request.getParameter("id_clan")%> and id_naloga= <%=request.getParameter("user1")%>;

<%
String redirectURL = "account.jsp";
response.sendRedirect(redirectURL);
%>

So,the problem comes with the refreshing the page. I am trying to get my account again (updated) but with sending redirect it will only show empty account.jsp page. Only way it works is by pressing a back button in the browser. IS there a way to simulate a back browser button function automatically?

  • the problem comes from the way you are handling all this. I'm not sure if you are aware but scriptlets "" are discouraged and you really should not use them, they are not longer being maintained since 2010... Also i highly recommend not doing your database operations with the JSTL sql tags... It's much easier to just have java classes where you can do all this and then call it with Servlets. – Jonathan Laliberte May 08 '18 at 09:29
  • If redirecting you need to have the necessary parameters available for the final action. You could (a) append them in the URL `response.sendRedirect("/final-target-url?param1=1&param2=2");` or (b) store them in the session or (c) forward rather than redirect so the params are not lost between requests: `request.getSession(). getServletContext().getRequestDispatcher(nextJSP).forward(request, response);` – Alan Hay May 08 '18 at 11:18
  • Possible duplicate of [RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()](https://stackoverflow.com/questions/2047122/requestdispatcher-forward-vs-httpservletresponse-sendredirect) – Alan Hay May 08 '18 at 11:23

0 Answers0