• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need answer to the questions!!  RSS feed

 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
I need the answers for the following questions.
1.If a constructor is written in the servlet,which method will be called first constructor or init?
2.How many servlet instances will be present in the webserver?
3.In MVC architecture,how many controller and view instances will present?
4.How to maintain HttpSession between different application servers in the distributed enviroment?
5.When to use jsp-java bean combination and taglibs as both serve the same purpose of reusability?Any specific reason for the same?
Please help me out.
Regards,
Ravi
 
Vadiraj Deshpande
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me try some of them.

1.If a constructor is written in the servlet,which method will be called first constructor or init?

Constructor ofcourse.

2.How many servlet instances will be present in the webserver?

Totally depends on the web server implementation.

3.In MVC architecture,how many controller and view instances will present?

Ideally one controller and many view instances. But you can have many controllers as well as in the case of struts.

4.How to maintain HttpSession between different application servers in the distributed enviroment?

Not sure about this. sorry

5.When to use jsp-java bean combination and taglibs as both serve the same purpose of reusability?Any specific reason for the same?

javabeans in jsp serve different purpose than custom tags although in some cases both can be used interchangeably. The custom tags mostly used in the case wheere you need to generate some output at the end of processing (Some mark up like HTML or XML). Javabeans are used in the cases where you need to have java counterpart of the HTML form. (This is the most popular use, although they can be used for some other purposes like accessing a DB). But javabeans can't generate a HTML table out of a say a resultset while a custom tag can do this easily (as it has the access to pageContext object).
HTH
-A
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi -
I'd like to know which resources and url's you have been looked at before posting this question, do you have any opinion/contradiction with any of these questions? This sounds more like homework questions to me.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The constructor must be a no arg constructor.
 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Andres Gonzalez,
Those are the questions asked to me at interview which iam not aware of it.So posted to know the answers for the same by the experienced guys present in the forum.4th question is not answered yet.Please help me out.
Regards,
Ravi
 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Allan Deshpande,
Can u please elaborate the 5th quesion?Iam unable to catch your point.
Regards,
Ravi
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to maintain HttpSession between different application servers in the distributed enviroment?
Ravi-
I highly recommend you SCWCD study kit, by Hanumant Deshmukh and Jignesh Malavia. It's not only for certification purposes, it's a very good book.

The specification mandates that requests belonging to a session must be serviced by only one JVM at a time. However, the container may migrate the session to another JVM for load balancing or fail-over.
  • A servlet container is not required to propagate HttpSessionEvents to different JVMs
  • An HttpSession can reside on only one JVM at a time.
  • a container may throw an IllegalArgumentException in the setAttribute() method of HttpSession if the attribute is not serializable. So, attributes of a session that implement the serializable interface are migrated appropriately when the session migrates.


  • hope this helps.
    [ August 22, 2003: Message edited by: Andres Gonzalez ]
     
    Andres Gonzalez
    Ranch Hand
    Posts: 1561
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Ravi Kumar R.S:
    Hello Allan Deshpande,
    Can u please elaborate the 5th quesion?Iam unable to catch your point.
    Regards,
    Ravi

    Again, SCWCD study kit has the answers for you
    - Tags are thread safe; beans are not. Beans,like other separate utility classes, have to be made thread safe by developers
    -Tags only have scope page. Beans can have different scopes. I think this one is very important.
    - javabeans are data handlers of JSP pages. Tags aid computational logic related to a particular request.
    so on...
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!