URL not updating with latest page changes
Asked Answered
M

1

0

I have a problem that is very similar to this one: How to navigate in JSF? How to make URL reflect current page (and not previous one)

It is actually the same very problem but happens in different situations, and it is when I use a <jsp:forward> tag

To put you in situation, I have a form that asks for an user and pass to perform login. This redirects to a new page (checklogin.jsp) that performs the checking, updates the session and if everything is ok then it goes like this:

  if (con.comprobarUserPass(passmd5)) { // We check everything is OK
           sesion.setAttribute("conexion", con);
           sesion.setAttribute("pass", passmd5);
  %>
  <jsp:forward page="index.jsp"/> //forwards to the index
  <%
  } else {
  %>
  <jsp:forward page="login.jsp"> // user/pass error, goes back to the login.jsp page
     <jsp:param name="error" value="<strong><span style=\"color:red;\">Usuario y/o clave incorrectos. <br>Vuelve a intentarlo.</span></strong>"/>
  </jsp:forward>
  <%               }
  } catch (userPassIncorrectoException e) {
  %>
  <jsp:forward page="login.jsp">
     <jsp:param name="error" value="<strong><span style=\"color:red;\">Usuario y/o clave incorrectos. <br>Vuelve a intentarlo.</span></strong>"/>
  </jsp:forward>
  <%                       }
  %>

Well, the problem appears here, even if I'm redirected to the index.jsp page or to the login.jsp page my url is:

http://localhost:8084/myContext/checklogin.jsp

Any ideas why this is happening? It's making the debug process realy harder than it should be.

Mytilene answered 26/3, 2013 at 10:59 Comment(2)
and how are you calling checklogin.jsp? Using javascript ?Largess
@HardikMishra Mishra nope, the form that asks for the user and pass has it as action: <form id="form1" name="form1" method="get" action="checklogin.jsp">Mytilene
M
0

Solved my problem by using response.sendRedirect("pageToGo"); and inserting a page between the form submit and the actual page I need to go after submitting.

This way the form will call the intermediary web that only redirects to the page the user has to see after submitting the form.

Mytilene answered 27/3, 2013 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.