Howdy,

>Oops, you're right that line would not have compiled...I meant I use
this:
>
>DataSource ds = (DataSource) new
>InitialContext().lookup(application.getInitParameter("db.jndi.dsn"));

What is the type of the application object?

>
>...to get a datasource values and assumed the similar line would work
for
>retrieving a String:
>
>String str  = (String) new
>InitialContext().lookup(application.getInitParameter("myString"));

It will, if you setup your JNDI resources correctly.

>God, why does it have to be so difficult to do something so simple.  I
love

It's only difficult when you try code out of the sky without learning
about it first ;)

>times.  Ok, so you're saying go and read JNDI documentation and
hopefully
>once I understand JNDI inside and out I can finally set a freaking
>application constant paramter?

I'm saying that's one thing you can do.  You can use context-param in
web.xml instead.  That's an easier and more direct option.  JNDI is
overkill for simple strings usually.

Yoav Shapira

>
>
>
>
>
>"Shapira, Yoav" <[EMAIL PROTECTED]> wrote:
>
>Howdy,
>
>>I'm trying to do something as simple as define global constants for my
>JSP
>>application. In ASP there is a Global.asa file and the closest thing
in
>JSP
>>is of course the web.xml file. I defined a value in my web.xml file
>and
>>assumed I could retrieve it using the following line:
>>
>>String test = (String) new
>InitialContext().getAttribute("html.basepath");
>>
>>I've done something similar for Datasources that works just fine but
>for
>>some reason tyring to retrieve a basic String in a similar manner
>doesn't
>>work.
>>
>>Can someone please tell me what I am missing?
>
>You're missing a lot. You should read the Servlet Specification,
>specially the section on context parameters (context-param elements in
>web.xml), which is what you will probably use for simple strings.
>
>You should read the JNDI documentation for what a context (including
>InitialContext) is. It doesn't have a getAttribute method, so I
>seriously doubt this line of code even compiles, much less works for
>datasources or any other type of JNDI resource. You could use a JNDI
>context for simple strings, but that's usually overkill.
>
>Yoav Shapira
>
>
>
>This e-mail, including any attachments, is a confidential business
>communication, and may contain information that is confidential,
>proprietary and/or privileged. This e-mail is intended only for the
>individual(s) to whom it is addressed, and may not be saved, copied,
>printed, disclosed or used by anyone else. If you are not the(an)
intended
>recipient, please immediately delete this e-mail from your computer
system
>and notify the sender. Thank you.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------
>Do you Yahoo!?
>New Yahoo! Photos - easier uploading and sharing



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to