Why GenericServlet has init() with no arg method?

1)why GenericServlet has init() with no arg method also?.......when do we need this method, is there any such scenario?
2) why subclass of HttpServlet must override at least one DoXXX method and why we don't override service method? how does the server via "public service" method recognize to call the corresponding doXXX method like for get request call doGet() ?
Thanks in advance
Rahul

1) the javadocs explain exactly what the use of this method is. It's nothing more than a convenience method.
2) Technically you can override service() and ignore doGet() and doPost(). But that's just bad design, for all you know the service() method does more then just calling doGet() and doPost(). Do what the javadocs tell you, and they tell you to implement doGet() and/or doPost().
how does the server via "public service" method recognize to call the corresponding doXXX method like for get request call doGet()The answer is already in your question! The service() method checks the request method (get/post/put) and then calls the corresponding method in HttpServlet :s You can check this yourself, call HttpServletRequest.getMethod().

Similar Messages

  • 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.]

  • Why Servlet has init method?

    Hello,
    i am new bie to servlet. Can you tell me why servlet has init method to initialize?
    Why do not we use constructor instead of init method to initialize? Does servlet allow constructor?
    Why init method has SevletConfig as argument?
    Please help me to get knowledge regarding this. Any URL for this(sun or anything), please send.
    Thanks,
    balachandar

    http://www.unix.org.ua/orelly/java-ent/servlet/ch03_03.htm

  • TS3297 Why I can't download a free game I get a message that there's a problem with my payment method but not what it is this is a free app I tried support and got nowhere help

    Why can't I down load a free app  I get a message that there is a problem with my payment method but I gave all information correctly , I did recently change my card no because I lost my old one .i did change the no. On my account      HOPE YOU HAVE SOME SUGGESTIONS  I DON'T SEE WHY THEY HAVE TO CHECKMY PAYMENT METHOD FOR A FREE GAME

    Contact iTunes customer support.
    We're all users like yourself and as such have no access to your account.

  • Why I cannot show what I am playing on my Mac on my TV? The Mac has connected with the TV

    My product: Mac Pro.Retina, OS X Version 10.9.5
                        Processor-2.3GH Intel Corei7
                        Memory 16GB 1600MHz DDR3
                        Graphics NVIDIAGeForceGT750M2048MB
                        Serial No. C02MK36VFD57
                        Software OS X 10.9.5(13F34)
    The Mac has connected with my TV but my TV shows: no message!
    I used this method to show my playing videos from the Mac to this TV before but it cannot work now. I'd love to know how come.
    please tell me where the problem is.
    Thank you very much!

    Hi Isaiah,
    Your set up is not completely clear to me, in particular what kind of TV you have and how it connects to your MacBook Pro, but this article may give you some help with getting your computer to work with your TV for video -
    Apple computers: Troubleshooting issues with video on internal or external displays
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • I m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    i m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    tom i have been using ubuntu for c++ project
    i use lambda and atomic (c++0x) but now as I am working on MAC not able to use them
    installed xcode(4.3) and changed compiler settings to LLVM3.1 but still both features are not available
    to compile wanted to have g++ which supports c++0x features ...
    new to MAC (2-3 days) so was in rush to solution
    let me know if you have some suggestion ...
    else will try with eclipse cdt .... 

  • [svn:fx-trunk] 5445: Fix for - @ copy tag for two methods with different arg lists not working.

    Revision: 5445
    Author: [email protected]
    Date: 2009-03-19 17:47:57 -0700 (Thu, 19 Mar 2009)
    Log Message:
    Fix for - @copy tag for two methods with different arg lists not working.
    Some changes for refactoring.
    QE Notes: None.
    Doc Notes: None.
    Bugs: SDK-19975
    tests: checkintests, asdoc
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-19975
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va

    Revision: 5445
    Author: [email protected]
    Date: 2009-03-19 17:47:57 -0700 (Thu, 19 Mar 2009)
    Log Message:
    Fix for - @copy tag for two methods with different arg lists not working.
    Some changes for refactoring.
    QE Notes: None.
    Doc Notes: None.
    Bugs: SDK-19975
    tests: checkintests, asdoc
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-19975
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va

  • I don't understand why a person who has been with a company for 6 years cant get a simple upgrade can anyone help figure that out?

    I don't understand why a person who has been with a company for 6 years cant get a simple upgrade can anyone help figure that out?

    Are you trying to get an upgrade before you're actually eligible? If that is the case, it doesn't matter if you've been a customer for 6 years or 6 days...if you're not eligible then you're not eligible. Some of your possible options are to pay full retail, do an early edge up (if you are eligible for that option), or buying a phone from some other source to use.
    If your situation is something different then it might help to share that. The options may still be the same but it helps to know what exactly the issue is.

  • HT1349 why some iphone 4s has korean letters at the back and not the same with the most iphones..but the serial and software are all the same..so why there is phone with korean letters on the back it says.. kcc -cmm- apa -a1387

    why some iphone 4s has korean letters at the back and not the same with the most iphones..but the serial and software are all the same..so why there is phone with korean letters on the back it says.. kcc -cmm- apa -a1387..i purchased one and really worried about this..is this original or not..but all the software etc are all the same with other iphone..just that korean letter at the back

    I bought it in some mall here in our place..im from philippines.. im worried about this coz its different with other iphone at the back.. it says designed by apple in california..then its all korean letters at the bottom it says KCC-CMM-APA-A1387..i checked both serial number from the phone in the box and in the sim card slot and its all match, i checked it also in apple service and support coverage and it says : valid purchase, your product is eligible...and it shows i have 90 days technical support,and my repair and service coverage is active....pls help what model of iphone is this its working and i can sync to itunes,icloud and etc..thats what it says on the back on the image ia

  • So annoyed with this new itunes, spent over 2 hrs to get one ringtone on iphone,why apple has to make it so complicated, on samsung just a push of button ringtone or music is on ur phone... i think its time to say good bye to ihpne... Not a user friendly.

    so annoyed with this new itunes, spent over 2 hrs to get one ringtone on iphone,why apple has to make it so complicated, on samsung just a push of button ringtone or music is on ur phone... i think its time to say good bye to iphone... Not a user friendly...
    Highly recommended for samsung galaxy S4....

    hi i had the same problem today when i updated my itunes to latest version. however, i have just found my songs in the 'itunes media' folder. this was accessed through 'my music'  then keep clicking through until you find itunes media and all my library songs were in there and i then just added these files to my library and all were restored however, i have lost all my playlists but at least my 700 songs are back. very dissapointed with apple that they have let this happen with their latest update, the previous version was miles better than this one . hope you find them. stevo

  • Why now has a code to use the ipad with apple tv....

    Why now has a code to use the

    restart ipad
    http://support.apple.com/kb/HT1430?viewlocale=en_US&locale=en_US
    restart appletv (you can just pull the plug)
    restart the wifi router (you can just pull the plug unless the router documentation say otherwise)
    if it does not help then make sure that your wifi router is not using the same ssid (default is often netgear or linksys or whatever the brand is) as other close by wifi networks as that could result in 1 or more of your devices connecting to another network then you think they are using
    and if your wifi channel is the default if many close by wifi networks use the same channel it will cause disturbance
    and if your wifi network is running 2.4Ghz then it's a rather busy frequency dect phones, microwave ovens and tons of other things use the same frequency so if one have the option of changing to 5Ghz it's less busy == give less disturbances

  • Why my ipad mini with retina display has short life battery?

                            My iPad mini with retina has problem with battery. I use it for 4 months. Now, it faces a lot of problem. Especially, battery has the most problem. When I just bought it, battery was good. I played games for 20 minutes, the percentage is still 100%. But now, when I played games for 20 minutes, the percentage was 90%. The percentage cut down very much. I tried to turn off wifi, reduce the brightness, turn on airplane mode, but it still the same.

    We'll the battery has its number of cycles, as time goes the battery will be used up and will need replacement. Try to close all apps running on your backround cause it will also use the battery life. Games with high end graphics will use more battery life due to more data processing involved.

  • Why should i write main(String[] args)?

    Hello,
    I don't know why i am obliged in the main function of the class to send an array of string as parameters?
    Thanks

    Actually I think this is a great question!
    main()
    Any java application has to have a main method to do anything, but as you gain further into java and object orientated practices you will start writing lots of stuff that do NOT have a main method but are *.java and *.class files, neither will they do anything unless they are attached to a program with a main. Andthen as you get DEEPER still you might even have 'private synchronised void main(String[] args)' - though not too often.
    Why an array of strings? Hmmm ...pauses ...thinks, there is no obvious reason, other than the fact that if you're going to pass parameters from 'java ...' command line to the application. This is, logically, the most potentially useful data type to have. There may well be other reasons for this, so the answer to the second part of your question is a logical deduction - it may not be right.

  • Issue with std GET method GET_PROPERTY_AS_VALUE

    Hi,
    We have created a Z field using AET in WebUI which is already moved to Production system. This field has a Get and Set method customized to populate its value.
    Now we have included  similar field with a similar logic. The issue is that now the earlier field is not able to read certain attribute values using the standard method IF_BOL_BO_PROPERTY_ACCESS~GET_PROPERTY_AS_VALUE
    Line......LV_PROPERTY_REF = GET_PROPERTY( IV_ATTR_NAME )
    We have not made any changes in the code, then why the system is unable to read the attribute value in our Test client.
    Any hints?
    Regards,
    PP

    Hi Pepe,
    Cant answer your question without debugging but below are few things you can try out:
    1. In case you are writing custom code, try to use other method like get_property_as_string or get_property and see if they    return a value.
    2. Check your design layer if both the fields are present there.
    I don't see any other reason. If no luck with above two then please raise an OSS.
    Regards,
    Bhushan

  • Problem with the renameTO method in the Linux environment

    Hi
    I got a problem with the renameTO method in the Linux environment. The file is not moving.
    This method is returning false. the same code executed successfully in Windows environment.
    Can anyone give some fix to this one or an alternate solution to move the files in both windows and Linux.
    boolean success;
    File root = new File(tempPath);
                   File f = new File(root, phyFileName);
                   File dest = new File(targetPath);
    success = f.renameTo(new File(dest, actualFileName));actualFileName = 400.doc
    dest = /home/jboss-4.0.3/axsscm_1.0/axsscmDocuments/xchange/fileup/fshare/PO/1786

    JITHENDRA wrote:
    Thanks for the prompt replyNo problem.
    >
    Can u solve the below doubt.
    Will renameTo method wont work in Linux? If so why?Did you not read what I said? I suspect you are trying to rename a file so that it actually has to be moved to a different volume (partition or hard disk) so it won't work. One would have the same problem on Windows trying to rename a file on the c: drive to a name on the d: drive.
    >
    >
    Can u give a sample or good link to do the above work which works fine in all environments.?Just follow the pseudo code I gave. 15 minutes work.

Maybe you are looking for