RE: global.asa -> Web.xml
Hi Ben, I'm really new to Tomcat/Jsp. Would you be able to send me a sample web.xml as what should I include if i want to use it from my Jsp. That would be a great help.. Thanks in advance, Regards, Divya -Original Message- From: Ben Souther [mailto:[EMAIL PROTECTED] Sent: 15 December 2003 23:31 To: Tomcat Users List Subject: Re: global.asa -> Web.xml In your web.xml file: city_name NY In your JSP City: <%= application.getInitParameter("session-expired-page")%> On Monday 15 December 2003 02:40 pm, you wrote: > 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? > > Thanks. > > > > > - > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: global.asa -> Web.xml
hi why do not u try this statment inyour jsp? getServletContext().getInitParameter(""); this statement will just retrieve the value of the parameter name u set in the web.xml. good luck sat - Original Message - From: "neal cabage" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Tuesday, December 16, 2003 4:40 AM Subject: global.asa -> Web.xml > > 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? > > Thanks. > > > > > - > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: global.asa -> Web.xml
No problem. BTW: If you're not using an IDE for development, you might want to bookmark the j2ee API Docs. http://java.sun.com/j2ee/1.4/docs/api/ On Monday 15 December 2003 07:39 pm, you wrote: > Ah, thanks Ben. Yes, I tried what I wrote prior and also tried > application.getAttribute ... but didn't realize there was a > getInitParameter() method. That did the trick. > > Thanks. > N > > > Ben Souther <[EMAIL PROTECTED]> wrote: > In your web.xml file: > > > > city_name > > > NY > > > > > > In your JSP > > City: > > On Monday 15 December 2003 02:40 pm, you wrote: > > 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? > > > > Thanks. > > > > > > > > > > - > > Do you Yahoo!? > > New Yahoo! Photos - easier uploading and sharing > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: global.asa -> Web.xml
Ah, thanks Ben. Yes, I tried what I wrote prior and also tried application.getAttribute ... but didn't realize there was a getInitParameter() method. That did the trick. Thanks. N Ben Souther <[EMAIL PROTECTED]> wrote: In your web.xml file: city_name NY In your JSP City: On Monday 15 December 2003 02:40 pm, you wrote: > 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? > > Thanks. > > > > > - > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing
Re: global.asa -> Web.xml
In your web.xml file: city_name NY In your JSP City: <%= application.getInitParameter("session-expired-page")%> On Monday 15 December 2003 02:40 pm, you wrote: > 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? > > Thanks. > > > > > - > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: global.asa -> Web.xml
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]
RE: global.asa -> Web.xml
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")); ...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")); ...but no dice. God, why does it have to be so difficult to do something so simple. I love Java for a lot of reasons, but this kinda stuff makes me really curse it at 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? "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
RE: global.asa -> Web.xml
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]