• 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:

Some questions....concepts...Plz answer!

 
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guyz,
I have some questions/concepts in mind and want to share with U.So plz. answer and confirm my concepts too!.
Here it starts....
Q1:If the attributes of session are not serialized, then session can be migrated on one machine to another machine?.
**************************************************
Q2: Provided non distributable enviroment, is there one ServletContext for each webapp.Means if there are 3 webapp in a single web server then there will be 3 ServletContext objects are associated with each web appl.?
**************************************************
Q3: My question is on calling getInitParameter() by My Servlet class instance in init() method.I wnat to know how getInitParameter() is available to My Servlet instance.My logic for this reason......
init() is called by our Servlet class instance(which is either extending GenericServlet or HttpServlet).Therefore if we call this.getInitParameter("name") in init() it will be OK!.B/C getInitParameter() is defined in ServletContext which is assinged in ServletConfig(during initialization) and ServletConfig is implemented by GenericServlet & therefore HttpServlet & hence Our Servlet class and thus available to My Servlet class instance.
Is this correct?
*************************************************
Q4:Why doXXX() methods are declared protected?
*************************************************
Q5:Why HttpServlet is declared abstract even there is no abstract method in this class.
*************************************************
Q6:HttpServlet has two overloaded versions of service()
public void service(ServletRequest req, ServletResponse res)
protected void service(ServletRequest req, ServletResponse res).
My question is that does public service method calls protected service method when recieves any Http request?.
*************************************************
Q7:If we pass diff. Request/Response objects to include() instead of passing the Original Request/Response objecst which we recieve in our servlet then what will happen?...Any Error or Exception?
*************************************************
Q8:What is emant by Fully Qualified Name of class?.For e.g String class if written as fully qualified name then it will be like this....java.lang.String Means along with full package name.?
*************************************************
Q9:What happen if we arite just name of class in <servlet-class>XYZ </servlet-class> instead of writing Fully Qualified Name, what will happen?.
*************************************************
Q10:If servlet does not generate or fails in generating error page after calling setStatus(int statusCode) then what will happen?(Remember its responsibility of Servlet to generate error page after calling Fully Qualified Name ).
*************************************************
Q11:What is root-cause exception.
Bye & LOT of thanx in advance
Viki.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alot of these questions could be answered if you just tried it on your own...
Q1. If your referring to a system that has two tomcat containers running (load-balancing) then, NO, a session is only created on one tomcat instance and is not available to the other tomcat instance.
Q2. Yes, one ServletContext per web application.
Q3. getInitParameters() // will get servlet init variables
getServletContext().getInitParameter() // will get ServletContext init variables
Q4. By making the doXXX() methods protected, they can be overridden by subclasses and invoked by subclasses.
Q5. This is kinda tricky. It's abstract so when extending it with a non-abstract class, you must implement a method, usually an abstract method. Even though there are no abstact methods in HttpServlet, you must implement (override) one, usually a doXXX() method.
Q6. Probably, but not sure. Check the servlet specifications.
Q7. If you generate a valid Request/Response object then I'd imagine it would work. Try it.
Q8. Yes
Q9. It won't find the servlet. Try it.
Q10. Not sure, but easy to try yourself.
Q11. Don't know.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,
Yes u r correct that i can answer lot of questions my self.But i have not instructor except Java Server Programming by Wrox,Serv.spec2.3,JSP Spec.1.2,Serv API and one and only instructor of all times www.javaranch.com.I have much confidence on Ranchers.
Anyway....
My question to given answers by u are accordingly..
Q3: Read my question again.
Q4: This can be achieve by declaring public
Q5: I think: it is declare abstract coz. if we will not implement any of doXXX() method then it will be totally consider non-sense with extending HttpServlet.
Bye.
Viki.
[ February 27, 2002: Message edited by: Vikrama Sanjeeva ]
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are my answers..
3. Yes your understanding is right.
4. doXXX() methods are declared protected so that only child/same objects can call those methods. It makes sure that only servlet object calls the doXXX()
5.HttpServlet is made abstract to makesure that no one creates an instance of HTTPServlet object directly without creating its child classes.
6.YES when HttpServlet receives a HTTP request it calls Service(HttpReq,HttpRes). It also contains the service(ServletRequest,ServletResponse) to provide functionality for service method of GenericSErvlet method.
7. The servlet in include will use the passed req/response pair for its processing and will not generate any error/exception unless for other reasons.
10.Will display exception on browser.
11. Root-cause exception is the exception at the base of exception trace. ususally thrown by user coded methods.
any corrections need to be made ???
Vamsi
 
Vikrama Sanjeeva
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Noops.... May be any other rancher
Bye & Thanks A LOT
Viki.
 
You've gotta fight it! Don't give in! Read this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic