The init() method

hi,
i'm reading a book that in the beginning showed the init method as:
public void init(ServletConfig config) throws ServletExceptionbut later when discussing jdbc the author mentions that loading the driver should be done in the init method since this way it can be loaded once the servlet is loaded, but in that example the init method signature is:
public void init() {
}there's no parameter or error thrown.
so i'm confused are both signatures ok, or is one wrong?

Both is correct, and init() is a shortcut. See http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/GenericServlet.html#init()

Similar Messages

  • The Init() method of abstract pagebean always it excute, and i lost data.

    Hi,
    I have applicaction to buid in NetBean 6.1 and JDK 1.6 using Visual Web Java Server Pages. This application to present a view that have a 2 calendar component, 1 dropdownlist, button component and table component.
    The table component show rows where calendar1.date > date1 and calendar2.date < date2 and estado(DropDownList)= status1
    In the init() method of abstractpagebean i set de initial calendar's date that follow
    java.util.Calendar dateAntes = GregorianCalendar.getInstance();
    java.util.Calendar date = GregorianCalendar.getInstance();
    dateAntes.add(java.util.Calendar.MONTH, -1);
    GregorianCalendar gc = new GregorianCalendar(2000, 11, 20);
    //tablePhaseListener = getSessionBean1().getTablePhaseListener();
    calendar1.setSelectedDate(dateAntes.getTime());
    calendar2.setSelectedDate(date.getTime());
    With this initial dates dates i show the table row thw follow
    String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
    "requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
    "FROM requerimiento,cliente,estado " +
    "WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
    "AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";
    try {
    getSessionBean1().getRequerimientoRowSet().setCommand(command);
    getSessionBean1().getRequerimientoRowSet().getCommand();
    getSessionBean1().getRequerimientoDataProvider().refresh();
    } catch (Exception e) {
    error("No puede levantar comando");
    log("Cannot switch to person " +
    estados.getSelected().toString(), e);
    The DropDownList implement the ProcessValueChange Event with AutoSubmit On Change properties. At Change choise of DropDown List Component it trigger a event that and execute estados_processValueChange method that to show a table rows accord to the new filter (include the new calendar date if necessary that follow:
    String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
    "requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
    "FROM requerimiento,cliente,estado " +
    "WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
    "AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";
    try {
    getSessionBean1().getRequerimientoRowSet().setCommand(command + " AND requerimiento.codestado =" + "'" + (String) estados.getSelected() + "'");
    getSessionBean1().getRequerimientoRowSet().getCommand();
    getSessionBean1().getRequerimientoDataProvider().refresh();
    } catch (Exception e) {
    error("No puede levantar comando");
    log("Cannot switch to person " +
    estados.getSelected().toString(), e);
    The Table component have a column of checkbox type for select a particular(s) row(s). With a Button it to choose all the rows that has been to set checkbox, in the session bean to save this selected rows and link to another page that show the details about seletec rows.
    The Problem
    Every time that i press the button, after to the select the rows, for another page showme detail, this page is empty because it execute the init method before the button_action, to re initialize and erase the user selection and lost it
    I try with another component that trigger event, por exmaple dropdownlist, and it the same, even to press the pagin in teh table it execute init meth, re-initialize and erase all.
    Result prove
    1.- I execute the application for first time:
              Execute      Init()
    2.- I Chage choos en the DropDownList
              Execute      Init() and
              after           estado_processValueChange()
    3.- I change choos again in the DropDownList
              Execute      Init() and
              after           estado_processValueChange()
    4.- I press pagin button in table
              Execute      Init()
    5.- I press button detail, for detail
         Execute      Init() ----> I reinitialize and lost the user select.
         after          Butoon_action
    How ia can to preven that every time it execute init(),
    Why alway it execute init method?, the init methd() is for initialize application and not RE INTIALIZED
    Why is the relation INIT(); PREPROCESS(), PRERENDER(), PROCESSVALUECHANGE, BUTTON_ACTION. What it execute first, what secodn?
    I need execute init method only one , at first time
    I hope i undertandme, i not native english.
    Thank for advance

    Anupama,
    Do you mean init or wdDoInit? You cannot call the later as well as you cannot call any WD-framework methods that start with "wd" prefix.
    By the way, wdDoInit in component controller (do not confuse with custom controller or interface controller) is called before any other method in any controller. So I hardly believe that it is not called when your view become available.
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • Why there are two init methods?

    I copied this code from netbeans for a JApplet.. and it has two init methods
    One is public void init() that calls another initComponents() method.
    And the initComponents() method has all the components defined in it, and it is private.
    I replaced private with public and changed initComponents to init, and then deleted all the init method, it worked that way.
    But why there two methods when you can put every thing in single init() method?
    The init() method has this code in it:
    public void init() {
            try {
                java.awt.EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        initComponents();
            } catch (Exception ex) {
                ex.printStackTrace();
        }

    BDLH:
    WWJD? Probably code in Ruby, but I digress. No, he would define an abstract base for that boilerplate code:
    import java.awt.*;
    import java.lang.reflect.*;
    import javax.swing.*;
    public abstract class AbstractApplet extends JApplet {
         public void init() {
              try {
                   EventQueue.invokeAndWait(new Runnable() {
                        public void run() {
                             initComponents();
              } catch (InterruptedException ex) {
                   ex.printStackTrace();
              } catch (InvocationTargetException ex) {
                   ex.printStackTrace();
         protected abstract void initComponents();
         //ditto: start, stop, distroy
    }

  • LDAP Context Initialization Problem in a Servlet's Init method

    Hi
    I have a servlet where I am using the InitialDirContext to Initialize context to a LDAP Server. I have created the context as a static variable. I am initializing the context in the init method and am using the same reference in the service method of the servlet. But if the context fails (due to naming exception and time out) in the init method all my requests in the service method will fail. Is there any way to validate the reference before using the same in the service method.
    Also what is the best approach to initialize the context in a servlet. Whether to initialize in the service method or the init method.
    I would appreciate if anyone can answer the above 2 queries.
    Thanks in advace,
    Ashish

    If you want to use threadsafe objects in doPost/doGet there are two common ways to do this.
    First, create the object in doPost/doGet. This may get expensive depending on the object, but it is 'easy' code and works.
    The second option is to create a pool of objects in the servlet's init() method and to just have doPost/doGet get an object from the pool, use it and return it when done. This take a little more work to code, but the overhead of creating objects is almost eliminated. Look at jakarta/apache commons pool for a quick way to do this.
    If you create on object in init() and use it in doPost/doGet, any time you get two request for the same servlet at the same time you will have synchronization issues that will usually cause problems. There is one instance of each Servlet, so all request for that servlet go through the single instance. Anything in doPost/doGet must be threadsafe.

  • How to write custom prerender or init  method?

    some ide provide override prerender() and init() methods,i can use this methods,
    i use differnt ide but i didnt find prerender and init methods ,so i try to write these but i couldnt.
    i did ;
    1) write phaselistener
    2) and extends my beans with phaselistener
    public class phases implements PhaseListener {
    public phases() {
    public void init() {
    System.out.println("/******************phase****init*****************************");
    public void afterPhase(PhaseEvent phaseEvent) {
    public void beforePhase(PhaseEvent event) {
    if (event.getPhaseId()==PhaseId.RESTORE_VIEW) {/// this mean is page init
    init();
    protected boolean isPostBack() {
    if (getFacesContext().getRenderResponse())
    return false;
    else
    return true;
    and my bean is ;
    public class login extends phases {
    @Override
    public void init() {
    System.out.println("/**********************init*****************************");
    but nothing (didnt enter the init method);;
    pls How can i do this?
    Edited by: ermanbas on Jun 13, 2009 9:16 PM
    Edited by: ermanbas on Jun 13, 2009 9:17 PM

    That's why it sucks to be tied up to an ide feature. Do not extend your beans from a phaselistener. You need sth like;
    http://cagataycivici.wordpress.com/2006/06/06/managed_beans_aware_of_the/
    Edited by: CagatayCivici on Jun 16, 2009 4:06 PM

  • Call doGet in the Init of a servlet?

    Hello
    Please could you show through the code. I think there is something wrong with the init. If I run the servlet, it don't show a thing. It only displays: Site can't not be shown.
    The doGet and also the dopost is not executed. Must I call in the doPost in the init(). And when yes how?
    Thanks a lot!
    Sandra Frei
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Properties;
    public class update42 extends HttpServlet {
         Connection con = null;
         public void init() {//throws ServletException {
              String url = "jdbc:DBF:/sys:copal/copal_data/data/gesch/data/stamm";      
              try {
                   //Register the JDBC driver
                   Class.forName("zyh.sql.dbf.DBFDriver");//.newInstance();
                   con = DriverManager.getConnection(url, "fre","sandy66");                    
              catch( Exception e ) {
                   e.printStackTrace();
              }//end catch
         }//end init()
         public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              out.print("in do get");
              //connecting to the Database
              Statement stmt = null;
              ResultSet rs = null;
              PreparedStatement ps = null;
                   try
                   stmt = con.createStatement();
                   catch (SQLException e) {e.getNextException();}                              
                   // displaying records
                   try
                   rs = stmt.executeQuery("SELECT Random, Nsa, Bzng, Bzn2, Tart, Meeh, Fstat, Nzn FROM part");
                   catch (SQLException e) {e.getNextException();}                              
                   try
                   while(rs.next()) {
                        out.print("<form action=\"");
                        out.print( req.getRequestURI() );
                        out.print("\" method=\"post\">");
                        out.print("<input type=\"text\""); //hidden
                        out.print(" name=\"Random\" size=\"15\" value=\"");//without 15
                        out.print( rs.getObject(1).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Nsa\" size=\"15\" value=\"");
                        out.print( rs.getObject(2).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Bzng\" size=\"25\" value=\"");
                        out.print( rs.getObject(3).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Bzn2\" size=\"25\" value=\"");
                        out.print( rs.getObject(4).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Tart\" size=\"6\" value=\"");
                        out.print( rs.getObject(5).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Meeh\" size=\"6\" value=\"");
                        out.print( rs.getObject(6).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Fstat\" size=\"6\" value=\"");
                        out.print( rs.getObject(7).toString() );
                        out.print("\">");
                        out.print("<input type=\"text\"");
                        out.print(" name=\"Nzn\" size=\"15\" value=\"");
                        out.print( rs.getObject(8).toString() );
                        out.print("\">");
                        out.print(" <input type=\"submit\"");
                        out.print(" value=\" \">");
                        out.print(" Update<br>");
                        out.print("</form>");
                   catch (SQLException e) {e.getNextException();}                              
                   try
                        if(rs != null)
                             rs.close();
                        if(stmt != null)
                             stmt.close();
                   catch (SQLException e) {
                        e.printStackTrace();
         out.print("</pre></code>");
         out.print("<p\"><a href=\"");
         out.print( req.getRequestURI() );
         out.print("\">Back</a></p>");
         out.print("</body></html>");
         out.close();
         public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              out.print("<html><body>");
              out.print("<code><pre>");
              out.print("<table border=1>");
         out.print("<tr>");
              out.print("<td><font color=green>Artikelnr</font></td>");
              out.print("<td><font color=green>Bezeichnung</font></td>");
              out.print("<td><font color=green>Zusatzbezeichnung</font></td>");
              out.print("<td><font color=green>Art</font></td>");
              out.print("<td><font color=green>ME</font></td>");
              out.print("<td><font color=green>Stat</font></td>");
              out.print("<td><font color=green>Spezifikation</font></td>");
         out.print("</tr>");
              // receiving parameters
              String Bzn2 = req.getParameter("Bzn2").trim();
              String Meeh= req.getParameter("Meeh").trim();
              String Pk = req.getParameter("Random").trim();
              boolean proceed = false;
              Statement stmt = null;
              Statement stmt1 = null;
              ResultSet rs = null;
              try {
                   String sql;
              sql = "UPDATE part SET Bzn2 = " + "'" + Bzn2 + "'" + " WHERE Random LIKE " + "'" + Pk + "'";
                   stmt1 = con.createStatement();               
                   out.print(sql);
                   out.print(Bzn2 + Meeh + Pk);
                   stmt1.executeUpdate(sql);
              // displaying records
                   stmt = con.createStatement();               
                   rs = stmt.executeQuery("SELECT * FROM part");
                   while(rs.next())
                        out.print("<tr>");
                        out.print("<td>"+ rs.getObject(1).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(2).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(3).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(4).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(5).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(6).toString()+ "</td>");
                        out.print("<td>"+ rs.getObject(7).toString()+ "</td>");
                        out.print("</tr>");
                   out.print("</table>");
              catch (Exception e)     
                   out.print(e.getMessage());
                   e.printStackTrace();
                   try
                        if(rs != null)
                             rs.close();
                        if(stmt != null)
                             stmt.close();
                        if(stmt1 != null)
                             stmt1.close();
                   catch (SQLException e) {e.getNextException();}
              out.print("</pre></code>");
              out.print("<p\"><a href=\"");
              out.print( req.getRequestURI() );
              out.print("\">Back</a></p>");
              out.print("</body></html>");
              out.close();
         public void destroy() {
              try {
                   //Close the connection to the database
                   con.close();
              } catch( Exception e ) {
                   e.printStackTrace();
    }

    It won't get shown unless you make a call to the servlet from (e.g.) a web browser referencing it. And no - don't call doPost() or doGet() from the init() method. You might be lucky, and it might work, but it's inherently unsafe. Servlet engines will not normally call these methods until the servlet is properly initialised.
    And BTW, there is no guarantee that init() will be called until the first call to the servlet, unless you specify load on startup to the servlet engine.
    Your best bet is simply to type the URL of your servlet into your web browser. That will call doGet(). To call doPost(), you'll have to write a little HTML page with a form with method="post" and action=the name of your servlet.
    Robin

  • Invoking servlets init method

    Let's just say I want to write a startup class that initilizes a servlet,
              (just like ServletStartup class). How would I do this without using the
              URLConnection class?
              Thanks
              

    c00ler wrote:
    Hey guys,
    Studying JDBC & Java by O'Reilly. Old book, very old. You'd be better off with the Sun JDBC tutorial. Google for it.
    init() method is not really explained in the book and i'm kind of stuck. As far as i understand it's used to initialise servlet before its execution right? O'Reilly uses it to connect to the database (i'm find with connection part), problem is i don't understand why i can't connect through proccessRequest() method and I can't actually find the init() method within servlet...unless of course i write my own one. There is code offered by O'Reilly:
    Terrible form. More evidence of just how out of date this book is. No one would write a servlet to do this now.
    Book was published quite a few years ago...is there different implementation to this?
    Also for some reason Class.forName().newInstance() throws unidentified error if i use SQLException (even though java.sql.* is there), but works fine with Exception...any ideas???Not unidentified if you look at the javadocs for Class - it throws ClassNotFoundException, among others.
    You don't have to call newInstance() - Class.forName() is sufficient for registering the driver class.
    %

  • 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

  • Backing file init method always called for proxy portlets

    Hello,
    We are currently using Weblogic Portal 10 MP1. Deployed within our Portal EAR is a local proxy portlet and attached to this proxy portlet is a backing file, which currently implements the init() and prerender() methods from the backing interface.
    When this is placed in a page that is within a desktop, the init() method is always invoked no matter which page you access within the desktop. As I understand it from the documentation, if you have "tree optimization" turned on, then the init() method will only be called when rendering the actual page the proxy portlet is in. But this doesn't seem to be the case. However, if I define a standard Java portlet within the EAR and attach a backing file, then the init() follows the rules when tree optimization is turned on or off.
    Does anyone know if this is a defect within the portal framework, or is this expected and proxy portlets do not follow this rule?
    And I guess, if it is a defect or known limitation, is there a possible workaround? I assume the simplest workaround will be to move the logic into the prerender() method.
    Regards,
    Jonathan

    Hello Jonathan,
    Tree optimization is a tricky thing- some portlets may still be initialized even when the page they are on isn't visible. The rules for which get initialized and which don't are very complicated and depend on a number of things, so it is just best to not rely on the init() method not getting called.
    By far the best option for your use-case is to have the proxy portlet listen to the "onRefresh" event, and move the logic from the backing file's init() method into an event-handling method in the backing file, then have this method called when the refresh event is received. Here's a sample portion of the .portlet file for doing this:
    <netuix:handlePortalEvent event="onRefresh" eventLabel="onRefreshEvent">
        <netuix:invokeBackingFileMethod method="handleRefreshEvent"/>
    </netuix:handlePortalEvent>The "onRefresh" event is sent to the portlet only when it is visible on the page, so it should work perfectly for your use-case.
    Kevin

  • Printing in servlet's init() method

    i am trying to print out some information in init() method, but i can not create a 'response' object of ServletResponse to print with out.prinln() method for displaying these information in browser. please help me for working it out. i have given code below.
    public void init(ServletConfig config) throws ServletException {
            //response.setContentType("text/html;charset=UTF-8");
            //PrintWriter out = res.getWriter();
            Enumeration parameters = config.getInitParameterNames();
            while(parameters.hasMoreElements()) {
                String parameter = (String)parameters.nextElement();
                System.out.println("Parameter name: " + parameter);
                System.out.println("Parameter value: " + config.getInitParameter(parameter));
        }

    You don't 'create' a response object, the container does it and passes it to your code.
    You don't service requests in the init method, it's for initialization. You only setup stuff that you want to use later there.
    And in any case, do you even see 'response' declared anywhere?
    Move your code to a doGet() or doPost() method.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Why RichCommandButton doesn't invoke the actionListener method?

    I have a dynamically drop down list, it is refreshed when user changes something on the UI.
    And I add a “RichCommandButton” button and set its ActionListener is a method in the backend bean (for example, #{ctrlBean.onClick} ), the bean’s scope is Request.
    In the backend bean method, I want to do the commit.
    DCBindingContainer bindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    oracle.binding.OperationBinding operationBinding =
    bindings.getOperationBinding("Commit");
    operationBinding.execute();
    When I click the button on UI, the UI refreshes once and the dynamical entity type dropdown list becomes empty and the debugger doesn’t come into the breakpoint in the method.
    Can anybody explain the process when clicking the button?
    I don't know why the UI refreshes, but don't invoke my method.
    Thanks

    K. Konuri
    An Applet must implement at least one
    of the following methods: init, start, or paint. Unlike Java applications, applets do not need to implement a
    main method
    The init() method, which works much like a constructor, handles whatever
    initialization your applet requires. The browser or applet viewer automatically
    calls it to perform applet initialization each time the applet is loaded.
    Deepak

  • Monitoring progress of init() method in servlet

    the init() method of my servlet is extremely long; it will probably take several minutes to load. For this reason, I want to have my servlet print its progress periodically. Unfortunately, when initializing a servlet, Tomcat does not allow the System.out.println() method to do anything.
    Is there a way to tell tomcat to print something to the screen while it is initializing the servlets?

    You can write jamon monitors after each event that occurs in the init method. Then if you go to the jamonadmin page you can see the progress. You will find many other uses for jamon too. One thng that it does real well is to allow you to look at what is currently executing in your web application via the jamonadmin page.
    It is easy to use. Really just 2 methods: start and stop. see below. You should be able to get it working in minutes.
    jamon is an open source project. Also if you use the servlet filter it will keep stats such as hits, and time stats (avg, total, min, max) and more.
    import com.jamonapi.*;
    // i'm not sure of the actual signature name, but this should give you the point.
    public void init() {
    Monitor mon=MonitorFactory.start("executing Part1 Of Init")
    ... part 1...
    mon.stop();
    Monitor mon=MonitorFactory.start("executing Part2 Of Init")
    ... part 2...
    mon.stop();To get jamon go to www.jamonapi.com. There is also a live program that lets you see the JAMonAdmin.jsp page in action.
    steve - http://www.jamonapi.com

  • Calling init() method from "session scope" backing beans (AbstractPageBean)

    hi,
    i prepared a jsp/jsf page named DBmanage, its backing bean's scope is set to "session"
    the page contains - among other components - one radiobuttongroup, the buttons of which i would like to rename at the first time when the user visits the page... (default names are "item 1", "item 2", "item 3")
    i thought that the overridden init() method does the work for me with this simple code:
    import com.sun.webui.jsf.model.Option
    @override
    init() {
    rbg_default_options.setOption( new Option[]{new Option("it1", "RB1"), new Option("it2", "RB2")}
    so, let see how this code works when DBmanage backing bean's scope is "request"
    great! i see a radiobuttongroup with two buttons, named RB1 and RB2
    ok, now i change the scope to "session"
    sh&#@t!!! now i'm gazing at a page with buttons named "item 1", "item 2", "item 3"
    let's place a breakpoint inside the init() method and DEBUG... and my init() code has not run(??), how can this happen? init() method is valid only for request beans?
    pls! could anyone help me?
    ps.: i work with netbeans6.0 & glassfish
    thanks
    Gabor

    it's ok. i found out why it wasn't working.
    my scope was set to "session", but had to be "request" so that i could use the params syntax.
    thanks anyway.

  • Init() method is executing twice

    Hi,
    I have a servlet & implemented the init() method. But, the init() method is executing twice.
    Also, the destroy() method is executing twice.
    Any input guys.
    Thanks

    JAXMServlet most certainly IS an HttpServlet - the javadocs that I see say it extends HttpServlet. It won't be very useful in a SOAP implementation if it's not.
    I thought the SingleThreadModel interface. Why? I thought that was a bad practice that was discouraged. What writable data members does this "test" servlet have that require such careful treatment? If your servlet implements doGet and doPost methods, with only local variables, it'll be thread-safe enough.
    I follow the Sun Java coding standards, even for dash-off classes. "test" should be capitalized. Is there no more descriptive name you can think of?
    I'm not aware of a problem with Tomcat, and I haven't checked the bug list. But I'd put my money on your code being the problem here. Do you call super.init() in your servlet's init() method? Maybe you're seeing the superclass init() being called?
    %

  • When the init mehtod is called

    When the init mehtod is called?
    while running the server or by running the servlet program.
    When u create a enterprice project in WSAD you will have JavaResource and Web Content in your project.
    Say i have 10 servlet program in my JavaResource.
    When running the JavaResource by right cliking and run on this server which servlet will run first and when will the init method is called.
    ** (I am using Websphere)**_

    If you have gone thorugh the servlet life cycle methods, you could have come to know when init method is called.
    Servlet�s life cycle is controlled by the container in which the servlet has been deployed. When a request is mapped to a servlet, the container performs the following steps. If an instance of the servlet does not exist, the Web container
    a.     Loads the servlet class.
    b.     Creates an instance of the servlet class.
    c.     Initializes the servlet instance by calling the init method. Initialization is covered in Initializing a Servlet. 2.     Invokes the service method, passing a request and response object.
    If the container needs to remove the servlet, it finalizes the servlet by calling the servlet's destroy method.
    I think now you can understand when init method is called.

Maybe you are looking for

  • Report Open balance for Customers back in time

    Dear All, I would like to have a question: How can I report Highest Balances for Customers back in time? So I have to list Date and Amount, in the last one year, when Customers had their Highest Balances (highest outstanding amount). I have a transac

  • Many Crashes and Other Problems

    Hello, I have been experiencing many problems with Mozilla Firefox, before and after the 4.0 upgrade. There are frequent crashes. see below... Submitted Crash Reports bp-4cffa69c-7490-44b8-b4d6-558c521103313/31/20119:11 AMbp-19f8275f-773a-402c-a8c1-7

  • Returning a serializable object from a java stored procedure

    [Server : Oracle 8.1.6 on WinNT4 server. Client : java 1.2.2 on WinNT4 workstation.] I am attempting to use a java stored procedure to build a complex serializable java object on the database (to minimise number of requests/queries on the network) an

  • Portege Z10T has 'lost' 4g hardware since Win 8.1 update

    Since I updated last night to Win8.1, my Portege Z10t 4G i5 model no longer has an aircard/4G anymore. I've tried re-installing original drivers/software and the updated software, to no avail. Numerous restarts and checking for updates too. Help plea

  • How to convert more than 1 Iphone to Icloud

    I hae 3 iphones and want to connect all 3 to icloud.  It did make the icloud icon appear on the other 2 iphones after converting my MacBook Pro to ICloud.