tags:

views:

82

answers:

2

I hava a servelt. I am using the following code to refresh.

res.addHeader("Refresh", "10");

But before I am reading the date using a form.

For the first time, it works fine. But after 10 sec, during refresh I am getting null pointer exception as date is null.

How to take the previous value of date even after refresh.

thanks in advance, Mahes

A: 

The simplest solution is probably to save the date in the session.

If the value is present on the request (post) store the value in the session.

session.setAttribute("queryDate",theDate);

When reloading, check if getParameter() returns null and use the date from the session using getAttribute().

KarlP
+1  A: 

Putting the value in session is one valid option.

Another option is, on the first submission, to add a hidden field to the form that contains the previously submitted date. On refresh, the hidden field will be submitted, so the date will still be part of the request parameters.

JacobM