Super.init(config)

Hi all
Can anyone please tell me why we write this line in init()?
super.init(config)?
What does config contain???
I am really full of queries!!! :-(

Read the javadocs for the method and classes involved. Or get a servlet book.
Config is the servlet configuration from the container. The init method is just setting them for the javax.servlet.Servlet class.
MOD

Similar Messages

  • Why Do We Have To Call super.init(config); in init() method of servlet?

    Hi, everyone..
    I wonder why we call super.init(config) in init method of servlet... If i dont call it ; when i try to get servletcontext in service method it throws java.lang.NullPointerException...when we call super.init() , what is happening behind the scene? If anybody has a technical explanation for my question , i will be very pleased...
    THX FOR YOUR FUTURE REPLIES IN ADVANCE....

    I am sorry about the uppercases and i dont want to seem smart on java forums... Anyway, m8 this is the thing that i know... i meant; for instance when we override doGet or doPost method ; we dont need to override init method; but the server loads the servlet and we can get the context of the servlet in these methods easily by calling getServletContext() method; however when we want to call service method implicitly by jndi, servlet needs to be loaded and init method must call its parent...(i also write down in web.xml <load-on-startup>.... for that servlet).
    thx for your replies in advance....

  • Clear my doubts  Developer super.init(config);

    When do we need to override super.init(config); method also what is the difference b/w in overriding doget and dopost methods
    Thanks in advance.

    override init when you need to do something on initialisation, like say, initialising a counter (it's kind of like a static initialiser).
    doGet responds to HTTP get requests, doPost responds to HTTP post requests.
    Read RFC2616 for more info.

  • A serious problem occurred while installing the iPlanet Messaging Server Init Config

    Hi I have this error while working with iMS5.x and iAS6.5. As long as iMS is the only product installed, nothing is the problem. If I try installing iMS after iAS installed, it points an error. I dont know whats the reason. The following is the message that I got:
    <b>
    A serious problem occurred while installing the iPlanet Messaging Server Init Co
    nfig. It reported the following problem:
    The application command "jre -cp "/train/iplanet/server5/bin/msg/imta/classes/im
    taconfig.jar" com.iplanet.msg.imta.config.InitConfig -d iplanet1.com -r iplanet1
    .com -h shivaram.sun.com -c /train/iplanet/server5/msg-shivaram-2/imta/config" c
    ould not be run.
    Press any key to continue.
    ON PRESSING ANY KEY, I GET...
    Due to a serious problem the iPlanet Messaging Server installer is unable to con
    tinue. Please examine the log file "/train/iplanet/server5/setup/msg/iplanet-ms
    g-install.log" for more information.
    Press any key to continue.
    </b>
    The content of "/train/iplanet/server5/setup/msg/iplanet-msg-install.log" file is:
    <b>
    Installer log started.
    GMT: 20020426225748Z
    NOTICE: Creating Common Product Configuration.
    NOTICE: Running Directory Setup.
    MESSAGE: running command
    /train/iplanet/server5/install/perl /train/iplanet/server5/bin/msg/install/bin/ims_dssetup.pl -i yes -c /train/iplanet/server5 -d slapd-shivaram -r "o=internet" -u "o=isp" -s yes -S /train/iplanet/server5/bin/msg/install/bin/config
    cmdpath: none
    runpath: none
    NOTICE: Creating Messaging Product Information in LDAP.
    NOTICE: Creating Messaging users/groups information in LDAP.
    NOTICE: Creating Messaging file links.
    NOTICE: Running PostInstall Product After Hook.
    MESSAGE: running command
    perl prod-post-aft-hook.pl /train/iplanet/server5
    cmdpath: /train/iplanet/server5/install
    runpath: /train/iplanet/server5/bin/msg/install/bin
    NOTICE: Creating Instance Name.
    NOTICE: Creating Messaging Common Instance Files.
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/configutil /train/iplanet/server5/msg-shivaram-2/configutil
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/counterutil /train/iplanet/server5/msg-shivaram-2/counterutil
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/expire /train/iplanet/server5/msg-shivaram-2/expire
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/getconf /train/iplanet/server5/msg-shivaram-2/getconf
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/refresh /train/iplanet/server5/msg-shivaram-2/refresh
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/setconf /train/iplanet/server5/msg-shivaram-2/setconf
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/start-msg /train/iplanet/server5/msg-shivaram-2/start-msg
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/stop-msg /train/iplanet/server5/msg-shivaram-2/stop-msg
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/start-ens /train/iplanet/server5/msg-shivaram-2/start-ens
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/stop-ens /train/iplanet/server5/msg-shivaram-2/stop-ens
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/README.txt /train/iplanet/server5/msg-shivaram-2/README.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imsimta /train/iplanet/server5/msg-shivaram-2/imsimta
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/ChannelDefaults.opt /train/iplanet/server5/msg-shivaram-2/imta/config/ChannelDefaults.opt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/big5.txt /train/iplanet/server5/msg-shivaram-2/imta/config/big5.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/cns11643.txt /train/iplanet/server5/msg-shivaram-2/imta/config/cns11643.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/gb2312.txt /train/iplanet/server5/msg-shivaram-2/imta/config/gb2312.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/jis0208.txt /train/iplanet/server5/msg-shivaram-2/imta/config/jis0208.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/jis0212.txt /train/iplanet/server5/msg-shivaram-2/imta/config/jis0212.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/ksx1001.txt /train/iplanet/server5/msg-shivaram-2/imta/config/ksx1001.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/charnames.txt /train/iplanet/server5/msg-shivaram-2/imta/config/charnames.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/charsets.txt /train/iplanet/server5/msg-shivaram-2/imta/config/charsets.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/charsets_ps.txt /train/iplanet/server5/msg-shivaram-2/imta/config/charsets_ps.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/charsubs.txt /train/iplanet/server5/msg-shivaram-2/imta/config/charsubs.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/countries.txt /train/iplanet/server5/msg-shivaram-2/imta/config/countries.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/dirsync.opt /train/iplanet/server5/msg-shivaram-2/imta/config/dirsync.opt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/dispatcher.cnf /train/iplanet/server5/msg-shivaram-2/imta/config/dispatcher.cnf
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/dl_auth.map /train/iplanet/server5/msg-shivaram-2/imta/config/dl_auth.map
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/dns_canonical.rules /train/iplanet/server5/msg-shivaram-2/imta/config/dns_canonical.rules
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/imta_tailor /train/iplanet/server5/msg-shivaram-2/imta/config/imta_tailor
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/internet.rules /train/iplanet/server5/msg-shivaram-2/imta/config/internet.rules
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/job_controller.cnf /train/iplanet/server5/msg-shivaram-2/imta/config/job_controller.cnf
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/languages.txt /train/iplanet/server5/msg-shivaram-2/imta/config/languages.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/magic.dat /train/iplanet/server5/msg-shivaram-2/imta/config/magic.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/maximum.dat /train/iplanet/server5/msg-shivaram-2/imta/config/maximum.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/maximum_charset.dat /train/iplanet/server5/msg-shivaram-2/imta/config/maximum_charset.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/maximum_command.dat /train/iplanet/server5/msg-shivaram-2/imta/config/maximum_command.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/name_content.dat /train/iplanet/server5/msg-shivaram-2/imta/config/name_content.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/option_charset.dat /train/iplanet/server5/msg-shivaram-2/imta/config/option_charset.dat
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_bounced.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_bounced.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_deferred.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_deferred.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_delayed.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_delayed.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_delivered.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_delivered.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_failed.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_failed.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_forwarded.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_forwarded.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_header.opt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_header.opt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_prefix.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_prefix.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_suffix.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_suffix.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/config/locale/C/LC_MESSAGES/return_timedout.txt /train/iplanet/server5/msg-shivaram-2/imta/config/locale/C/LC_MESSAGES/return_timedout.txt
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/bin/sendmail /train/iplanet/server5/msg-shivaram-2/imta/bin/sendmail
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/bin/cshrc /train/iplanet/server5/msg-shivaram-2/imta/bin/cshrc
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/imta/bin/kshrc /train/iplanet/server5/msg-shivaram-2/imta/bin/kshrc
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/attach_fs.html /train/iplanet/server5/msg-shivaram-2/html/attach_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/collect_fs.html /train/iplanet/server5/msg-shivaram-2/html/collect_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/comp_fs.html /train/iplanet/server5/msg-shivaram-2/html/comp_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fldr_fs.html /train/iplanet/server5/msg-shivaram-2/html/fldr_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/frame.html /train/iplanet/server5/msg-shivaram-2/html/frame.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ldap_fs.html /train/iplanet/server5/msg-shivaram-2/html/ldap_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/mbox_fs.html /train/iplanet/server5/msg-shivaram-2/html/mbox_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/msg_fs.html /train/iplanet/server5/msg-shivaram-2/html/msg_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/opts_fs.html /train/iplanet/server5/msg-shivaram-2/html/opts_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/receipt_fs.html /train/iplanet/server5/msg-shivaram-2/html/receipt_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/compRecipient.js /train/iplanet/server5/msg-shivaram-2/html/compRecipient.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/editPabEntry.js /train/iplanet/server5/msg-shivaram-2/html/editPabEntry.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/form.js /train/iplanet/server5/msg-shivaram-2/html/form.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/editPabGroup.js /train/iplanet/server5/msg-shivaram-2/html/editPabGroup.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/lookup.js /train/iplanet/server5/msg-shivaram-2/html/lookup.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/main.js /train/iplanet/server5/msg-shivaram-2/html/main.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/pab.js /train/iplanet/server5/msg-shivaram-2/html/pab.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/util.js /train/iplanet/server5/msg-shivaram-2/html/util.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/en/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/default.html /train/iplanet/server5/msg-shivaram-2/html/en/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/en/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/en/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/en/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/mail.html /train/iplanet/server5/msg-shivaram-2/html/en/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/en/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/help2.htm /train/iplanet/server5/msg-shivaram-2/html/en/help2.htm
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/ix.htm /train/iplanet/server5/msg-shivaram-2/html/en/ix.htm
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/topics.htm /train/iplanet/server5/msg-shivaram-2/html/en/topics.htm
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/i18n.js /train/iplanet/server5/msg-shivaram-2/html/en/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/en/iplanet.jpg /train/iplanet/server5/msg-shivaram-2/html/en/iplanet.jpg
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/ja/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/default.html /train/iplanet/server5/msg-shivaram-2/html/ja/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/ja/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/ja/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/ja/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/mail.html /train/iplanet/server5/msg-shivaram-2/html/ja/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/ja/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ja/i18n.js /train/iplanet/server5/msg-shivaram-2/html/ja/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/ko/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/default.html /train/iplanet/server5/msg-shivaram-2/html/ko/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/ko/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/ko/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/ko/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/mail.html /train/iplanet/server5/msg-shivaram-2/html/ko/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/ko/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/ko/i18n.js /train/iplanet/server5/msg-shivaram-2/html/ko/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/de/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/default.html /train/iplanet/server5/msg-shivaram-2/html/de/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/de/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/de/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/de/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/mail.html /train/iplanet/server5/msg-shivaram-2/html/de/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/de/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/de/i18n.js /train/iplanet/server5/msg-shivaram-2/html/de/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/fr/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/default.html /train/iplanet/server5/msg-shivaram-2/html/fr/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/fr/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/fr/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/fr/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/mail.html /train/iplanet/server5/msg-shivaram-2/html/fr/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/fr/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/fr/i18n.js /train/iplanet/server5/msg-shivaram-2/html/fr/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/es/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/default.html /train/iplanet/server5/msg-shivaram-2/html/es/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/es/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/es/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/es/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/mail.html /train/iplanet/server5/msg-shivaram-2/html/es/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/es/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/es/i18n.js /train/iplanet/server5/msg-shivaram-2/html/es/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/default.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/editPabGroup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/lookup_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/lookup_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/mail.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/mail.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/pab_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-CN/pab_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-CN/i18n.js /train/iplanet/server5/msg-shivaram-2/html/zh-CN/i18n.js
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-TW/compRecipient_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-TW/compRecipient_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-TW/default.html /train/iplanet/server5/msg-shivaram-2/html/zh-TW/default.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-TW/editPabEntry_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-TW/editPabEntry_fs.html
    cmdpath: none
    runpath: none
    MESSAGE: running command
    cp /train/iplanet/server5/bin/msg/install/templates/msg-inst/msg/html/zh-TW/editPabGroup_fs.html /train/iplanet/server5/msg-shivaram-2/html/zh-TW/editPabGroup_fs.html
    cmdpath: none

    You are probably installing on a hardened machine.
    The "installation guide" says that if you are doing so, you need to create a file named libx11.so.4 and update your LD_LIBRARY_PATH (see http://docs.iplanet.com/docs/manuals/messaging/ims52/ig/unix/overview.htm)but:
    1- the library name is libX11.so.4 and
    2- for jre a common file is not enough, you need to install SUNWxwplt at least. This will install the library on /usr/openwin/lib.
    You can check the results running <server-root>/bin/base/jre/bin/jre
    Hope that helps and sorry about my poor english.

  • Init-params in web.xml are not loaded (Tomcat 4)

    Hello all...
    I register a servlet in webapps/<my-servlet>/WEB-INF/web.xml file, and pass 1 <init-param> tag. The file gets parsed (I know because when I made errors tomcat complained during initialization). However, when in the init method of the servlet I try to access this parameter, its not there. In fact, the servlet has NO init params at all.
    =================================================
    I have the following web.xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>XServlet</servlet-name>
    <servlet-class>com.fxcm.xml.xengine.xdas.XServlet</servlet-class>
    <init-param>
    <param-name>xengine.configFile</param-name>
    <param-value>c:/projects/re/das.config/config.xng</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
         <servlet-name>XServlet</servlet-name>
         <url-pattern>/xservlet</url-pattern>
    </servlet-mapping>
    </web-app>
    =======================================================
    I have the following servlet
    * XServlet.java
    * Created on May 6, 2002, 1:17 PM
    package com.fxcm.xml.xengine.xdas;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletConfig;
    import java.util.Enumeration;
    import com.fxcm.xml.xengine.XEngine;
    public class XServlet extends HttpServlet{
    /** Initiates new XServlet */
    public void init(ServletConfig config)
    throws ServletException
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();){
    //This statement never gets printed because the loop never enters here since there are no init parameters
                   System.out.println(e.nextElement());
    super.init(config);
    String str = config.getInitParameter("xengine.configFile");
    System.out.println(str);
    XEngine.init(str.trim()); //This line throws NullPointer, because str is null since there are no initParameters.
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException{
    // res.setContentType( );
              System.out.println("Got post request in XServlet");
    PrintWriter out = res.getWriter();
    out.println(XEngine.process(req.getInputStream()));
    out.flush();
    out.close();
    ================================================================
    I get the follwoing error in the browser:
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
         at com.fxcm.xml.xengine.xdas.XServlet.init(Unknown Source)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:655)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:400)
    Please help.
    Thank you,
    Elana

    I know what the problem is. If you call servlet with the default URL (http://host/app/servlet/package.Servlet) than Servlet DOES NOT read init parameters. I don't know why it was designed this way.
    To make servlet read init parameters, you have to assign it a name and then call it with that name, like this:
    <servlet>
    <servlet-name>ServletName</servlet-name>
    <servlet-class>package.ServletClass</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ServletName</servlet-name>
    <url-pattern>/app/path/ServletName</url-pattern>
    </servlet-mapping>
    You can then call servlet using path specified in url-pattern and read init parameters in the normal way.

  • Empty init() methods

    I am currently working on and cleaning up (old) Java servlet code that I inherited from another collegue. In a lot of the servlets, I find empty init() methods like:
    public void init() {
    }As a novice to Java servlets, I have just been reading the First Edition of Jason Hunter's 'Java Servlet Programming' book. There, on page 59 it is stated that every servlet's init() method should call super.init(config) as its first action. I was wondering if I could simply remove the empty init() methods that I encounter in the servlets... If i remove them, the init() method of the superclass will get called... and the behaviour of the superclass init() might be slightly different than an emtpy init() method... isn't it? But I wonder if it will make a big deal for my application...
    Are there any possible side effects to expect here? What could probably happen if remove the empty init() methods and consequently start using the init() method from the superclass?

    OK. Yesterday, I cleaned up all empty init() methods, now it's time for cleaning up all unnecessary init(ServletConfig cfg) methods. In the servlet code that i inherited from a collegue, I find a lot of servlets containing the following:
        public void init(ServletConfig cfg) throws ServletException {
            super.init(cfg);
        }In the meanwhile, i know that we are using Tomcat 5.5 as a container, so I looked into the Tomcat HttpServlet implementation and I found no init(ServletConfig cfg). I then looked at GenericServlet where i found:
        public void init(ServletConfig config) throws ServletException {
            this.config = config;
            this.init();
        }and since the init() method also doesn't do much, i think i can safely remove all
        public void init(ServletConfig cfg) throws ServletException {
            super.init(cfg);
        }methods in our own servlets... since what they do is actually just the same as the init(ServletConfig cfg) method from GenericServlet.
    Can somebody who is more experienced in Java Servlets than me confirm?
    Thanks!
    Bart

  • How servlet's init method is overridden ?

    Here is a sample code to override servlet's init method.
    public class BookDBServlet ... {
            private BookstoreDB books;
            public void init(ServletConfig config) throws ServletException {
                // Store the ServletConfig object and log the initialization
                super.init(config);
                // Load the database to prepare for requests
                books = new BookstoreDB();
        }I dont get why super.init(config); is called.
    Comment says +// Store the ServletConfig object and log the initialization+
    what does "Store" mean here ? Where it is stored ?
    how it is logged ( log4j / commons -logging ? ) and where (which file) it is logged ?
    Can we remove this line without any damage ?

    There are several calls you can make to the servlet object which are simply delegated to the ServletConfig object, most notably getServletContext(). The default action of the init(SerletConfig config) method is to store the config in a field which is defined in GenericServlet, so that these calls can work. If you don't do this then calling getServletContext() at some later time will give you a NullPointerException.
    I think the reference to logging is that, if you use the built in servlet logging system, rather than log4j or java.util.loging then this depends on a valid servlet context, which in turn, depends on a valid servlet config reference.

  • Getting the HTTP server name, port and context name inside the init()

    I have a servlet which is initialized when the Web server comes up. Is there any way I can print the complete URL from this servlet?
    I am aware that this can be done by using request object. But note that in this case, there is no request object. All we have is the ServletConfig and ServletContext.
    Pasting a part of my code here.
    public class MyInit extends HttpServlet
    private ServletContext m_servletContext = null;
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    m_servletContext = config.getServletContext();
    //System.out.println("Print the URL here...")
    }

    Only a request has a URL. It's possible for servlets to be mapped to respond to more than one URL, and the server can be configured to respond to more than one host and at more than one port. So none of those things you are asking for have any meaning without an actual request.

  • Multpile inits being called in Servlet

    I am trying to create one thread which will be executed once Jakarta-Tomcat begins execution. To do this I have the following code:
    web.xml
      <servlet>
        <servlet-name>initializecontroller</servlet-name>
        <servlet-class>roverlook.InitializeController</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>     
    InitializeController.java
    public class InitializeController extends HttpServlet {
      public void init(ServletConfig config) throws ServletException {
        super.init(config);
        Daemon.INSTANCE.start(); // start daemon thread
    Daemon.java
    public class Daemon extends Thread{
      public static final Daemon INSTANCE = new Daemon(null); // singleton
      public synchronized void run  () {
         while(true) {
            LoggerCentral.info("Daemon executing required jobs at "+ (new java.util.Date()).toString(), null);
            // do work here
            try {
           Thread.sleep(1000*60);       
            } catch (InterruptedException e) {
                LoggerCentral.exception("Daemon:run():sleep interrupted", null);
        }         When I run Jakarta-Tomcat, I can see the Daemon writing once every ~1 minute as expected. However, when I run other Servlets (which aren't related to this) there are additional instances of the Daemon which are apparently created, because I see many writes to the logfile, sometimes only 1 second apart. It seems like the init() function is being called again even though I t should not be.
    To simplify things, I just put a System.out.print() statement in init() and it is in fact called multiple times! Putting a similar statement reveals that destroy() is not being called.
    I'm confused, because I thought init() was supposed to run once - Can anyone help out?
    Thanks alot

    Thank you for the good suggestion - I think I was able to make some progress. The first init() is called in
            at roverlook.InitializeController.init(InitializeController.java:37)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)which looks like normal initialization to me. The second one is:
            at roverlook.InitializeController.init(InitializeController.java:37)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
            ....     org.apache.catalina.connector.warp.WarpConfigurationHandler.deploy(WarpConfigurationHandler.java:313)
            at org.apache.catalina.connector.warp.WarpConfigurationHandler.handle(WarpConfigurationHandler.java:117)
            at org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:189)
            at java.lang.Thread.run(Thread.java:536)which makes me think it has to do with the fact that I am using Apache Tomcat as a front end and using the Warp connector. In my httpd.conf file I have the following:
    WebAppDeploy roverlook warpConnection /roverlook/
    WebAppDeploy roverlook warpConnection /roverlook/jsp/*.jspIt would appear that this warp connector is causing init() to be called more than once! (could it be in a different JVM?). I need things which are accessed via the connector to share the same space with things in tomcat that load via 'load-on-startup'.
    Any additional suggestions? Thanks.

  • Servlet init block doesn't work with getServletContext().getRequestDispat..

    Hi Everyone,
    I am getting null pointer exception when i have coded init method inside my servlet(inside that i am fetching init parameter passed from web,xml file) and while getting requestdispatcher from context.
    if i get requestdispatcher from request then it works fine. i dont understand reason behind this behaviour.
    please give your valueable comment.
    find code below:
    public void init(ServletConfig config) throws ServletException
    enum1 = config.getInitParameterNames();
    while(enum1.hasMoreElements()){
    init_paramNm = (String)enum1.nextElement();
    init_paramVal = config.getInitParameter(init_paramNm);
    System.out.println("Name = "init_paramNm" and value = "+init_paramVal);
    getting null pointer exception with this
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/ObjJSPtoServlet.jsp");
    rd.forward(request, response);
    work fine with
    RequestDispatcher rd = request.getRequestDispatcher("/ObjJSPtoServlet.jsp");
    rd.forward(request, response);

    public void init(ServletConfig config)
    throws ServletException
    Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See Servlet.init(javax.servlet.ServletConfig).
    This implementation stores the ServletConfig object it receives from the servlet container for later use. When overriding this form of the method, call super.init(config). ...
    [More Info|http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/GenericServlet.html#init%28javax.servlet.ServletConfig%29]

  • Can servlet has more than one init method...?

    Clarification 1:
    Suppose i will write init()(-without constructor) method. In this case, how servlet config object passed to init method.
    Clarification 2:
    if i will override init(ServletConfig) .why do i need to call super.init(config).
    thanks,
    JaiGaneshR

    suppose i ll override init method without constructor. //wrong
    i think u want.
    suppose i ll override init method without arguments
    then also servlet calls the init(ServletConfig) method.
    1st servlet container check in ur Servlet class for init(ServletConfig)
    it's not found.
    2.then it checks in the super class HttpServlet. it's not found.
    3.then it checks in the super class GenericServlet there it will found it.
    then it will execute.
    package javax.servlet;
    import java.io.IOException;
    import java.io.Serializable;
    import java.util.Enumeration;
    // Referenced classes of package javax.servlet:
    // Servlet, ServletConfig, ServletException, ServletContext,
    // ServletRequest, ServletResponse
    public abstract class GenericServlet
    implements Servlet, ServletConfig, Serializable
    public GenericServlet()
    public void destroy()
    public String getInitParameter(String name)
    return getServletConfig().getInitParameter(name);
    public Enumeration getInitParameterNames()
    return getServletConfig().getInitParameterNames();
    public ServletConfig getServletConfig()
    return config;
    public ServletContext getServletContext()
    return getServletConfig().getServletContext();
    public String getServletInfo()
    return "";
    public void init(ServletConfig config) *<-------------------------------------------------- called*
    throws ServletException
    this.config = config;
    init(); ---------------------------------------------------> called your override method
    public void init() *<------------------------------------------------- Not called*
    throws ServletException
    public void log(String msg)
    getServletContext().log(getServletName() + ": " + msg);
    public void log(String message, Throwable t)
    getServletContext().log(getServletName() + ": " + message, t);
    public abstract void service(ServletRequest servletrequest, ServletResponse servletresponse)
    throws ServletException, IOException;
    public String getServletName()
    return config.getServletName();
    private transient ServletConfig config;
    4. finally ur init() without arugments method will exected.
    Edited by: Lakshman.Balanagu on 26 Aug, 2008 3:43 PM
    Edited by: Lakshman.Balanagu on 26 Aug, 2008 3:44 PM

  • Init() method in Servlet

    Hi All,
    I am new in Servlet.So this question might sound silly to everyone.
    As per the init() method takes a ServletConfig object as a parameter. This reference should be stored in a member variable so that it can be used later.
    My doubt is why do we need to store the reference?

    What if you need to access the information later - init is only called once per Servlet. It is stored so you can call getServletConfig() in your Servlet and access any init params that you defined in web.xml. You do not need to store it though - GenericServlet (or HttpServlet?) will take care of it - although if you override the init method make sure you call super.init(config).
    m

  • File not found error

    I get the following error, but don't know why it can't find the file. Is there anything in this script that would call "\" instead of "/"? Is there any line of code that will switch a wayward "\" back?
    01-09-24 09:37:02 - path="" :jsp: init
    2001-09-24 09:43:42 - path="" :LoginServlet: init
    2001-09-24 09:44:15 - path="" :CourseServlet: init
    2001-09-24 09:46:48 - path="" :LessonServlet: init
    2001-09-24 09:46:54 - path="" :Error: /usr/local/apache/sites/tesco.spinweb.net/htdocs/cmi/courses\Food Service/Intro/AU00.html (No such file or directory)
    The script is below. Thanks for any help anyone can provide me.
    import cmi.xml.AU;
    import cmi.xml.Block;
    import cmi.xml.CourseReader;
    import cmi.xml.CSFElement;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.Vector;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServlet;
    import org.jdom.JDOMException;
    public class LessonServlet extends HttpServlet
    public void init (ServletConfig config) throws ServletException
    super.init (config);
    try {
                   Class.forName (GlobalData.DatabaseDriverName);
                   _jdbcConnection = DriverManager.getConnection (GlobalData.DatabaseName, "tesco", "scorm");
    _jdbcConnection.setAutoCommit (true);
    //should I do this?
    //_jdbcConnection.setAutoCommit (false);
    //load serialized course data
    loadCourseData();
              catch (Exception xcp) {
                   xcp.printStackTrace();     
                   getServletContext().log("Error: " + xcp.getMessage());     
    public void doGet( HttpServletRequest request,
                             HttpServletResponse response)
              throws ServletException, IOException
    boolean normalMode = true;
    try {
    HttpSession session = request.getSession (true);
    //can I load the session given the id??
    //System.out.println ("Lesson.valid session " + session.getId() + ": " + request.isRequestedSessionIdValid());
    response.setContentType ("text/html");
    JDBCHelper dbHelper = new JDBCHelper (_jdbcConnection);
    //get student ID
    Integer studentID = (Integer) session.getAttribute ("studentID");
    //get course ID
    Integer courseID = (Integer) session.getAttribute ("courseID");
    //get lesson ID
    String lessonID = request.getParameter ("lessonID");
    if (lessonID == null) {
    lessonID = (String) session.getAttribute ("lessonID");
    if (studentID == null || courseID == null || lessonID == null) {
    //reset session data by re-logging the user
    sendProfileError (response.getOutputStream());
    return;
    //store lesson ID in session
    session.setAttribute ("lessonID", lessonID);
    String auID = request.getParameter ("auID");
    String mode = request.getParameter ("mode");
    if (mode != null) {
    session.setAttribute ("mode", mode);
    else {
    mode = (String) session.getAttribute ("mode");
    if (mode.equalsIgnoreCase ("review")) {
    normalMode = false;
    else {
    normalMode = true;
    //synchronize access to course hash table
    synchronized (_courseHash)
    //make sure _courseHash is in tact
    if (_courseHash == null) {
    //try reloading it....
    loadCourseData();
    if (_courseHash == null) {
    //error
    response.getOutputStream().close();
    throw new IOException ("Corrupt course data");
    if (! _courseHash.containsKey (courseID.toString())) {
    //try reloading it....
    loadCourseData();
    if (! _courseHash.containsKey (courseID.toString())) {
    //error
    response.getOutputStream().close();
    throw new IOException ("Corrupt course data (course not found)");
    if (auID == null) {
    //show course menu
    Hashtable hash = (Hashtable) _courseHash.get (courseID.toString());
    sendAvailableAUs (hash, studentID.intValue(), courseID.intValue(), lessonID, response.getOutputStream(), response, dbHelper);
    return;
    //if AU has not been attempted, initialize it
    Integer auDataID = new Integer (getAUDataID (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper));
    //if (getAUDataID (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper) == -1) {
    if (auDataID.intValue() == -1) {
    int newID = initializeAUData (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper);
    dbHelper.addAUToPath (studentID.intValue(), courseID.intValue(), lessonID, auID);
    auDataID = new Integer (newID);
    session.setAttribute ("AUID", auID);
    session.setAttribute ("AUDataID", auDataID);
    sendAU (studentID.intValue(), courseID.intValue(), lessonID, auID, auDataID.intValue(), normalMode, response.getOutputStream(), dbHelper);
    //to do: detailed messages should be sent to the client depending on which
    // exception was thrown. Don't have one try/catch....have one for each situation
    catch (Exception e) {
    e.printStackTrace();
                   getServletContext().log("Error: " + e.getMessage());
    public void destroy()
              try {
                   if (_jdbcConnection != null) {
                        _jdbcConnection.close();
              catch (Exception ignored) {}
    private int initializeAUData (int studentID, int courseID, String lessonID, String auID, JDBCHelper dbHelper)
    String sqlQuery = null;
    ResultSet results = null;
    try {
    //get student's name
    sqlQuery = "SELECT Full_Name" +
    " FROM " + GlobalData.StudentTable +
    " WHERE Student_ID = " + studentID;
    results = dbHelper.doQuery (sqlQuery);
    if (! results.next()) {
    //error
    return -1;
    String studentName = results.getString (1);
    results.close();
    //the lock prevents CMIServlet from reading AU_ID before it's committed
    //sqlQuery = "LOCK TABLES " + GlobalData.AUDataTable + " WRITE;";
    //System.out.println (sqlQuery);
    //dbHelper.executeUpdate (sqlQuery);
    sqlQuery = "Insert Into " + GlobalData.AUDataTable +
    "(Course_ID, Lesson_ID, AU_ID, student_id, student_name, lesson_location, credit," +
    " lesson_status, entry, exit, score_raw, score_max, score_min, total_time," +
    " session_time, lesson_mode, suspend_data, launch_data, Evaluation_ID, Objective_ID)" +
    " Values (" + courseID + ", '" + lessonID + "', '" + auID + "', " + studentID + ", '" + studentName + "'," +
    " 'NA', 'credit'," + " 'not attempted', 'ab-initio', " + "'NA', " + 0 + ", " + 0 + ", " + 0 +
    ", '00:00:00.0', '00:00:00.0', " + " 'normal'" + ", 'NA', " + "'NA', " + 0 + ", " + 0 + ");";
    dbHelper.executeUpdate (sqlQuery);
    return getAUDataID (studentID, courseID, lessonID,auID, dbHelper);
    //sqlQuery = "UNLOCK TABLES;";
    //System.out.println (sqlQuery);
    //dbHelper.executeUpdate (sqlQuery);
    catch (Exception e) {
    e.printStackTrace();
                   getServletContext().log("Error: " + e.getMessage());
    return -1;
    private int getAUDataID (int studentID, int courseID, String lessonID, String auID, JDBCHelper dbHelper)
    throws SQLException
    String sqlQuery = "SELECT AUData_ID, lesson_status, lesson_mode, exit" +
                                  " FROM " + GlobalData.AUDataTable +
                                  " WHERE student_id = " + studentID +
                                  " AND Course_ID = " + courseID +
    " AND Lesson_ID = " + "'" + lessonID + "'" +
    " AND AU_ID = '" + auID + "';";
    ResultSet results = dbHelper.doQuery (sqlQuery);
    if (results.next()) {
    return results.getInt ("AUData_ID");
    return -1;
    private void sendAU (int studentID, int courseID, String lessonID, String auID, int auDataID, boolean normalMode, ServletOutputStream htmlOut, JDBCHelper dbHelper)
    throws IOException, ClassNotFoundException
    Hashtable hash = null;
    synchronized (_courseHash)
    hash = (Hashtable) _courseHash.get (String.valueOf (courseID));       
    if (hash == null) {
    loadCourseData();
    hash = (Hashtable) _courseHash.get (String.valueOf (courseID));
    if (hash == null) {
    throw new IOException ("Corrupt course data (course not found)");
    AU au = (AU) hash.get (auID);
    try {
    if (! normalMode) {
    dbHelper.setReviewMode (auDataID);
    String courseFileName = getFileName (String.valueOf (courseID), dbHelper);
    File file = new File (courseFileName);
    //create absolute path to file so we can resolve relative URLs
    String newFileName = file.getParent() + "\\" + au.getLaunchParams();
                   BufferedReader buf = new BufferedReader (new FileReader (newFileName));
    PrintWriter htmlWriter = new PrintWriter (htmlOut);
                   String temp;
    htmlWriter.write (getAUHtml (au.getLaunchParams()));
    htmlWriter.flush();
    htmlWriter.close();
    catch (Exception e) {
    e.printStackTrace();
                   getServletContext().log("Error: " + e.getMessage());
    private String getAUHtml (String path){
    path = path.replace ('\\','/');
    String response;
    response = "<html>\n" +
                        "<head>\n" +
    "</head>\n" +
    "<body>\n" +
    "<script language=\"JavaScript\">\n" +
    "document.location = \"/cmi/courses/" + path + "\"\n" +
    //"win = window.open ('','displayWindow','menubar=yes,scrollbars=yes,status=yes,width=300,height=300');\n" +
    //"window.onload = \"win.close();\"" +
    "</script>\n" +
    "</body>\n" +
    "</html>\n";
    return response;
    private void sendAvailableAUs (Hashtable hash, int studentID, int courseID, String lessonID, ServletOutputStream out, HttpServletResponse response, JDBCHelper dbHelper)
    StringBuffer buf = new StringBuffer (200);
    Block block = (Block) hash.get (lessonID);
    AU au = null;
    try {
    Vector completedAUs = dbHelper.getCompletedAUs (studentID, courseID, lessonID);
    buf.append ("<html>\n" +
                        "<head>\n" +
    "<title>" + block.getTitle() + " units</title>\n" +
    "<script language=\"JavaScript\">\n" +
    "function go() {\n" +
    " var form = document.goForm;\n" +
    " var index = form.gotoSelect.selectedIndex;\n" +
    " if (index == 0) {\n" +
    " document.location = \"/servlet/CourseServlet?courseID=" + courseID + "\";\n" +
    " }\n" +
    " else if (index == 1) {\n" +
    " top.restart();\n" +
    " }\n" +
    "}\n" +
    "</script>\n" +
    "</head>\n" +
    "<body background=\"/cmi/images/marble.jpg\">\n" +
    "<center><h1><b><u>" + block.getTitle() + "</u></b></h1></center>\n" +
    "<p></p>\n<p></p>\n" +
    "<b>" + block.getTitle() + " contains the following units: </b>\n" +
    "<dl>\n");
    Enumeration enum = block.getChildren();
    while (enum.hasMoreElements()) {
    String temp = (String) enum.nextElement();
    CSFElement element = (CSFElement) hash.get (temp);
    if (element.getType().equals ("au")) {
    au = (AU) element;
    if (completedAUs.contains (au.getID())) {
    buf.append ("<dt><p><img src=\"/cmi/images/node2.gif\"><a href=\"/servlet/LessonServlet?lessonID=" + block.getID() + "&auID=" + au.getID() + "&mode=review\">" + au.getTitle() + " (<i>review</i>) </a></p></dt>\n");
    else {
    buf.append ("<dt><p><img src=\"/cmi/images/node.gif\"><a href=\"" + response.encodeURL ("/servlet/LessonServlet?lessonID=" + block.getID() + "&auID=" + au.getID() + "&mode=normal") + "\">" + au.getTitle() + "</a></p></dt>\n");
    else if (element.getType().equals ("block")) {
    buf.append ("<dt><p><img src=\"/cmi/images/folder.gif\"><a href=\"" + response.encodeURL ("/servlet/LessonServlet?lessonID=" + element.getID() + "&mode=normal") + "\">" + element.getTitle() + "</a></p></dt>\n");
    buf.append ("</dl>\n" +
    "<br><br>\n" +
    "<form name=\"goForm\">\n" +
    "<select name=\"gotoSelect\">\n" +
    " <option value=\"lesson\">Lesson Menu</option>\n" +
    " <option value=\"exit\">Exit LMS</option>\n" +
    "</select>\n" +
    "<input type=\"button\" value=\"Go\" onClick=\"go()\">\n" +
    "</form>\n" +
    "</body>\n" +
    "</html>");
    PrintWriter writer = new PrintWriter (out);
    writer.write (buf.toString());
    writer.flush();
    writer.close();
    catch (Exception e) {
    e.printStackTrace();
                   getServletContext().log("Error: " + e.getMessage());
    private String getFileName (String courseID, JDBCHelper dbHelper)
    throws ClassNotFoundException, SQLException
              ResultSet results = null;
              String fileName = null;
    String sqlQuery = "SELECT CourseFile" +
                                  " FROM Course" +
                                  " WHERE Course_ID = " + Integer.parseInt (courseID) + ";";
    results = dbHelper.doQuery (sqlQuery);
              if (results.next()) {
                   fileName = results.getString (1);
              else {
    //need to do more than this :)
                   System.out.println("crap");
    results.close();
    return fileName;
    private void loadCourseData()
    throws IOException, ClassNotFoundException
    //load serialized course data
    File file = new File (GlobalData.DataFileName);
    if (! file.exists()) {
    //error
    throw new FileNotFoundException (GlobalData.DataFileName + " not found.");
    FileInputStream fis = new FileInputStream (GlobalData.DataFileName);
    ObjectInputStream ois = new ObjectInputStream (fis);
    _courseHash = (Hashtable) ois.readObject();
    ois.close();
    private void sendProfileError (ServletOutputStream out)
    String html = "<html>\n" +
    "<body>\n" +
    "<p>An error has occurred with your profile. Please " +
    "<a href=\"\" onClick=\"top.restart(); return true\">login again</a>" +
    "</body>\n" +
    "</html>\n";
    PrintWriter writer = new PrintWriter (out);
    writer.write (html);
    writer.flush();
    writer.close();
    private Connection _jdbcConnection;
    private Hashtable _courseHash;

    I know that is where my error is, but why and where is
    the script calling it up way?You wrote it right? check out the sendAU() method, there is line
    String newFileName = file.getParent() + "\\" + au.getLaunchParams();

  • Upload multiple files WITH correct pairs of form fields into Database

    In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
    INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
    INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
    INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
    However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
    if(item.isFormField()){
    }else{
    }I seems to be restricted from this structure.
    The jsp form page
    <input type="text" name="description1" value="" />
    <input type="file" name="sourcefile" value="" />
    <input type="text" name="description2" value="" />
    <input type="file" name="sourcefile" value="" />The Servlet file
    package Upload;
    import sql.*;
    import user.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Date;
    import java.util.List;
    import java.util.Iterator;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.*;
    public class UploadFile extends HttpServlet {
    private String fs;
    private String category = null;
    private String realpath = null;
    public String imagepath = null;
    public PrintWriter out;
    private Map<String, String> formfield = new HashMap<String, String>();
      //Initialize global variables
      public void init(ServletConfig config, ServletContext context) throws ServletException {
        super.init(config);
      //Process the HTTP Post request
      public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        Thumbnail thumb = new Thumbnail();
        fs = System.getProperty("file.separator");
        this.SetImagePath();
         boolean isMultipart = ServletFileUpload.isMultipartContent(request);
         if(!isMultipart){
          out.print("not multiple part.");
         }else{
             FileItemFactory factory = new DiskFileItemFactory();
             ServletFileUpload upload = new ServletFileUpload(factory);
             List items = null;
             try{
                items = upload.parseRequest(request);
             } catch (FileUploadException e) {
                e.printStackTrace();
             Iterator itr = items.iterator();
             while (itr.hasNext()) {
               FileItem item = (FileItem) itr.next();
               if(item.isFormField()){
                  String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
                  formfield.put(item.getFieldName(),formvalue);
                  out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
               }else{
                 String itemName = item.getName();
                 String filename = GetTodayDate() + "-" + itemName;
                 try{
                   new File(this.imagepath + formfield.get("category")).mkdirs();
                   new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
                   //Save the file to the destination path
                   File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
                   item.write(savedFile);
                   thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
                   DBConnection db = new DBConnection();
                   String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
                   db.SelectQuery(sql);
                    while(db.rs.next()){
                      int cat_id = db.rs.getInt("id");
                      sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
                      out.println(sql);
                      db.RunQuery(sql);
                 } catch (Exception e){
                    e.printStackTrace();
            HttpSession session = request.getSession();
            UserData k = (UserData)session.getAttribute("userdata");
            k.setMessage("File Upload successfully");
            response.sendRedirect("./Upload.jsp");
      //Get today date, it is a test, actually the current date can be retrieved from SQL
      public String GetTodayDate(){
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        String today = format.format(new Date());
        return today;
      //Set the current RealPath which the file calls for this file
      public void SetRealPath(){
        this.realpath = getServletConfig().getServletContext().getRealPath("/");
      public void SetImagePath(){
        this.SetRealPath();
        this.imagepath = this.realpath + "images" +fs;
    }Can anyone give me some code suggestion? Thx.

    When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
    In any case you may look at how you are Uploading Multiple Files with mod_plsql.

  • INSERT INTO statement in java servlet.

    Hiya
    Was wondering if anyone knew how to use variables from an html form into a sql insert into statement? The constants work ok below, its just getting the variables to work.
    //constants work ok.
    rs = stmt.executeQuery("INSERT INTO ACCOUNTS " + " VALUES ('un', 'test2', 'test2', 'test2', 'test', 'test', 'test', 'test', 'test')");
    //doesn't do anything no errors.
    rs = stmt.executeQuery("INSERT INTO ACCOUNTS " + " VALUES ( '"+uname+"', " + " '"+fname+"', " + " '"+sname+"'," + "'"+address1+"'," + "'"+address2+"'," + "'"+town+"'," + "'"+county+"'," + "'"+postcode+"')");

    <html>
    <head>
    <title>
    CreateAccount
    </title>
    </head>
    <body>
    <form method=get action=/servlet/website.CreateAccount>
    <p> Username:
    <input type=text name="username"> </p>
    <p> Password:
    <input type=text name="password"> </p>
    <p> First Name:
    <input type=text name="firstname"> </p>
    <p> Surname:
    <input type=text name="surname"> </p>
    <p> 1st Line of Address:
    <input type=text name="1address"> </p>
    <p> 2nd Line of Address:
    <input type=text name="2address"> </p>
    <p> Town:
    <input type=text name="town"> </p>
    <p> County:
    <input type=text name="county"> </p>
    <p> Postcode:
    <input type=text name="postcode"> </p>
    <input type=submit>
    </form>
    </body>
    </html>
    package website;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class CreateAccount extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html";
      /**Initialize global variables*/
      public void init(ServletConfig config) throws ServletException {
        super.init(config);
      /**Process the HTTP Get request*/
      public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        ResultSet rs = null;
        Connection con = null;
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        //get the variables  entered in the form
        String uname = req.getParameter("username");
        String pwd = req.getParameter("password");
        String fname = req.getParameter("firstname");
        String sname = req.getParameter("surname");
        String address1 = req.getParameter("1address");
        String address2 = req.getParameter("2address");
        String town = req.getParameter("town");
        String county = req.getParameter("county");
        String postcode = req.getParameter("postcode");
        try {
          // Load the database driver
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          // Get a Connection to the database
          con = DriverManager.getConnection("jdbc:odbc:account", "", "");
          //Add the data into the database
    try
                String sql = "INSERT INTO ACCOUNTS " + " VALUES (?,?,?,?,?,?,?,?)";
                PreparedStatement statement = con.prepareStatement(sql);
                statement.setString(1, uname);
                statement.setString(2, fname);
                statement.setString(3, sname);
                statement.setString(4, address1);
                statement.setString(5, address2);
                statement.setString(6, town);
                statement.setString(7, county);
                statement.setString(8, postcode);
                int numRowsChanged = statement.executeUpdate(sql);
                statement.close();
    //Statement stmt = null;
    //stmt = con.createStatement();
    //Create a Statement object
    //constants work ok.
    //rs = stmt.executeQuery("INSERT INTO ACCOUNTS " + " VALUES ('uname', 'test2', 'test2', 'test2', 'test', 'test', 'test', 'test', 'test')");
    catch (Exception e)
          // show that the new account has been created
          out.println("<p> New account created: </p>");
          out.println(" '"+uname+"'");
        catch(ClassNotFoundException e) {
          out.println("Couldn't load database driver: " + e.getMessage());
        catch(SQLException e) {
          out.println("SQLException caught: " + e.getMessage());
        finally {
          // Always close the database connection.
          try {
            if (con != null) con.close();
          catch (SQLException ignored) { }
    }ok now the regular statement with constant values inserts data into the database (the regular statement is being used with a result set ) but the prepared statement does not - there are no error messages but it does not insert any data either. The data is going into the variables due to the system.out.println, but is it going into the prepared statement? I believe the prepared statement is being executed with the executeupdate method.

Maybe you are looking for

  • How do I get music to stop in Safari from a website that has been closed?

    I have played a mahjong game in www.mahjonggames.com which has accompanying music, using my Safari browser.  When I close the site, the music doesn't stop.  I have cleared the caches and that didn't help.  Any suggestions?

  • How to permanently close the right Toolbar in Adobe Reader DC?

    How can i permanently close the toolabr ind the new Reader App? I don`t need those tools and it cuts off valuable space on my display.

  • Photoshop Elements 11 will not download

    I have been trying to download Photoshop Elements 11 for a couple of hours and have not had any success.  I keep getting the popup after the installation has started that says - Elements Auto Analyzer. exe.dynamic link manager - is using files that n

  • Help with errors on opening Dreamweaver

    On opening DW (v. CS3), I get an error message that says: quote: The following translators were not loaded due to errors: XSLTransform.htm: has configuration information that is invalid" It takes a couple of times of clicking "OK" to get that one to

  • How do I forward email to a group?

    I have GContact Lite with names assigned to groups.  When I want to forward an email, I can bring up the group by tapping the + sign on the To: line but can't see what to do next to send it to the group.