Reg Servlet's inti method and Constructor method

Hi,
My friend asks me 'Is init method of servlet is necessary? Can't we do whatever we want to do in Init method, in the constructor of the servlet? Why is init method is necessary?'
Thanks in advance,
Guhan

you can get the config object from the init method which u cant get from constructors. The environment details of the servlet can be had from it...

Similar Messages

  • Sample Program Using Method And Constructor

    Pls. help me... pls. post just a simple running program... that uses a method and constructor getter and setter..... my program doesn't do anything
    public class Attraction{
         public int minutes;
         public Attraction(){
              minutes = 75;}
         public Attraction(int m){
              minutes = m;}
         public int getMinutes(){
              System.out.println("Reading an attraction's minutes...");
              return minutes;}
         public void setMinutes(int m){
              System.out.println("Writing an attraction's minutes...");
              minutes = 7;}
    }

    public class Attraction{
         public int minutes;
         public Attraction(){
              minutes = 75;}
         public Attraction(int m){
              minutes = m;}
         public int getMinutes(){
    System.out.println("Reading an attraction's
    s minutes...");
              return minutes;}
         public void setMinutes(int m){
    System.out.println("Writing an attraction's
    s minutes...");
              minutes = 7;}
    //new code added
    public static void main(String arg[]){
    Attraction att=new Attraction();
    att.setMinutes(14);
    att.getMinutes();
    }

  • Need help!! How to use super in equals() method and makeCopy() method?

    This is my Name class:
    class Name {
        private String title;
        private String name;
        public Name(){
             title=" ";
             name=" ";
        public Name(String title){
             setTitle(title);
             name=" ";
        public Name(String title,String name){
             setTitle(title);
             setName(name);
        public void setTitle(String title){
             this.title=title;
        public String getTitle(){
             return title;
        public void setName(String name){
             this.name=name;
        public String getName(){
             return name;
        }   This is my Person Class
    class Person extends Name{
        private String address;
        private String tel;
        private String email;     
        public Person(){
             super();
             address=" ";
             tel=" ";
             email=" ";
        public Person(String name){
             super(name);
             address=" ";
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr){
             super(title,name);
             setAddress(addressStr);
             tel=" ";
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             email=" ";
        public Person(String title,String name,String addressStr,String phoneNum,String emailStr){
             super(title,name);
             setAddress(addressStr);
             setTel(phoneNum);
             setEmail(emailStr);
        public void setAddress(String add){
             address=add;
        public String getAddress(){
             return address;
        public void setTel(String telephone){
             tel=telephone;
        public String getTel(){
             return tel;
        public void setEmail(String emailAdd){
             email=emailAdd;
        public String getEmail(){
             return email;
         public boolean equals(Person inputRecords){
             boolean equalOrNot=false;
             if(inputRecords.super(getTitle()).equals(title))         //this is wrong
                  if(inputRecords.super(getName()).equals(name))           //this is wrong
                       if(inputRecords.getAddress().equals(address))
                            if(inputRecords.getTel().equals(tel))
                                 if(inputRecords.getEmail().equals(email))
                                      equalOrNot=true;
             return equalOrNot;   
            public void makeCopy(Person copyInto){
                 copyInto.super(setTitle(title));             //this is wrong
                 copyInto.super(setName(name));           //this is wrong
                 copyInto.setAddress(address);
                 copyInto.setTel(tel);
                 copyInto.setEmail(email);
    }How can I correct the wrong part?
    I don't understand how to use super in equals() method and makeCopy() method.

    Try something like this ...
    public boolean equals(Object other) {
      if (other==null || !(other instanceof Person)) return false;
      Person that = (Person) other;
      return getTitle().equals(that.getTitle())
          && getName().equals(that.getName())
          && getAddress().equals(that.getAddress())
          && getTel().equals(that.getTel())
          && getEmail().equals(that.getEmail())
    Notes:
    * This overrides Object's public boolean equals(Object other), which is (probably) what you meant.
    * You don't need to call "super.getWhatever" explicitly... just call "getWhatever" and let java workout where it's defined... this is better because if you then override getTitle() for example you don't need to change your equals method (which you would otherwise probably forget to do, which would probably have some interesting side effects.
    Cheers. Keith.

  • Push method and Pull method of extraction

    hello Friends,
    Can you please suggest me what is the diffrance between Push method and Pull method of extraction.
    i am having some confusion in this.
    It would be great if you can elobrate your view on this.
    Regards,Jain

    We used this in the Start Routine of Update Rule, The Oull Method is used if you will looked- up another value other than your source
    Example, You have an ODS name ODS123 and the its Load came from ODS234 and ODS345, If the requirement states that you must select a value other than your Source (let say your ODS is Delivery) you must extract from other ODS (let say Order or Billing that will serve as a Key to your Start Routine)
    The Pull Method is when you implement a routine directly from your source to do some conversion or computation
    Example
    Example, You have an ODS name ODS123 and the its Load came from ODS234 and ODS345, you will implement a routine to from Update Rule 8ODS234 and 8ODS345 to do some Key Figure computations

  • Academic Question about Classes Method and Constructor

    Given the similarity between the Constructor class and the Method class, why don't they have a common super class for the methods they have in common that are unique to them?

    sledged wrote:
    jschell wrote:
    sledged wrote:
    I've found that the most common reason for invoking a constructor or method through reflection is because you don't know what you need until runtime, commonly because what you want can vary based on context, or is otherwise being specified external to the bit of code that uses reflection. Not true. The fact that I don't need it until runtime never means I don't know what I need.Never? Then your experiences with the reflection API have been different than mine. Either that or I wasn't very clear. Let's take Apache Commons BeanUtils;
    It doesn't matter how you access a class. You can't use it unless
    1. You have a goal in mind
    2. That object in some way fulfills that goal.
    3. You know how that object fulfills that goal.
    And as I already pointed out you can't use a JFrame for a JDBC driver. Simple as that. Nor can I create a new class that implements, for example, ProC (Oracle method to embed access into C code) using my own idiom despite that it provide database access. It MUST match what jdbc expects.
    Sometimes it's not even clear before runtime whether a constructor's needed or a method.
    I disagree. That isn't true in any OO language.Perhaps not out the box, but it can be true when using certain tools built from the OO language. Let me continue using the Spring framework as an example. It does not know whether to use a method or a constructor to instantiate any bean defined in the XML configuration metadata until that XML file is read and it determines whether or not a given bean definition has the "factory-method" attribute. The XML file in not read until runtime, therefore with any given bean defined therein, Spring does not know until runtime whether to use a constructor or method.Not apt at all.
    As I already said those are two different idioms. Spring supports them because they are used to solve different problems not because they wish constructors didn't exist.
    >
    The basis of OO is the "object". You can't have a method without the object in the conceptual OO model. (And in Smalltalk that is always true.)
    True, but one may not always care how the "object" is provided. When the method [Properties.load(InputStream)|http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load%28java.io.InputStream%29] is called, it isn't going to care whether the InputStream argument was instantiated by one of the FileInputStream constructors, or if it came from a [URL.openStream()|http://java.sun.com/javase/6/docs/api/java/net/URL.html#openStream%28%29] method call. It'll work with either regardless of their respective origins.
    That of course has nothing to do with anything. Unless you are suggesting that construction in any form should not exist.
    A factory is not a constructor.I'm not saying it is. I'm just pointing out a number of the similarities between the two.
    So? There are many similarities between RMI and JDBC but that doesn't mean that they should be the same.
    With your argument you can claim that construction doesn't exist because any method, regardless of intent, that uses 'new' would eliminate the need for construction. And that isn't what happens in OO languages.I wouldn't claim that construction doesn't exist in any OO language. But I do know that in ECMAScript construction exists on the basis of whether or not a method is called with the 'new' operator. So in ECMAScript a single method can also be a constructor.
    And in C++ I can entirely circumvent the object construction process. Actually I can do that in JNI as well.
    I would still be a bad idea.
    >
    They are not interchangable.Normally, no, but with a high enough level of abstraction, they can become interchangeable. Again, the Spring framework is a great example. It doesn't care if a method or a constructor is used, and it won't know which one has been chosen until runtime. I don't even think Spring checks the return type of a method, so you could use a void return type method. (Although I don't know what that would buy you because the bean would always be set to null, but still...)
    No.
    Based on that argument every possible programming problem could be solved by simply stating that one must implement the "doit()" method. One just need to generalize it enough.
    Different APIs exist because there are in fact differences not because there are similarities.
    Over generalization WILL lead to code that is hard to maintain. Actually generalization itself, even when done correctly, can lead to code that is actually more complex.
    Because construction is substantially different than calling a method. In all OO languages.Yes, construction is different, but the actual call to a constructor and a method is only syntactically different with the presence of the 'new' operator. With reflection the difference is between calling Method.invoke() and Constructor.newInstance(), and, as I mentioned earlier, there's enough similarity between the two methods that they could be called by a single method specified by a common super class.Which does not alter the fact that the process of achieving the result is fundamentally different.

  • Reg: Order in which view and controller methods executed

    Hi,
    I want to know in which order the following methods get executed in the intial stage of application.
    View wdinit()
    wddomodify()
    controller wdinit()
    and when a we press a button or something what is the order in which the following methods get executed.
    Action of corresponding button
    wddomodify()
    Thanks in advance.

    Hi Armin,
    Thanks for the reply.
    Just to make sure, Do u mean the on start of application the order is Controller Init(),View init()
    on some action the order is actionhandler, wddomodify().
    Thanks in advance.

  • Overriding Methods and super.method()

    I've got some custom classes that extend and extension of the
    MovieClip. At the end of the movieclip timeline I want the end
    users to be able to simply call myMethod to signal they are at the
    end of the timeline. Certain classes will need to do something
    things and others yet others, but they will all also need to do a
    few things in common.
    I was hoping to define the "in common" things in the super
    class and then overide the method for the extensions. So in my
    example I was hoping that an instance of Class B would do what it
    needed to do and then call the super function. However Class C has
    nothing specific itself to do and since the method wasn't overriden
    the same myMethod() on the timeline would invoke the super classes
    method.
    So the case of Class C works. But in the case of Class B. I
    get the trace that the Class B method has been called, but I don't
    get a message that Class A was called. Is there a way to make this
    idea work? Is it a good idea? What am I missing?

    Okay I've worked it out. The trick comes in with how you call
    myMethod(). On the timeline I have to be sure and use a qualified
    reference. So, this is on the of an instance of B, if I use
    myMethod();
    I only get the myMethod() from class B, but if I do:
    this.myMethod()
    I get B and A. But oddly enough if I say invoke myMethod from
    the constructor of B, I get both trace statements -- regardless of
    whether or not I use a qualified reference! Now that is strange.

  • How many reocrds update in call transaction method and session method

    The flat file having the 10 records but the flat file having the 5 th record is error so in session method how many records will  update and in call transaction how many records  will update.
    can you provide with detailed information  like in synchrnous mode and asynchronous mode
    Regards
    reddy

    hi,
    session method :up to 4 records will be updated as it is in synchronus mode.
    Call transaction method : except 5 th all 9 records will be updated as it is assyncronous method.
    Regards
    sandeep Reddy

  • Oracle forms - .find method and .select method both recognized as .find method in OATS

    Hi All,
    Am working on Oracle EBS version R12.1.3 and trying to SELECT a responsibility from List of Values (LOV) but the code is working as .find method.
    Code:
    forms.listOfValues("//forms:listOfValues").select("001_Responsibility");
    The above method is working as
    forms.listOfValues("//forms:listOfValues").find("001_Responsibility");
    Please let me know if any details are required to understand issue.
    FYI:
    OATS version 12.4.0.1.139
    EBS version R12.1.3
    Thanks and Regards,
    Vasanth Kumar S M

    I called a procedure in in-insert and on-updateWhy are you writing this code in the first place? If you have a block based on an updatable view, just let Forms do the inserts and updates.
    If it's not an updatable view, use instead of triggers on the view.
    See this current thread too:
    INSTEAD of Trigger View for an Oracle EBS New form development

  • ALV method and spool method

    Hello
    We have created a report with financial data by using method   CL_GUI_ALV_GRID.
    We want to print it by include a separator between each new value of the Account.
    So I would like to print it in the same spool order but when there is a new value into the account to create a new spool using the last spool order.
    I do not find any method to do it and I don't want to use forms to do it. There is someone can help me ?
    thanks for your help.
    Philippe
    NB: is_print gives only information for the header of the document or page and it_special_group not permittes to do it.

    You can do this by filling the IT_SORT parameter in set_table_for_first_display function.
    data :
    wa_sort type LVC_S_SORT,
    it_sort type LVC_T_SORT
    wa_sort-FIELDNAME = <Account field name>.
    wa_sort-GROUP     = '*' "New page is triggered
    wa_sort-UP        = 'X'.
    append wa_sort to it_sort
    This will trigger a new page for each new value of the account.

  • Urgent!!!   Problem on the String method and File method

    I would like to ask two questions:
    (1) From the String method, it can use .equals() method to compare two strings whether two string exactly equal or not. But what method can i use to compare two strings see whether any words exists in the string?
    (2) From the following code,
    Java.io.File outFile = new java.io.File("TestProg.java");If i would like to use a variable (e.g. let the variable be name) instead of the filename "TestProg.java", do you know how to revise the above code??
    If i write as following, is it correct???
    Java.io.File outFile = new java.io.File(""+name+"");Please help!!!

    1- To check whether a word (sunstring) exists in a longer string, you can use the following String method:
    indexOf(substring) on the string that you are searching. If the word does not exist, -1 is returned.
    2- yes you can provide a variable (of type string) in the constrcutor of File.

  • Class-data versus data and methods versus class-methods in OO ABAP

    Hi
    I was going thorugh following OO ABAP code.
    CLASS vessel DEFINITION.
      PUBLIC SECTION.
        METHODS: constructor,
                 drive IMPORTING speed_up TYPE i,
                 get_id RETURNING value(id) TYPE i.
        CLASS-METHODS: start,
                       objects,
                       inheritance,
                       interfaces,
                       events.
      PROTECTED SECTION.
        DATA: speed TYPE i,
              max_speed TYPE i VALUE 100.
      PRIVATE SECTION.
        CLASS-DATA object_count TYPE i.
        DATA id TYPE i.
    ENDCLASS.
    Whats is difference between methods and class-methods ?
    What is the difference between data and class-data ?

    Hi Rajesh,
    There are two types of componenets in a class
    1)Static components
    2) Instance components
    Instance components exist for every instance of the class, while static exist only once for any number of instances of the class.
    Components of the class are methods, attributes, events etc.
    static attributes are represented by CLASS-DATA and instance attributes are represented by DATA.
    static methods hence are done by CLASS-METHODS and can access only static attributes.
    Instance methods are done by METHODS and can access any attribute.
    For eg: supposing that in a class, there is a static attribute. Suppose after one instance is created, we are setting this static attribute value as 10. Now we are creating another instance of the same class. Now when you try to display the value of this attribute, it will be 10.ie. it needs to be initialized once and can be shared between instances.
    Just go through this document..You will get nice info from this.
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    If you want to go deeper, like object persistence and all, just refer this document.
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    Regards,
    SP.

  • Scenario in which implement or Write our own hascode and equals method

    Dear All,
    Please let me know in which circumstances we write our own Hashcode method and equals method not the default one provided by java.Kindly give me complete code and scenario.
    Thanks
    Sumit

    Thanks for your reply
    I have one more question.
    When equal method of Object class give the same result as equals we override then why should we override equals.For example see the below code
    public class EqualsTest{
    public EqualsTest() {
         super();
    public static void main(String[] args) {
    Moof one =new Moof(8);
    Moof two =new Moof(8);
    if(one.equals(two))
    System.out.println("one is equals to two");
    class Moof {
    private int moofvalue;
    Moof(int val){
    System.out.println("val inside moof constructor"+val);
    moofvalue=val;
    System.out.println("moofvalue inside moof constructor" +moofvalue);
    public int getMoofValue()
    System.out.println("moofvalue inside getmoffvalue method "+moofvalue);
    return moofvalue;
    public boolean equals(Object o)
    System.out.println("Object o in equals"+o);
    if( (o instanceof Moof) &&(( (Moof)o).getMoofValue()==this.moofvalue))
    System.out.println("true");
    return true;
    else
    System.out.println("false");
    return false;
    Here the output we get is :
    val inside moof constructor8
    moofvalue inside moof constructor8
    val inside moof constructor8
    moofvalue inside moof constructor8
    Object o in equalsMoof@119c082
    moofvalue inside getmoffvalue method 8
    true
    one is equals to two
    The last output "one is equals to two" gives the same result as overridng equals by us.So why should we override equals here.
    Thanks
    Sumit

  • How to call Instance Methods and set property values in BAPI?

    In Project systems, for the three business objects viz.
    Network, ProjectDefinition and WBS, there are two kinds of methods which are available : class methods and instance methods. We have tried calling some instance methods, for instance, BAPI_PROJECTDEF_GETDETAIL to get details pertaining to a project. While importing this BAPI, it shows two elements for mapping i.e. Current Internal Project(string) and Current External Project(string). We supplied these values for an existing project. Upon running this call through an XML client at our end, it
    returned an error "Module Unknown Exception". This general message is present on every instance method thus far. Upon searching in BAPI Explorer for Project System->ProjectDefinition->GetDetail, we found that this BAPI didn't take any input parameter.
    Following message was displayed in BAPI Exlorer for this BAPI:
    "... Obligatory import parameters are the external and internal keys CURRENTEXTERNALPROJE and CURRENTINTERNALPROJE of the project definition.The system reads parameters contained in the structure
    BAPI_PROJECT_DEFINITION_EX ..."
    i) How to supply the values of Obligatory import parameters.
    ii) What are the possible causes of this exception.
    iii) How to call an instance method. We are using same mechanism for calling class as well as instance methods so far, we have been to call only class level methods successfully. Is there anything special that we
    need to do to call instance methods.

    Hi,
    what version is the SAP PS running?  If WebAs or higher,  create an inbound synch interface containing your two parameters in the request structure and as many as you require in your response structure.  Generate an Inbound ABAP proxy, where you can plug in some code, i.e. create and instantiate an object of the required type and make the call to the BAPI.
    If SAP PS on lower than WebAs, then create a wrapper function module and make it RFC enabled.  Then plug your code in here and do the same thing.
    Watch out for commits!
    Cheers,
    Mark

  • Dif betwen BDC call transaction and session method

    Hi to all,
               This is my problem. I want to know, what is the difference between BDC call Transaction method and Session method. where the situation we can use these methods.
    I will be thankfull to all.

    Session Method :
       Asynchronous Processing.
       Transfers Data for Multiple Transactions
      Synchronous Database Update
      During Processing, No Transaction is started until the previous transction has been written to the database.
      A Batch Input Processing log is generated for each session
      Sessions can not be generated in Parallel.
      The Batch Input Porgram must not open a Session until it has closed the preceding Session.
    Call Transaction :
       Synchronous Processing.
       Transfers Data for a single transaction.
       Synchronous and Asynchronous Database updating both Possible.
       The Program Specifies which kind of updating is desired.
      Seperate LUW for the transaction.
      The System Performs a database commit immediately before and after the  CALL TRANSACTION Using Statement.
    No Batch Input Processing Log is generated.
    These are the differences between session and call transaction method.
    Call transaction is faster then session method. But usually we use session method in real time...because we can transfer large amount of data from internal table to database and if any errors in a session. Process will not complete until session get correct.

Maybe you are looking for

  • Any way to get frame accurate in icon view mode?

    Does anyone know if there is a way set frame accurate in points in icon view mode?  I know that if you are "hover scrubbing" a clip, and then click on it you can use the JKL keys to shuttle through the footage.  But is there any way to go frame-by-fr

  • Flash drive only "pretends" to eject - help!

    I am trying to transfer data from a Power Mac G5 running OS 10.3.9 to a 4 GB USB flash drive. After finishing the copying procedures, I attempt to eject the drive by dragging it to the trash bin, clicking the eject button within a finder window, or u

  • HT5887 Why doesn't AirDrop work between iOS and OSX?

    Apple has almost always never fail to seamlessly integrate its devices, until now? I understand that there is iCloud for content sharing between devices. However, AirDrop was introduced as a simpler way for users to not only share contents between th

  • Re: how to link the EKGRP to the User-ID

    Hi, The purchase group is shared by a group of buyers. How can I configure such that it would be automatically retrieve from the User who create the PO? Which configuration should I checked? Thanks

  • Error in parsing template

    Hi All! I'm experiencing really strange behavior of my adobe forms... I developed the form, deployed it, launched it several times and everything was fine. Few days after, I just changed the font size for only one text field on the form and it didn't