wood burning stoves 2.0*
The moose likes Servlets and the fly likes Constructor,init() in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Constructor,init() in a servlet" Watch "Constructor,init() in a servlet" New topic
Author

Constructor,init() in a servlet

Durga Krishna
Greenhorn

Joined: Jul 10, 2006
Posts: 11
Hi friends,
I am new to the development.Any one of you please clear my doubts..

1)What will happen if i create a contrutor to my servlet?
2) can i creata thread in service method and can i use it ?
3) How to call a user difined method in one servlet from another servelt?
4)init() method is called only once,but there r two overloaded init methods,which one will be called when servlet is loaded?
5)why should i go to EJB if i can write my business logic using servlets itself?
6) how to use the filter when server is sending response to the clinet?

ThankYou.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

DurgaKrishna,
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here

Also:
n an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular, please see CarefullyChooseOneForum.

This forum is dedicated to JSP issues.
I'll move your thread to the Servlets forum for you.

Again, welcome to JavaRanch and good luck with your question.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
1)What will happen if i create a contrutor to my servlet?
** the servlet container will always call a no-args constructor, there is no good reason to do this - instead, follow the servlet API and use init

2) can i creata thread in service method and can i use it ?
** sure, just be careful - there have been many discussions of when this might be desirable, (not very often) do a search in this forum.

3) How to call a user difined method in one servlet from another servelt?
** This would be a bad design, keep your servlet code simple and put useful methods in helper classes.

4)init() method is called only once,but there r two overloaded init methods,which one will be called when servlet is loaded?
** use one or the other, not both in your servlet code

5)why should i go to EJB if i can write my business logic using servlets itself?
** no good reason to use EJB if you dont have to.

6) how to use the filter when server is sending response to the clinet?
** read the JavaDocs for filters

Bill
Durga Krishna
Greenhorn

Joined: Jul 10, 2006
Posts: 11
ThankYou bill..
I got very perfect answers from you i think.Thankyou very much
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

"DurgaKrishna", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Consider Paul's rocket mass heater.
 
subject: Constructor,init() in a servlet
 
Similar Threads
HFSJ 2nd edition question 43 answer seems ambiguous
init() and http related questions
init() and init(conf)
some basic questions
init() method?