Send it as request attribut when clicking on button
a) Set request attrbute in jsp
request.setAttribute("thatobject",thatobject);
In Servlet retrive it as
Thatobject obj = (ThatObject) request.getAttribute("thatobject");
b) Set the object in session session.setAttribute("thatobject",thatobject)
and retrive it as
Thatobject obj = (ThatObject) session.getAttribute("thatobject");
Oh my mistake Updated...
Note: Also iam not providing null check. I think you can handle it
Edit:
Even you can do other way, which is very sofistiacted way,
a) Create a Bean class
b) provide Object as a attribute in bean class and provide getter and setter methods too
C) in jsp use that bean to set the object when the page is submitting to servlet
d) retrive the object from the bean in servelt
Edit 2:
Please check this link there is clear explanation.
JSP2Servlet
Edit 3
Note : If you are submiting form , the request becomes new request and the object will become null, when you use request.getattribute in servlet. So above approach will not work on Form submit in jsp.
So to overcome this please folw the instructions provide in below link
Passing Object from JSP to Servlet