I try to prepare some data from MySQL in a Java String array in a servlet, but after clicking another page(after a request and a respond) this data is lost in the array and it gives NullPointerException. Is there a way I can save data in a Java object that will maintain after several HTML or JSP pages have been changed?
Asked
Active
Viewed 45 times
0
-
1Store it in the Session ? – Arnaud Apr 25 '16 at 14:14
-
Take a look at sessions. – f1sh Apr 25 '16 at 14:14
-
You would have probably stored it in request scope. Hence the data is lost after the request is served. As @Berger said, you may have to store it in either session or application scope, depending on its visibility – JavaHopper Apr 25 '16 at 14:34