Results 1 to 5 of 5
  1. #1
    Minu is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default question on servlets

    which two prevent a servlet from handling requests?
    A. the servlet's init method returns a non-zero status.
    B. the servlet's init method throws a ServletException.
    C. the servlet's init method does NOT return within a time period defined by the servlet Container.

    the correct options are B and C.

    Could somebody explain me as to what exactly happens in case of option C?

  2. #2
    peppem is offline Member
    Join Date
    Jan 2009
    Location
    italy
    Posts
    16
    Rep Power
    0

    Default

    the init Servlet method returns void type so it can't returns any non-zero status
    Article and examples about Java EE world
    http://programmaremobile.blogspot.com

  3. #3
    neilcoffey is offline Senior Member
    Join Date
    Nov 2008
    Posts
    286
    Rep Power
    10

    Default

    I'm not sure that there's one specific, exact behaviour that containers must follow. It it really matters to you, I would test it with the specific version of the specific Servlet runner that you're using.

    That said, I would expect reasonably behaviour be for the Servlet runer to send some appropriate HTTP status code such as 504 ("Gateway Timeout") back to the client.

  4. #4
    peppem is offline Member
    Join Date
    Jan 2009
    Location
    italy
    Posts
    16
    Rep Power
    0

    Default

    Sorry but I the first my reply I hadn't understand correctly the question!:p

    Perhaps It is possible that the servlet container doesn't response to client so client go in timeout.

    I'm curious, tomorrow I try this behaviour with glassfish application server.
    Article and examples about Java EE world
    http://programmaremobile.blogspot.com

  5. #5
    peppem is offline Member
    Join Date
    Jan 2009
    Location
    italy
    Posts
    16
    Rep Power
    0

    Default

    PHP Code:
     @Override
        public void init()
        {
        while(true)
        {
                try
                {
                    Thread.sleep(5000);
                } catch (InterruptedException ex)
                {
                    Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);
                }
        }
        }
    this code on glassfish server never returns(I wait it for 10 minutes).
    I think that the servlet container wait for init() method completions
    Article and examples about Java EE world
    http://programmaremobile.blogspot.com

Similar Threads

  1. JTextPane with servlets
    By kinabaloo in forum Advanced Java
    Replies: 2
    Last Post: 07-11-2008, 06:32 AM
  2. Deploying Servlets
    By gapper in forum New To Java
    Replies: 2
    Last Post: 01-17-2008, 12:43 PM
  3. servlets or jsp
    By krishnapal in forum Advanced Java
    Replies: 1
    Last Post: 12-13-2007, 02:31 PM
  4. Servlets
    By nagaroopanandha in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 02:09 PM
  5. working with servlets
    By Freddie in forum Java Servlet
    Replies: 2
    Last Post: 05-15-2007, 05:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •