user1982491
user1982491

Reputation: 21

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

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?

Upvotes: 1

Views: 2788

Answers (1)

Alexandre Lavoie
Alexandre Lavoie

Reputation: 8771

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.

Upvotes: 1

Related Questions