URL not updating with latest page changes

一个人想着一个人 提交于 2020-01-24 00:43:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15635338/url-not-updating-with-latest-page-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!