1

I am building a web application using Java to do my server side processing. Currently when I make an ajax request from the frontend, it calls a servlet, which then creates an object of a class, which has a list of methods I call.

Is there a better way to achieve this so that I dont have to instantiate an object every time I make a request? I.e is there a way to cache the object instance?

Julian
  • 781
  • 1
  • 11
  • 32
  • If you have no more references to the new created object, the object will be garbage collected (soon) when the response method is finished. You may use a cached object, but the JVM is all about creation and deletion of objects anyway. Depends on the use case, if a cache will have any advantage. – PeterMmm Dec 16 '16 at 15:24

0 Answers0