I have the following servlet code to store a data for a specific reason and later I retrieve the same data in another scenario in a project. It works fine as expected.
// setting
ServletContext context = request.getSession().getServletContext();
context.setAttribute("imageData", data);
// retrieving ...
ServletContext context = request.getSession().getServletContext();
byte[] data = (byte[])context.getAttribute("imageData");
Now, In an another project, where I use plain java program, where I want to store data similar to this servlet logic. I tried using the same code in plan java project, but it throws error, not accepting this servletcontext in plan java file.
Could someone please help, 1.) what is the equivalent in plan java to store like this temporarily or 2.) How to make that servletconext code working in plain java ?
Thank you in advance!
- Getsy