There has to be a way to find the current directory in JSP, right?

I've read a number of posts, with limited results.
Here's my problem. I have 3 databases set up, and I'd like to use a different one depending on which directory I am in. (ie Stage, Production, Dev). So I am reading the database name from a parameter file.
I am simply trying to read a text file from the same directory as my jsp file. For example, my jsp file is in /home/username/public_html/prod
When I try System.getProperty("user.dir"), it returns /home/username/public_html/.
Is there a way for the jsp page to let me know it is in the prod subdirectory? Verses another subdirectory? Everything I've tried puts me in either the /home/username directory or the home/username/public_html directory. I can't get to any of the subdirectories!!! Please help!

This is what I'm working with right now, seems to work. Anyone know a better way:
ServletContext context = getServletContext();
String servletpath_str = request.getServletPath();
StringTokenizer st = new StringTokenizer(servletpath_str,"/");
int nooftokens_int = st.countTokens();
nooftokens_int--;
String virtualpath_str = "";
for(int i=0; i<nooftokens_int; i++) {
if(i == 0) { virtualpath_str = "/" + st.nextToken(); }
else { virtualpath_str = virtualpath_str + "/" + st.nextToken(); }
String currentDir = context.getRealPath(virtualpath_str);
String filename = currentDir + "/file.txt";

Similar Messages

  • There has to be a way to print the calendars from iCloud.. Am I out of the loop?

    I know there is a way to do it with a screen grab and sizing your screen to show everything. That's not very Apple-esque though. Is there a better way?

    Restore from iCloud Backup
    1. Erase all contents and settings (Settings>General>Reset>Erase all content and settings)
    2. You'll be asked twice to confirm
    3. You'll see Apple logo and progress bar
    4. You'll see a big iPad logo on screen
    5. Configuration start
    6. Set language
    7. Set country
    8. Enable Location Service
    9. Select network, enter password and join network
    10. You'll be given 3 options (a) Setup as New iPad (b) Restore from iCloud Backup (c) Restore from iTune Backup
    11. Selected Restore from iCloud Backup
    12. You'll be required to enter Apple ID and Password
    13. Agree to Terms and Conditions
    14. Select Backup file
    15. You'll see progress bar
    16. Red slider will appear; slide to unlock; step #1 to #16 is fast
    17. Pre-installed apps will be restored first
    18. Message: Purchased apps and media will now be automatically downloaded
    19. You'll see a pageful of apps with Waiting/Loading/Installing
    20. When the restore process is complete, your device will restart. You should connect the device to iTunes to sync data not contained in the backup (such as music, videos, apps, and so on).

  • Finding the current directory

    within my program i need to know the current runing directory, my app. i portable and intended to be ran from usb stick and other portable media, so it will be different for each execution.
    im convinced that thisis far to easy a thing for me to figure out on my own, and help would be nice.
    thx

    ( new File( "." ) ).getCanonicalPath( )?

  • New Apple TV to non-HMDI... there has to be a way?!

    Ok so my TV is 4 years old it does not have an HDMI or DVI connection on the back. There has to be a way to connect the new Apple TV, right? The TV was build before HD TV was completely defined. It is an "enhanced def" TV. I am pretty sure it supports 720p
    I have found something called hdfury check it out on hdfury.com. I am thinking this may be my only hope? What do you think? Any other ideas?

    Actually, this may work, Gefen GTV-DIGAUD-2AAUD Digital-to-Analog Audio Adapter:
    http://www.geekbro.com/index.cfm/p/v/738504?source=GoogleBase
    You will also need to purchase a TOSLINK cable:
    http://www.monoprice.com/products/product.asp?cid=102&cp_id=10229&cs_id=1022901&pid=3396&seq=1&format=2
    If you have only one DVI input, you may need this also; search monoprice.com for 4088.
    4X1 Enhanced 1.3b Certified HDMI Switch with built-in Equalizer and Remote (REV.3.0):
    http://www.monoprice.com/products/product.asp?cid=101&cp_id=10110&cs_id=1011002&pid=4088&seq=1&format=2
    Also, product# 3871; (you may need several of these.)
    3FT 28AWG High Speed HDMI Cable w/Ferrite Cores - Black:
    http://www.monoprice.com/products/product.asp?cid=102&cp_id=10240&cs_id=1024008&pid=3871&seq=1&format=2
    You will need to investigate this further to determine yourself if the above suggestions will work.
    Hope this helps!
    Others on this discussion board may have other suggestions.
    Good Luck!
    Let us know how this works out.
    Alan

  • How do I find the current connections?

    I've noticed that the disk doesn't always spin down after using my media player (OSMC on a Raspberry Pi) to access my My Cloud, and I'd like to debug this. First, I need to see if there's a persistent connection by checking the connection status at the My Cloud command line.  Googling tells me that you use the "smbstatus" command for this -- and there's my first stumbling block. That command is not present because it's in the "samba" package, which I am surprised to find is not installed by default.  # apt-cache policy samba
    samba:
    Installed: (none)
    Candidate: 2:4.1.17+dfsg-2
    Version table:
    2:4.1.17+dfsg-2 0
    500 http://ftp.us.debian.org/debian/ jessie/main armhf Packages I could install the "samba" package with "apt-get install samba". Is that safe to do on the My Cloud? The My Cloud is all about providing samba shares and yet the "samba" package is not installed. I was wondering if it was not installed for a reason. Installing it won't trash the My Cloud's normal services? Or is there a better way to find the current connections -- one that doesn't need the "smbstatus" command?

    Hi and welcome to the WD community.
    I have not tried this, lets see if another user can share some tips and information on this matter.

  • Finding the current path

    Hey all,
    what is the shortest way to get the current directory?

    You can also call System.getProperty("user.dir"), which will return the user's current working directory as a String. Using "user.home" as the method parameter will give you the user's home directory. So if you want/need either of those directories, there's a simple 1-line way to obtain the values.
    -dSn

  • InCopy workflow in InDesign: Is there a way to find the document in which an ICML file has NOT been checked IN again before saving the doc?

    The situation:
    We are working with the InCopy feature (checking in and checking out ICML files).
    The problem:
    I might have saved a document with an ICML file still checked out.
    The question:
    Is there a way to find out which document was saved with the ICML file still checked out?
    or in other words:
    Is there a way to find the document in which an ICML file has NOT been checked IN again before saving the doc?
    Thanks for any help!

    Hello Sumit Singh,
    thank you for your answer and your reasonable recommendation. Unfortunately, this only works when the ICML content is used in one INDD file. In our case, we use ICML content in multiple docs (various manuals with the same safety instructions, warranties, adresses etc.).
    So, is there a way to trace back where an ICML has been used?
    Is it possible to find out in which document the ICML is still checked out?

  • I have files that freeze my programs whenever I try to open ANY file. Is there a way to find the exact files causing the crash?

    I have files that are freezing my programs (adobe; after effect and photoshop, as well as maxon cinema 4d). Whenever I try to import ANY file from within the program it doen't even let me select the file I need before freezing. I have moved all files off my desktop and into my dropbox, and it now allows me to import files/search for files on the desktop but NOT dropbox, once I go to dropbox it freezes again. I am assuming there are files within dropbox now that are crashing my programs. The problem is I have a lot of files in there and would like to remove the corrupt ones so that I can use my programs without freezing. Is there a way to find the exact files causing the crash?
    This has happened a couple of times and each time I have to move all my files off my desktop, so there must be a type of file doing this, I just don't know what files they are.
    Mac Book Pro 15" running OSX 10.9
    Processor  2.3 GHz Intel Core i7
    Memory  16 GB 1600 MHz DDR3
    Graphics  Intel Iris Pro 1024 MB
    ANY help would be greatly appreciated! It is making it really hard to get work done. THANKS!

    This error sounds to me like you have/had BootCamp Windows installed and then removed, posible ?
    If so (and even if not so), try restating your MBA while holding down the alt/option-key until you get to the Boot Selection Screen.
    Choose to boot OSX.
    Once in OSX go to System Preferences then Startup Volume and set your OSX to be the default.
    Hope it helps
    Stefan

  • Is there a way to find the total "ON" time on my MacPro?

    I was wondering if there was a way to find the total system "ON" time or usage time on my MacPro since I first purchased it?

    I don't believe there is any recordation of that, but someone else may know better. There is, however, a record of how much time the computer has been in use since the last restart: open the Terminal application in the Utilities folder and at the prompt enter "uptime" (without quotes) and press RETURN.

  • Is there a way to find the number of downloads of music from itunes store?

    Hi,
    Is there any way to find the number of downloads of each music file available on itunes store. If not exact no of downloads but atleast a relative term to find the rank of the music track From any API
    Thanks
    Sandeep

    A: Is there a way to read the number of active sequence executions from the Engine?

    Scott,
    > One way of handling the issue of init once a set of instruments is to
    > create a new sequence file that has a sequence to init and a sequence
    > to close the instruments. Assuming that you always terminate a
    > sequence and do not abort them, you could add a ProcessSetup and
    > ProcessCleanup callback sequences to the client sequence file that
    > using these instruments. These callbacks are automatically called by
    > the process model in both the Single Pass and Test UUTs execution
    > entry points. The callback sequences could call the init and close
    > sequences for the hardware. In the hardware sequence file you could
    > reference count the number of execution that init and close by setting
    > the file globals in the sequence file to be shared across executions
    > and then add a numeric value that keeps track of references for the
    > instruments. The init sequence adds to the count, and the close
    > sequence subtracts from the count. The init sequence inits the HW if
    > the count is 0->1 and the close sequence closes the HW if the count is
    > 1->0.
    >
    > This is one of many ways in TestStand that this could be done, not to
    > mention that this could also be done in a similar way in a LabVIEW VI
    > or DLL directly.
    That sounds like it will work. I'll try adding a client count
    increment/decrement in the DLL initialize and terminate functions. This
    should essentially perform the same tasks as the callback scheme you mention
    above, no?
    The reason I didn't think the 'client counting' scheme would work initially
    was I mistakenly thought that the termination function would not get called
    under Terminate conditions. Since Terminate conditions happen a LOT during
    our initial debug of new UUT types, I didn't think that would be acceptable.
    I forgot that lacing the terminate funciton in a cleanup step group, I can
    force it to be called in Terminate conditions.
    > If you abort an execution then the reference counting idea above would
    > fail to decrement properly. That might b... [Show more]

    Read other 5 answers

  • HT3986 I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation dis

    I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation disc which, then said the installation had been successful.
    Outlook is still not working.  Can anyone please advise me on what to do next.

    Remove MS Office 2011 completely (here are instructions) and reinstall it.
    It's not a simple or fast process but it is important to follow all of the steps in order to get all the files that Office scatters around. This will not affect your data files, only MS Office and its preferences.

  • HT4236 There HAS to be a way to get photos that were synced from the computer on to the iPad OFF of the iPad in a different way than having to email each individual photo back to oneself. And you can't delete them either, using up vital storage

    My Ipad2 has photos synced from my main computer on it, taking up vital storage.  I cannot remove them at all, and the folks at the Genius Bar can't help either.  Apparently there is no way to remove them unless they were originally taken by the Ipad2 camera.  And the only way you can get copies of those photos back on to the computer or another device is to individually email EACH photograph.
    There has to be a way to remove these pics to free up the storage.
    I almost was unable to load the new operating system because of the amount of photos on the iPad,which ended up on the iPad as a mistake in the first place during an early syncing when it was first purchased.
    This is a HUGE glitch in the system.  If you know otherwise, please advise!

    How to Transfer Photos from an iPad to a Computer
    http://www.wikihow.com/Transfer-Photos-from-an-iPad-to-a-Computer
    Importing Personal Photos and videos from your iOS device to your computer.
    http://support.apple.com/kb/HT4083
    The links below have instructions for deleting photos.
    iOS and iPod: Syncing photos using iTunes
    http://support.apple.com/kb/HT4236
    iPad Tip: How to Delete Photos from Your iPad in the Photos App
    http://ipadacademy.com/2011/08/ipad-tip-how-to-delete-photos-from-your-ipad-in-t he-photos-app
    Another Way to Quickly Delete Photos from Your iPad (Mac Only)
    http://ipadacademy.com/2011/09/another-way-to-quickly-delete-photos-from-your-ip ad-mac-only
    How to Delete Photos from iPad
    http://www.wondershare.com/apple-idevice/how-to-delete-photos-from-ipad.html
    How to: Batch Delete Photos on the iPad
    http://www.lifeisaprayer.com/blog/2010/how-batch-delete-photos-ipad
    (With iOS 5.1, use 2 fingers)
    How to Delete Photos from iCloud’s Photo Stream
    http://www.cultofmac.com/124235/how-to-delete-photos-from-iclouds-photo-stream/
     Cheers, Tom

  • Is there a way to find the serial number in these files so that I can reinstall the full version?

    I had to restore from backup to a new hard drive, and only have part of my Adobe Photoshop installation. Is there a way to find the serial number in these files so that I can reinstall the full version?  I have only part of the documentation so this is the best way I see to get the full version back.

    Hello brad,
    you did purchase your product from these firms like Amazon, so you didn't get a serial number, only a code with which you can request a serial number from Adobe. Please have a look at http://helpx.adobe.com/x-productkb/global/find-serial-number.html. (Start here: How did you purchase your product?)
    The following part, so I just see at least, ceased to exist on my Adobe website, everything takes place in the link from above. I leave it as an info yet, it might still fit for you. For this purpose, please click your way through to your Adobe Store and find the button "Get Serial Number". Fill in the form and after a while you will get the real serial number.
    Additionally you should have a look at Adobe's database, to see what's stored/saved about your accounts. Here you will find general infos about your Adobe Account.
    On the other hand, if necessary and for further questions click through http://helpx.adobe.com/contact.html and if "open" please use the chat, I for may part had the best experiences. I quote from Adobe's employee Preran: The chat button is activated as soon as there is an agent available to help.
    Hans-Günter

  • Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

  • My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes.

    My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes. Please help with anyway I can get the Ipod recognized so I can download music from Itunes to my Ipod. Thanks in advance.

    Hello xerxes.nashion,
    It sounds like your iPod is not recognized by iTunes or your MacBook Pro.  I recommend following the steps in the article below for an issue like this:
    iPod not recognized in iTunes and Mac desktop
    http://support.apple.com/kb/TS1410
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

Maybe you are looking for

  • How to connect airport time capsule to BT home hub 4

    I am finding it difficult to connect my new airport time capsule (ATC) to the BT home hub 4. On opening the time machine it asks me to configure the time capsule before using. Should I be using the ATC as time machine only or should I be re-routing w

  • Nano not syncing with iTunes but syncs with windows

    I cannot sync my sons Xmas present with iTunes. I have tried changing the drive and turning of iPod in systems and starting it again but no joy. It is recognised in windows but iTunes does not recognise it, my son is gutted as he cannot use it and so

  • Mic set-up for conference room?

    Hi, My company recently expanded and I need to rethink our current mic set-up.  What I'd like to do is use a mic connected to the computer to project to the other participants on the call and through our speaker set-up in our office.   Any suggestion

  • How can you find out what generation your iPod touch is?

    How can you find out what generation your iPod touch is?

  • Adding Norwegian to the spelling menu

    Hi. I have found the spelling menu, but there is no post for norwegian even though I have set Norwegian as my main language. Yes I have an english copy of OsX. I have been told that I need the .dict package to make it work. Where do I get it?