Can we override the init() & destroy() in case of serveltjsp

Can we override the init() & destroy() in case of servelt/jsp?
Asheesh_KumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

quincydudeCommented:
Sure you do. They are supposed to be overridden.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
quincydudeCommented:
Remember that when overriding init, include super.init(config) in it as well.
0
javaexpertoCommented:
The answer is possibly. The init() method gives you a chance to initialize your servlet before handling any client requests. So if you have initialization code (like getting a database connection or registering yourself with other objects), then you'll override the init() method in your servlet class.

Container calls destroy method to give the servlet  a chance to clean up before the servlet is killed. Like init it's called only once. So rarely you would want to override destroy() method but you can.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

javaexpertoCommented:
I gave the answer. Thanx
0
javaexpertoCommented:
it's ok, I didn't understand
0
javaexpertoCommented:
What kind of answer is? Sure you do. They are supposed to be overridden.

The only methods to be supposed overridden are doGet or doPost.

I gave a complete answer  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.