• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Couple of doubts

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a couple of doubts related to servlets/JSPs:

1. What is the exact sequence in which various web-app components are loaded (i.e. filters, listeners, context, servlets, etc...).

2. How are HTTP methods resolved for direct client calls to JSPs? For instance, if I do POST from a page to a JSP, how does the container know that it is to use doPost when none is explicitly implemented?

3. Can someone post the grammar / Regular Expression rules (if either exists) used for matching the input URL to servlet mappings?

Thanks and Regards,
Prasad
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi prasad,

What is the exact sequence in which various web-app components are loaded (i.e. filters, listeners, context, servlets, etc...).



Context, filters, listeners and servlets



How are HTTP methods resolved for direct client calls to JSPs? For instance, if I do POST from a page to a JSP, how does the container know that it is to use doPost when none is explicitly implemented?



Jsp is nothing but servlet. HttpServlet class provides the empty implementation for each of the doXXX() . First the container will call the service(ServletRequest req, ServletResponse res) of the HttpServlet.Second, this service method calls the service(HttpServletRequest req, HttpServletResponse res) of the same class. Third This method analyse the request and finds out which method is being used.Depending on the HTTP method, it calls the appropriate doxxx().

I hope, this will help you

I dont know the answer for your 3rd question


bye for now
sat
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Some confusion.

The inilialization order is context,filters, listeresr, servlets

When the context is initialized, the contextInitialized method of ContextListener is invoked, so I think atleast ContexListerers are initialized immediately after context initialization. I think it is not necessary to initialized filters and servlet at the start of application ( For servlet, unless the <load-on-startup> is mentioned in DD.


In case of generated Servlet there is no doXXX() methods. There is only on all in one _jspService method which process all types of requests and directly called by Servlet service() method.

The servlet mapping rules ( These are not regular expressions ) can be found in servlet specs. There is serpeate chapter on it SVR.11 Mapping Servlets to Requests.

Please confirm if any diversions.

Thanks
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet container performs following things in order before service method servlet gets called.
1. initialize listners.
2. context initialize method gets called.
3. create filters
4. create servlets.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rizwan:
Servlet container performs following things in order before service method servlet gets called.
1. initialize listners.
2. context initialize method gets called.
3. create filters
4. create servlets.



hi
there is some confusion between 1 and 2 option,
there is one listener(http session binding listener)
that we dont declare in dd.
so how it can be initialized before context
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If the context is initialized after listeners, how the context listeners get reference to the ServletContext.

Thanks
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
This is the order i found in Spec.

� Instantiate an instance of each event listener identified by a <listener> element in the deployment descriptor.
� For instantiated listener instances that implement ServletContextListener,
call the contextInitialized() method.
� Instantiate an instance of each filter identified by a <filter> element in the deployment descriptor and call each filter instance�s init() method.
� Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-on startup element values, and call each servlet instance�s init() method.


Reg
Vasanth
 
The moustache of a titan! The ad of a flea:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic