Hi
As you explained I added the <env-entry-name> to the web.xml and tried to
call it in my javabean as below:
-----------------------------------------------------------
Context ctx = null;
try {
ctx = new InitialContext();
} catch (Exception e) {
System.out.println("Couldn't build an initial context : " +
e);
return;
}
String dbuser = (String)ctx.lookup("java:comp/env/dbuser");
------------------------------------------------------------------------------------
but at this point I am getting this error:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
my web.xml entry is as below:
<env-entry>
<env-entry-name>dbuser</env-entry-name>
<env-entry-value>guest</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Can you throw some light on this please?
I am using jdk1.4 and tomcat 3.3.1
Thanx in advance
Deepak
On Wednesday 26 March 2003 03:40 pm, Lakshmeenarayana G G wrote:
> In web.xml you can use
> <env-entry>
> <env-entry-name>username</env-entry-name>
> <env-entry-value>myusename</env-entry-value>
> <env-entry-type>java.lang.String</env-entry-type>
> </env-entry>
>
> and you can access this from bean like this..
>
> String username = (String)ctx.lookup("java:comp/env/username");
>
> For this you need to import javax.naming.*;
>
>
> Well why you need to edit the web.xml?? cuz usually database deails will be
> changing and you need to upadate the web.xml regularly. You cant expect the
> end user to do it. so you need to provide seperate UI for this and read
> web.xml from a XML parser ( Sun hasnt provided any methods to edit the
> web.xml programatically ) and update it as user interacts with your system
> providing the latest details of database.
> web.xml is for giving instruction related to deployment not for updating
> system properties. So I feel its better to keep these details in a
> different file and use them.
>
> Cheers.
> Lakshmeenarayana G G
> ArisGlobal India Development Center,
> SysArris Software Pvt. Ltd.,
> Bangalore, India
>
>
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED] Behalf Of Deepak
> Sent: Wednesday, March 26, 2003 11:53 AM
> To: [EMAIL PROTECTED]
> Subject: DB Connection in web.xml
>
>
> Hi
>
> Can anyone tell me how to set up a db connection in the web.xml?
>
> I mean how to set the driver, url, user and pwd as parameters and how to
> call
> them in the jsp page or servlet.
>
> Is it possible to call the same from a javabean?
>
> Thanks
> Deepak
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com