Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in servlet

 
jai gurudev
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

any body clear my doubt.

1)can we declare constructor in servlet
2)how to do FTP using Servlet-give some code examples
3)how servlet is calling init() method since it is not a Static method,it is calling directly

regards

jaigurudev
 
smitha verghese
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)can we declare constructor in servlet
Its not possible to have a constructor since life cycle of a servlet is design having init, service and destroy

2)how to do FTP using Servlet-give some code examples
try search in google or hope this helps
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=2955&lngWId=2

3)how servlet is calling init() method since it is not a Static method,it is calling directly

servlet's init method will be invoked at its first hit /request.
Note: doesnt get invoked all time u request for the servlet


Hope this helps
smitha
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not possible to have a constructor


It is most certainly possible to have a constructor. it's just not a good idea to try to use it to perform any initialization because the base class will call the init() function when it is ready for you to perform your servlet-specific initialization (making constructs like ServletConfig available).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic