How might I read docBase into my application
Can anyone tell me how I can obtain the value of docBase from my application's (JSP) context? I would like to use it to help me form hrefs for my pages -- I would just use relative pathing except I am trying to manage which pages use HTTPS and which use HTTP and I would rather not hard-code them. It seems not to be in the application attributes or InitParameters. Also not in the pageContext attributes nor the config InitParams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How might I read docBase into my application
Hi, Can anyone tell me how I can obtain the value of docBase from my application's (JSP) context? I would like to use it to help me form hrefs for my pages -- I would just use relative pathing except I am trying to manage which pages use HTTPS and which use HTTP and I would rather not hard-code them. It seems not to be in the application attributes or InitParameters. Also not in the pageContext attributes nor the config InitParams. It's not omitted by accident, you know ;) Use request.getContextPath() to get it when creating URLs. Yoav Shapira http://www.yoavshapira.com 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: How might I read docBase into my application
application.getRealPath(/) This should return the full filesystem path to the root of your current web application (e.g. context). I believe this should be the value represented by docBase in your context config. [EMAIL PROTECTED] 11/16/2004 8:35:55 AM Can anyone tell me how I can obtain the value of docBase from my application's (JSP) context? I would like to use it to help me form hrefs for my pages -- I would just use relative pathing except I am trying to manage which pages use HTTPS and which use HTTP and I would rather not hard-code them. It seems not to be in the application attributes or InitParameters. Also not in the pageContext attributes nor the config InitParams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How might I read docBase into my application
Hi, application.getRealPath(/) This should return the full filesystem path to the root of your current web application (e.g. context). I believe this should be the value represented by docBase in your context config. Please beware of using that approach: getRealPath() returns null (for any argument) when running from a packed WAR. So if you use this approach, which is not guaranteed to be portable, at least make sure your code correctly handles the null return case. Yoav 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: How might I read docBase into my application
Thank you both! I think that for my purposes -- URL formation -- request.getContextPath() will work best. -Original Message- From: David Boyer [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 16, 2004 8:39 AM To: [EMAIL PROTECTED]; Ken Sims Subject: Re: How might I read docBase into my application application.getRealPath(/) This should return the full filesystem path to the root of your current web application (e.g. context). I believe this should be the value represented by docBase in your context config. [EMAIL PROTECTED] 11/16/2004 8:35:55 AM Can anyone tell me how I can obtain the value of docBase from my application's (JSP) context? I would like to use it to help me form hrefs for my pages -- I would just use relative pathing except I am trying to manage which pages use HTTPS and which use HTTP and I would rather not hard-code them. It seems not to be in the application attributes or InitParameters. Also not in the pageContext attributes nor the config InitParams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How might I read docBase into my application
Thank you. That is very good to know. [EMAIL PROTECTED] 11/16/2004 8:47:49 AM Hi, application.getRealPath(/) This should return the full filesystem path to the root of your current web application (e.g. context). I believe this should be the value represented by docBase in your context config. Please beware of using that approach: getRealPath() returns null (for any argument) when running from a packed WAR. So if you use this approach, which is not guaranteed to be portable, at least make sure your code correctly handles the null return case. Yoav 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: How might I read docBase into my application
On Tue, Nov 16, 2004 at 08:35:55AM -0800, Ken Sims wrote: : Can anyone tell me how I can obtain the value of docBase from my : application's (JSP) context? I would like to use it to help me form : hrefs for my pages In addition to the other advice you've received, you could do this within the JSP itself using JSTL and EL. The c:url/ tag creates context-relative links: First, create a string variable with the link path: c:url value=/some/page/or/image var=link/ Then, use it in a link or image tag: A HREF=${link}link text/A -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]