Passing parameters when setting the Refresh HTTP header with setHeader() method in Servlet

风格不统一 提交于 2019-12-11 06:46:59

问题


I am using setHeader() method to refresh a JSP page as shown below

response.setHeader("Refresh", "5; URL=passDebitCard.jsp");

Now I want to send parameters to this passDebitCard.jsp after refreshing for 5 seconds How can I do that?


回答1:


You can append GET parameters to the URL like this :

response.setHeader("Refresh", "5; URL=passDebitCard.jsp?param1=test1&param2=test2");

You should also put an absolute path to this URL as a good practice, like this :

response.setHeader("Refresh", "5; URL=" + request.contextPath + "/passDebitCard.jsp?param1=test1&param2=test2");

so you won't have path problem even if the previous page is moved or different.



来源:https://stackoverflow.com/questions/16782263/passing-parameters-when-setting-the-refresh-http-header-with-setheader-method

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