How to remove getParameter () value when page is refreshed

How to remove a parameter value when refreshing a page using F5 / reload? Expected Result: when B.jsp sends the status back to A.jsp, I want to make the value empty if the user clicks on the update page.

A.jsp:

<%String VALUE = request.getParameter("STATUS");%>

B.jsp:

<%send.responseRedirect("A.jsp?STATUS="Y");%>
+4
source share
2 answers

When an html page is sent to the / jsp servlet or to any other web resource, it contains some headers. Among these headers are query parameters. When the user clicks refresh / f5 in his browser, the browser does this to re-place the same header as before. So this problem is browser specific.

. , , , .

newjsp.jsp:

String param = request.getParameter("param");
if (session.getAttribute("PARAM") == null) {
    out.print("This is a NEW request");
    session.setAttribute("PARAM", request.getParameter("param"));
} else if (session.getAttribute("PARAM").toString().equalsIgnoreCase(param)) {
    out.print("This is a REFRESH");
    session.removeAttribute("PARAM");
} else {
    out.print("This is a NEW request");
    session.setAttribute("PARAM", request.getParameter("param"));
}

'newjsp.jsp? param = xyz123' .

+2

-,

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
+1

Source: https://habr.com/ru/post/1612708/


All Articles