How to get web app root?

IF im in a servlet/jsp how do I get the web app root? for example, if my web app's url in the browser is http://www.server.com/webapp/Servlet
then "webapp" is the root... how do I get that in code? I don't want request URI or anything like that... just simply the web app root without anything else. Thanks

have u tried this
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getContextPath()
= request.getContextPath();
or one of the other similar methods in httprequest. one them does the trick

Similar Messages

  • How to get the physical path of my web app root context ?

    Hi,
    I used this code to initialize my LOG4J logger.
            System.out.println(Version + "Servlet context path : " + sctx .getContextPath());
            String path = sctx .getRealPath("/");
            fullyqualifiedlog4jpath = path + "log4j.xml";
            File locallogxml = new File(fullyqualifiedlog4jpath);
            if (locallogxml.exists()) {
                initialized = true;
                DOMConfigurator.configure(fullyqualifiedlog4jpath);
                log = Logger.getLogger(Log4j.class.getName());
                log.info(Version + "Logger initialized");
            else {
                System.out.println(Version + "Unable to locate the log4j.xml file");
            }It works perfectly when running the application with the embedded Jdev11 WLS.
    When deploying the application on a standalone WLS server the path is not returned ;-( I get a null value.
    Does someone has three lines of code which get the physical path of my web app root context?
    Yves

    Changed the methiod used to access log4j.xml.
            FacesContext ctx = FacesContext.getCurrentInstance();
            ServletContext sctx = (ServletContext) ctx.getExternalContext().getContext();
            String contextPath = sctx.getContextPath();
            HttpServletRequest  hsr = (HttpServletRequest)ctx.getExternalContext().getRequest();
            String host = hsr.getServerName();
            int port = hsr.getServerPort();
            try
              String urlstring = "http://" + host + ":" + port + contextPath + "/faces/log4j.xml";
              DOMConfigurator.configure(new URL(urlstring));
              log = Logger.getLogger(Log4j.class.getName());
    .....using the URL s OK.

  • How do I change the Web App Root

    During installation I made a mistake of choosing the compiled output directory as the Wen App Root, whereas it seems that it actually wanted the source directory. Consequently whenever I try to open a source jsp file I get
    Unable to create this part due to an internal error. Reason for the failure:
    The NitroX editor can only be used with the pages located in the Web Application Root directory.
    The Web Application Root directory is the directory containing the WEB-INF folder.
    The text editor is being used instead.
    How do I change the Web App Root directory, I can't find a menu or preference that shows the current value or an ability to establish a new location.

    Does this mean then that you are forced to have a WEB-INF folder sitting beside JSPs you want to edit with NitroX?
    e.g. If my project directory structure looks like this:
    project-root
    |-- dist
    |      |- WEB-INF
    |      |- a.jsp
    |      |- b.jsp
    |-- web
            |- a.jsp
            |- b.jsp[/code:1:daa10af002]
    i.e. I keep my JSP source code in /web but when I run my Ant build the JSPs are copied to the dist directory.
    If I try to edit the files in /web using NitroX I get the error mentioned above. Does this mean I have to make /web the Web App Root directory and thus have to have a WEB-INF folder inside it?
    Cheers,
    mEEch                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to exclude Web App from search results

    Hi
    Search results link to a unstyled Web App instead to the actual page it resides in.
    Please do this:
    1. go to: http://kinship.businesscatalyst.com/
    2. search for "Michael" on the top global search
    3. on the search results page click on the name (link).
    4. you will see Michael's web app item not the actuall page it resides in (http://kinship.businesscatalyst.com/About/the-team)
    How to avoid getting web app results in search?
    Thanks
    Micha

    Hi Micha
    Just add “&OT=35 “ at the end of the action in your search form:
    Ex:
    <form name=”xxxx” method=”post” action=”/Default.aspx?SiteSearchID=3566&amp;ID=/results&OT=35”>
    <div class=”search-box”><input type=”text” class= ............../>
    <input type=”submit” class=”cat_button” value=”search” />
    </div>
    </form>
    Here are the rest of the content types IDs, should you come across similar situations in the future:
    Web Pages = 1
    Literature = 6
    Announcements = 7
    FAQs = 9
    Forums = 43
    Blogs = 55
    Web Apps = 35
    Catalogs = 26
    Bookings = 48
    You can exclude multiple areas from a search, simply list them with commas: &OT=35,1,6

  • How to debug web app with weblogic?

    I wrote a web app that includes jsp files and some javabeans, then I put the jsp files to directory
    mydomain\applications\DefaultWebApp
    then I complied javabeans and put those classes to
    mydomain\applications\DefaultWebApp\WEB-INF\classes
    Then I start the weblogic,it runs very well.
    I modified some javabean, complie them and put classes override the old classes,
    but the web app can not find the new classes.
    Any one know How to debug web app(with javabeans) in weblogic?
    thanks!

    how to config the hot deploy?
    thxSorry, for this delay in responding. I had set notify me with email option in Watch This topic; but I never did get any email notification.
    I use wls6.1; I think the process may be very similar to this in wls8.x. In wls6.1 (sp5), this is done via the -
    Dweblogic.ProductionModeEnabled=False or
    Dweblogic.ProductionModeEnabled=True
    in the startup cmd/sh script. Out of the box, wls6.1 is set to Dweblogic.ProductionModeEnabled=False which automatically enables hot deploys.

  • How to put web app to Oracle 8i Jserver ?

    I've developed a web app with JDev3.1 , Oracle8i 8.1.6 on NTServer4.0.
    and want to put it on Oracle Jserver 8.1.6:
    The app works well within JDev3.1.
    I depolyed my Business Components project and test well.
    I would like to know how to put web app to Jserver. Is it possible?

    when you say "web app" i am assuming you mean an applet, servlet or java server page(jsp) ??
    if you mean this, then you need to move to the rdbms 8.1.7 environment for this support.
    rdbms 8.1.7 supports servlets and jsp's in two different ways :
    externally -- on the rdbms 8.1.7 platform
    they can be run in an external apache front end included with the 8.1.7 rdbms.
    internally -- inside the rdbms 8.1.7
    they can be deployed internally to 8.1.7 in the "oracle servlet engine" (ose)
    applets and html static pages still need to be deployed to a web server on the mid-tier OR the external apache front end included with the 8.1.7 rdbms to optimize performance.
    i hope this helps ...
    p.s. if i've misunderstood your question , please restate it.
    null

  • TS3991 iWork doesn't seem to recognize that I already have the pages, keynote, and numbers apps so I can't use iCloud to sync my documents.  How to get my apps recognized?

    iWork doesn't seem to recognize that I already have the pages, keynote, and numbers apps so I can't use iCloud to sync my documents.  How to get my apps recognized?

    Do you have both the OS X and iOS versions of each of them?

  • How to get web application to use Tuscany without conflicting with SAP SDO

    Hi,
    We are attempting to run a web application on SAP NetWeaver CE 7.1 SP1 which uses Tuscany SDO.  As it now stands We must use Tuscany because the web application will not run with the SAP SDO implementation provided by Netweaver. To ensure that Tuscany is loaded with priority, we have packaged the Tuscany JAR files and their dependencies as a heavy resource, as described here:
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60642a88-95fe-2b10-d387-a245d48fc257?overridelayout=true
    The final check showed that Tuscany was correctly deployed as a heavy resource and included the following JAR files:
    common-2.2.3.jar
    ecore-2.2.3.jar
    ecore-change-2.2.3.jar
    ecore-xmi-2.2.3.jar
    tuscany-sdo-impl-1.1.1.jar
    tuscany-sdo-lib-1.1.1.jar
    tuscany-sdo-tools-1.1.1.jar
    xsd-2.2.3.jar
    We also verified that the web application using Tuscany has a hard reference to the Tuscany heavy resource.
    However, when we try to run the web application, the following error is logged:  java.lang.LinkageError: Class commonj/sdo/DataGraph violates loader constraints
    The issue is definitely due to some kind of classloading conflict with the SAP SDO library, as the application runs normally when SAP SDO is manually removed from the classpath. Doing this on a production system is unfortunately not an option, though.
    So the question is: how to get web application to use Tuscany without conflicting with SAP SDO?

    I took a look at the "printerReady" example.  Looks like I may be able to use the InetPing (...) function to ping through a range of IP addresses looking for a response.
    Any ideas on how to find the MAC address associated with the IP addresses that respond?
    We may have multiple units responding and the MAC address will allow the operator to determing which unit to connect to.
    I'll try the InetPing to see how it works,
    Kirk

  • Can someone tell me how to get my apps that are on my ipad to appear on my TV using Apple Tv

    Can someone tell me how to get my apps that are on my IPad to be viewed on my Apple TV?

    Welcome to the Apple Community Coachcad.
    Basic AirPlay: Assuming both devices are on the same network and that AirPlay is not turned off on the Apple TV, then simply tap on the screen when you are watching content you wish to stream to your Apple TV, then tap the airplay icon that appears in the control bar, choose the Apple TV from the menu that appears.
    Mirroring: When displaying the content you wish to mirror on the iPad 2 (or better), iPad Mini, iPhone 4S (or better), swipe from the bottom of the screen, tap the AirPlay icon and choose your Apple TV from the list of devices (iOS 7 or better) or double tap the home button (quickly) and swipe the bottom row of apps to the right to reveal the playback controls, tap the AirPlay icon and select your Apple TV from the list of available devices (pre-iOS7)

  • I just bought my iPad air and I would like to know how to get the App Store on it

    I just bought my iPad air and I would like to know how to get the App Store on it?

    It is included.

  • TS1702 When I try to update two certain apps in the App Store, I get a message that says 'cannot connect to iTunes store'. Any idea how to get these apps to update?

    When I try to update two certain apps in the App Store, I get a message that says 'cannot connect to iTunes store'. Any idea how to get these apps to update?

    Check that the apps are still available in the store

  • Instructions How To Add Web Apps

    Can someone tell me how to add web apps like the games and flashlight. I'm having a mental block lol Theres no download button on the apple site or in itunes that ive found.
    Thanks!

    Hi Jraps39
    Currently there are 2 answers to this question.
    The first applies if your iPod touch hasn't been updated with the January Software Upgrade which you can purchase through the iTunes music store. If this is the case then there is no official supported way of adding buttons to your home screen to those web apps. You can however bookmark them in Safari.
    If you have downloaded the January Software Upgrade through the iTunes Music Store then you will be able to tap the plus sign in the middle of the button bar at the bottom of the webpage in Safari and it will give you the option to "Add to Home" which will add an icon to your home screen.
    Some users have found alternative methods that are unofficially supported and cannot be mentioned on this forum however I hope the above answers your question.

  • My Itunes account is on my dad's user. I downloaded Itunes on my user, and I am wondering how to get the apps I downloaded on my dad's user, on mine? Sorry if the question is confusing.

    Our computer has users that you click to log on. My itunes thingy is on my Dad's and I downloaded Itunes on my user, and i am wondering how to get the apps I downloaded on my  dad's itunes, to mine. Thanks for any help.

    iPads sync to 1 computer only.
    All media and apps are tied to the Apple ID that purchased them.
    Without your relatives ID and password, you cannot update any of the Apps.
    I am pretty certain he is also violating Apples terms of service by giving you the apps.

  • I accidentally deleted all my apps and music. I can re-download the music but don't know how to get the apps back without buying them again. Any thoughts?

    I accidentally deleted all my apps and music. I can re-download the music but don't know how to get the apps back without buying them again. Any thoughts?

    Just follow this:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How to get online apps to work with the Verizon DSL modem firewall set at "Medium" level, not "Low?"

    How to get online apps to work with the Verizon DSL modem firewall set at “Medium” level? Xbox 360 Live, FTP, and the Windows sntp Time checker native to Windows XP WON’T WORK unless the Verizon firewall is first reset down to “Low.” Then all works well, but I then risk low firewall protection. Setup: · Westell 6100 DSL modem (Software Version: VER:4.04.03.00 Transceiver Revision: 7.2.3.0 Model Name: C90-610015-06), · D-Link DIR-655 wireless router (Hardware Version: A3, Firmware Version: 1.21), For Xbox 360 Live the “canned” port forwarding rule for provided in Verizon’s drop-down list for the Westell 6100 modem forwards ports 88 and 3074 for both TCP and UDP. This does not meet Microsoft’s forwarding recommendations for Xbox 360 Live stated at http://support.microsoft.com/kb/908874. Instead, for the Verizon modem (Westell) I made a new port forwarding rule to comply with those Microsoft instructions. It forwards ports 53, 80 and 3074 for TCP and ports 53, 88 and 3074 for UDP. These same ports are also forwarded in the D-Link router configuration. For FTP, port 21 is also forwarded for TCP and UDP in both modem and router. But they don’t work until I first cripple the Verizon firewall down to “Low.” How to get them to work with the Verizon firewall up to Medium?

    While I do not know the answer to your question, BUT since you have this modem and another router - you could just follow.
    http://www.dslreports.com/faq/13600
    ^^
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

Maybe you are looking for

  • Using Current Windows-based External Hard drive on Mac

    Hello, I have a MacBook Pro now. I have BootCamp installed with Windows Vista. Working fine. I also have a Western Digital 160 GB external harddrive with data on it from my old Windows only computer. In other words, it is formatted with NFTS. I want

  • How do I capitalise first letter of sentence

    Hi there. Just moved over to Mac and Pages, and love it, for the most part, except it doesn't capitalise the first letter of a sentence. for instance the "f" in "for" there does not come up automatically as "F" as it does in Word, and I believe in pr

  • How to implement Google "Show more results" type image gallery

    Hello all, Need help with implementation of "Show more results" for an image gallery, similar to google images. The requirement is to display 10 images at a time and on click of button show the next 10 images by ajax. I have a db with image names and

  • Two files to send

    Hi all My interface it is proxy to file scenerio in that one targed directory and two receiver files two be placed based  on whare house code can u please help me out how to do itdynamic configuration to be used r not if yes send me how to be used me

  • ITunes keeps backing up apps despite I chose "Don't Back Up"

    My iPhone5 does NOT ever sync with iTunes on my mac. I only use iTunes to back up. I am trying to save disk space on my mac and do not want iTunes to back up anymore apps since I can easily redownload them from app store. When I click "Back Up Now" i