Hey!

See comments below.

Sans adieu,
Danny Rubis

Robert wrote:

> Hello,
>
> That sounds like a nice solution.
> Could you pleace inform me why it is not such
> a good idea to put the db-connection in the
> init() method. I though it was better to do so
> since then the servlet only connects once to
> the db during its lifetime. And hence you gain
> some speed performance. Or have I got it all
> wrong?

See the archives
http://archives.java.sun.com/archives/servlet-interest.html

>
> The reason why I don't want to hardcode the
> db-url is 'cause the db wont lie in the same
> place now when I'm developing as it will later
> when it's done. So instead of changing loads
> of servlets I'll only have to change it on one
> place.
>

That's what I thought.  See my answer.

> cheers,
> Robert Karlsson
>
> On Fri, 7 Jul 2000, Danny Rubis wrote:
>
> > Hey!
> >
> > Yes, your correct.  One doesn't want to hard code the DB URL
> > in the servlet, or for that matter in any major software that accesses a
> > DB.
> >
> > The most important reason that I have encountered is what if
> > the DB moves.  I guess, if you only write one or two classes for
> > the application, it doesn't matter.  But what if you have 300 references
> > to the DB URL.  Not a good software maintenance situation.
> >
> > The way I solved this problem was I required everyone to use
> > a DB configuration object.  I required all applications do something
> > like this.
> >
> > ConfigObject config = new ConfigObject();
> > and use getters to access the attributes of the DB.
> > In that object I put all of the important DB stuff, including
> > the DB URL.  I access it with getters.
> >
> > getURL();  // the DB URL
> > getxxx();
> > getyyy();
> >
> > Now if the DB moves, all of the 300 references
> > in 100 different applications are handled by
> > changing one line of code in one class.
> >
> > Now I will agree that this is more important in
> > a corporate intranet environment as opposed
> > to an Internet website environment.  But I think
> > it is a good policy to do this anyway.
> >
> > I hope that this helps with you question.  You
> > don't give a reason why hard coding the URL
> > is bad for your project.
> >
> > BTW, it's my opinion that it is a bad policy to get
> > a DB connection in the init() of a servlet anyway.  It's
> > okay when you are developing, but when you go
> > into production you'll rudely find out why it's bad  Also,
> > check this list's archive for more info., for we had
> > a recent discussion concerning this very issue.
> >
> > Sans adieu,
> > Danny Rubis
> >
> > Robert wrote:
> >
> > > Hello,
> > >
> > > How can I retrieve the parameters in a servlet
> > > that I send in a jsp:
> > >
> > > <jsp:forward page="someservlet">
> > >  <jsp:param name="varname" value="sumvalue">
> > > </jsp:forward>
> > >
> > > To my knowledge I'm supposed to use the request
> > > object with the getParameter("varname") or
> > > getParameters(). But I can't seem to get it
> > > working.
> > > I want to retrive the parameter in the servlets
> > > init() method.
> > >
> > > Anyone having a solution, please?
> > >
> > > /Robert Karlsson
> > >
> > > ___________________________________________________________________________
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources: http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> > ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to