aspose file tools*
The moose likes Servlets and the fly likes why driver and url passed as context params Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "why driver and url passed as context params" Watch "why driver and url passed as context params" New topic
Author

why driver and url passed as context params

abhishek_saxena
Greenhorn

Joined: Oct 31, 2008
Posts: 1
i wanna know why driver name and url passed as context params in a generic Servlet why not init params and can we write the business logic statements in INIT Method rather than service do we get the same output
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
The servletContext contains data common to all your servlet application.
Typically an application will use one database and thus the settings to access it are the same for the servlets.

On the contrary the init parameters are specific to one servlet.
You will find data specific to the use case served by the servlet.

hope it will help


SCJP 5 , SCWCD 5, SCEA 5
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Originally posted by abs saxena:
i wanna know why driver name and url passed as context params in a generic Servlet why not init params and can we write the business logic statements in INIT Method rather than service do we get the same output


Hi "abs saxena",

Welcome to JavaRanch . The context param is for the entire web applciation and init param is for individual servlets.

As ntumba lobo mentioned, we do maintain ONE database/datasource for an application in general. That's the reason they are mentioned in the generic Context Param. Moreover, if at all you have to change the parameters, you can easily change it at one place.

Hope this helps!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

Hi "abs saxena",

Not very sure your first name "abs" has some REAL meaning. If not I would suggest you to kindly look at the Naming Policy of JavaRanch and you can easily convert/change your name by editing your profile
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why driver and url passed as context params