Nature of Problem
i am calling servlet with parameters from Jsp page.
The servlet contacts with database and generates dynamic content and redirected to jsp page and it is displayed to client.
if the user relaods the jsp page redirected by servlet/servlet page itself, the servlet is re loaded without sending parameters . so servlet returns Nullpointer Exception.
I have done cache-control mechanisms in jsp pages.
how to prevent the reloading of servlet by user directly.
even if user reloads servlet, how he will be redirected to some other necessary jsp page?
please help me to overcome this shortage in my servlet page.
You are using a sendRedirect to dispatch the user from the Servlet to another jsp page?
If not when the user reloads the page the request parameters should be there.
About preventing reloading and if the user reloads redirect to another page you can use the synchronyzer token pattern.
When the user loads that page you can generate a random seed (at the previous servlet, or inside the jsp itself), store it on the session and render as a hidden parameter.
At your Servlet the first thing you must do is get this seed from the session and see if it matches with the page provided seed, if not it's because is a reload or someone accessing the servlet without the form. After retriving the seed from session reset it.