Reputation: 4696
I've got 2 jsp files (index and go) and 1 java class MyClass. In index.jsp I've got an instance of MyClass. I want to use this same instance in go.jsp file. How can I do that?
Thanks
Upvotes: 0
Views: 1508
Reputation: 1482
In index.jsp use ->
application.setAttribute("myclass" , new MyClass());
in go.jsp use ->
MyClass myclass = (MyClass)application.getAttribute("myclass");
In the above code application
is a application level variable , you can access it from all the jsp's and servlets.
Upvotes: 1