Why Servlets having Init() even though its having constructors

Hi friends , i ve one doubt,
in servlets all initilization part can be handled by Iinit() method,
my qn is each servlet is singleton oriented i.e, each has only one instance, it means only one time constructor will called, and init() also called only once, so instead of init() we can use constructor, in this case why sun people provide us init() method,
please give me soln.

-nevermind-
I've found something interesting in Google:
http://www.unix.org.ua/orelly/java-ent/servlet/ch03_03.htm
The init() method is typically used to perform servlet initialization--creating or loading objects that are used by the servlet in the handling of its requests. Why not use a constructor instead? Well, in JDK 1.0 (for which servlets were originally written), constructors for dynamically loaded Java classes (such as servlets) couldn't accept arguments. So, in order to provide a new servlet any information about itself and its environment, a server had to call a servlet's init() method and pass along an object that implements the ServletConfig interface. Also, Java doesn't allow interfaces to declare constructors. This means that the javax.servlet.Servlet interface cannot declare a constructor that accepts a ServletConfig parameter. It has to declare another method, like init(). It's still possible, of course, for you to define constructors for your servlets, but in the constructor you don't have access to the ServletConfig object or the ability to throw a ServletException.

Similar Messages

  • Why does my iphone phone by it self ?even though its password protected, switched off, and has a hard cover over the screen.

    why does my iphone phone by it self ?even though its password protected, switched off, and has a hard cover over the screen.

    the phone started to phone by itself  only numbers in my addressbook, now its phoning random people, has any one any ideas?  also i find it pure cheek from apple that i paid for a phone that cost 100,s € and i have to pay for tech support.

  • HT204406 i am still unable to play or download a song that is already matched on my imac. i have gone through all of the recommended checks, author/reauthorized, turned match on/off, etc... but still asks to locate song as it cant even though its already

    i am still unable to play or download a song that is already matched on my imac. i have gone through all of the recommended checks, author/reauthorized, turned match on/off, etc... but still asks me to locate the song, even though its already matched. granted, the file is missing on my mac, but having been matched previously, why cannot i access it to play and/or download?

    i am still unable to play or download a song that is already matched on my imac. i have gone through all of the recommended checks, author/reauthorized, turned match on/off, etc... but still asks me to locate the song, even though its already matched. granted, the file is missing on my mac, but having been matched previously, why cannot i access it to play and/or download?

  • What is the significance of Marker interface? Why are we using, even though

    What is the significance of Marker interface? Why are we using, even though it has no method?

    Well, what's the significance of an interface? They can define a set of methods a class may implement but the class could equally well implement these methods without the interface so why having interfaces at all?
    The answer is that the most important aspect of an interface is that it constitutes a type (you can declare variables of it). And it's a type regardless of how many methods it defines, including none. So the reason for having a marker interface is that you're interested solely in the type aspect of interfaces.

  • My iphone time keeps messing up even though its on "set automatically" and i dont know how to fix it

    my iphone 5cs' time keeps messing up even though its set to "set automatically" the time doesnt change and i have no idea how to fix it. any help please?

    I'm having the EXACT same problem! I have a great wifi connection and it all started right after I updated it.
    I took it to the AT&T store and all they said that they could do for it was a "soft restart" which is where you hold down the lock button and the home button UNTIL you see the apple logo. And I did this like 4 times and it still messes up. When I turn it off and turn it on its fine for a few minutes but it slowly starts messing up again.
    And I'm also having several glitches. Like when I just received a text message when my phone was locked I slid it and put in my pass code then it like turned off and turned on my phone. And sometimes the messages that I send disappear from my side even though I sent them. If I turn it off then back on it's there. And also sometimes when I text a person and hit send it like backs me out of the messaging system(it still sends the message right then)  and back to the home screen.
    I called 1-800-myiphone and the lady did a "soft restart" which they call a "hard restart" and it worked for like 35 minutes and then it messed up again. And my iCloud isn't backing up my stuff so it's not like I can just completely reset my phone.

  • Why servlet has init() method insteadof constructor

    Why servlet has init() method insteadof constructor

    Depends completely on the servlet. If the servlet implements SingleThreadedModel, then multiple instances of the servlet will be created.
    Reason: Most servlets work quite well with multiple threads, the bulk of the variables are declared locally within the service method. Sometimes, however, the servlet needs to be able to handle multiple threads even though it is not thread safe. In such as case the SingleThreadedModel is implemented to tell the container to use a new (or one from a pool) servlet. In this case the init method will be called each time.
    [As an aside: there is of course one (not obscure, but not normal) scenario where you would call the constructor of a servlet directly - this would be where you are writing a container.  'Ah!' you say, 'I will leave that kind of madness to the boys and girls at Jakarta' - however, you may wish to write a container as a test frame for you servlet, which you should be doing.]

  • Running adobe captivate keeps asking for flash even though its already installed

    running adobe captivate keeps asking for flash even though its already installed

    iTunes will ask you to enter your password when buying songs for each browsing "session". This wouldn't explain why you are being asked to enter it every 3 minutes though.
    I would suggest logging out of your Apple ID on iTunes and logging back in. Also, you may verify that your computer is "Authorized" for use with your iTunes content.
    To do this on a Mac, go to the "Store" tab at the top of the screen and click "Authorize this Computer"

  • HT201412 After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to

    After ios7, My iphone4 has gone dead twice in a time frame of around two months...even though its not happening very often but a two month Old phone going dead just after a New update is not acceptable.probably ios7 still has sum bugs dat need to be fixed...Can this bug expected to be fixed in the next update...

    Hi 1283ar.
    Unfortunately, iOS 7 is too hard to push for the iPhone 4 and therefore has a lot of effects turned off to try to get it to run as smoothly as possible.
    However, it becomes better and better with each update coming but it's hard to do anything about the hardware on an already released phones.
    If you still have trouble or think they are too hard. My tip is, if so, to restore your iPhone 4 and make a clean setup with no iCloud backup. But all your photos in a photostream so you can access it later.

  • TS1702 I have a paid game app that I deleted and want to reinstall. There is no download button for it in iTunes even though its deleted from my ipad. Other apps I deleted I was able to re-download. What do I do? I would like to download this app again to

    Hi there,
    Hoping someone can help. I purchased a Big Fish Game app from itunes for my Ipad 1. I decided to delete it and reinstall it as there were some errors in the game. When I visit itunes to reinstall it it doesnt give me the option to reinstall/re-download and has it marked as downloaded even though its not now on my Ipad. I have already deleted and re-downloaded something else so I believe I know how to do this. Its a paid app so I would rather not delete it from itunes as an option.
    Hoping someone can help this newbie, thanks,
    DT1010

    iOS 7.0.3 is now available ,that may have a fix

  • In Imovie my music wont open the itunes list. it asks to open itunes even though its already open. would anyone know how i can access this library?

    Can anyone help with accessing itunes through imovie for background music? when pressing the music button, the music will not show for itunes and keeps asking to open itunes, even though its already open as an application?

    Do you get an error message when you try to launch iTunes? If so, what does it say? (Precise text, please.)

  • In FCP x backup process is constantly running in background even though its done which results into slow working of FCP x. any idea to resolve the issue. I am using 10.1.3 and facing the problem ever since i have updated my FCP x to 10.1.3

    in FCP x backup process is constantly running in background even though its done which results into slow working of FCP x. any idea to resolve the issue? I am using 10.1.3 and facing the problem ever since i have updated my FCP x to 10.1.3

    Go into preferences and under playback turn off background render. That helped speed things for me when working with large files.

  • AND Process failing even though its prior processes are green

    Hi Experts,
              I have an issue with AND process .The AND process is failing even though its prior processes have finished sucessfully and have become green in the  process chain.
    Can any one please help out on this issue.
    Thanks
    SHASHI

    Hi........
    U copy the rest of the chain.........
    Open the chain through RSPC1...........it will directly open the chain in Planning view.........bcoz to copy a chain u hav to open the chain in Planning view.......in the top where we write tcode.............write COPY there.........or ......in the top Process chain tab >> Copy.........Give the chain name..............remove all the processse till the AND process...........remember remove the Start process also...since Start proces is always unique..........and set the the condition as immediate.........then schedule the chain.........
    And to fix the issue permanently...........deschedule the chain..and then again schedule it back......
    Regards,
    Debjani......

  • Used wrong charger with ipod classic, now it wont turn on, displays the low battery icon even though its connected to the wright adapter

    used wrong charger with ipod classic, now it wont turn on, displays the low battery icon even though its connected to the wright adapter.
    Can anyone help ?
    please?

    WHow long have you left it to charge?  Have you tried resetting it after a short period of time to see if that can help jumpstart the charging process? To do this, press and hold both the Select/Center and Menu buttons together long enough for the Apple logo to appear.
    B-rock

  • HT1386 I have iphone 4, and couldn't update to ios7.1.1 even though its downloaded, gives error message as not connected to internet, even though am connected

    I have iphone 4, and couldn't update to ios7.1.1 even though its downloaded, gives error message
    Unable to verify update
    ios 7.1.1 failed verification because you are no longer connected to the internet
    Close          Try again
    Event though I am connected to the net
    Tried repeatedly but frustrating. Am able to do the same in another iphone 4 which my brother has....Do not know what setting to change. Even cant update via itunes

    Hi GajaPsy,
    If you are getting errors or alert messages when you try to update your iPhone, you may find the troubleshooting steps outlined in the following article helpful:
    Apple Support: Resolve iOS update and restore errors in iTunes
    http://support.apple.com/kb/ts1275
    Regards,
    - Brenden

  • My iphone 5 keeps shutting off every 2 minutes even though its fully charged what to do????

    my iphone 5 keeps shutting off every 2 minutes even though its fully charged ... what to do???

    http://support.apple.com/kb/HT1414?viewlocale=en_US&locale=en_US

Maybe you are looking for