Default Directory for JSP

Using Eclipse with Tomcat 6.0 Server, I have the following directory structure:
/Project
/WebContent
  webpage.jsp
  /PicsI am trying to access files within the Pics directory through the JSP. I figure this should be possible by getting the JSP document's directory and calling the Pics directory from that. However, I can't seem to figure out how to do this. I have tried
new File(".").getCanonicalPath();but that returns a path to my user directory within the operating system. I feel like this should be really easy, and I feel pretty dumb being unable to figure it out (nor able to find this on Google/SDN), so if somebody could just put me out of my misery with a line or two of code (or even just the call I need to make) I would really appreciate it.
Thanks!

ServletContext#getRealPath() returns the absolute path for the given relative web path.
String absolutePathOfWebRoot = getServletContextSomehow().getRealPath("/");
String absolutePathOfPicsDirectory = getServletContextSomehow().getRealPath("/Pics");

Similar Messages

  • How to set default directory for SQL LOADER

    hi all,
    i wanted to know how can we setup a default directory for SQL LOADER if at all we can. i connot place my control and data files in local system and use them at command prompt. rather i wanted to know if we can set default directory that the loader can use. this requirement is basically to enable all the clients to upload the data placed on the server and use the loader utility.
    thanks in advance,
    Basavraj

    Ella,
    You don't say which version of SQL Developer you are using via Citrix, but just setting the SQLDEVELOPER_USER_DIR hasn't worked for a long time (see Re: SQLDEVELOPER_USER_DIR does not function anymore). Also, since version 1.5, the default for the user directory (now set via ide.user.dir as shown below) is under the user profile area (relative to %APPDATA%), which you should be able to write to, even on Citrix.
    Assuming that neither of those help, you will need to get whoever installed SQL Developer on the Citrix C: drive to modify the sqldeveloper.conf to have a line like, where the path exists for everyone who will be using the shared SQL Developer (assumes everyone has a H: drive):
    AddVMOption -Dide.user.dir=H:\sqldeveloperAn alternative (depending on how you start SQL Developer via Citrix), is to create your own shortcut to start SQL Developer with something like:
    sqldeveloper -J-Dide.user.dir="%SQLDEVELOPER_USER_DIR%"theFurryOne

  • [WL5.1] Virtual Directory for JSP: Possible??=

    Hi,
              I'm looking for a way to use a virtual directory for JSPs within my
              webapp. I want to access my JSPs by e.g. /webappname/layouts/jspname.jsp
              while they should be physically located somewhere else in the file
              system. The following snippet works for static files, but I suppose
              there is no docHome for JSPs:
                   <servlet>
                        <servlet-name>ImageAlias</servlet-name>
              <servlet-class>weblogic.servlet.FileServlet</servlet-class>
                        <init-param>
                             <param-name>docHome</param-name>
                             <param-value>c:\dev\fbs\images\</param-value>
                        </init-param>
                   </servlet>
                   <servlet-mapping>
                        <servlet-name>ImageAlias</servlet-name>
                        <url-pattern>/image/*</url-pattern>
                   </servlet-mapping>
              Thanks for any hints,
              Daniel
              

    Hi,
              I'm looking for a way to use a virtual directory for JSPs within my
              webapp. I want to access my JSPs by e.g. /webappname/layouts/jspname.jsp
              while they should be physically located somewhere else in the file
              system. The following snippet works for static files, but I suppose
              there is no docHome for JSPs:
                   <servlet>
                        <servlet-name>ImageAlias</servlet-name>
              <servlet-class>weblogic.servlet.FileServlet</servlet-class>
                        <init-param>
                             <param-name>docHome</param-name>
                             <param-value>c:\dev\fbs\images\</param-value>
                        </init-param>
                   </servlet>
                   <servlet-mapping>
                        <servlet-name>ImageAlias</servlet-name>
                        <url-pattern>/image/*</url-pattern>
                   </servlet-mapping>
              Thanks for any hints,
              Daniel
              

  • Default Directory for iMovie08

    My students save their work on a 4 TB NAS; at least they did until iMovie 08. Is there any way to change the default directory for iMovie08 projects and save them on our classroom server?

    RossD8 wrote:
    My students save their work on a 4 TB NAS; at least they did until iMovie 08. Is there any way to change the default directory for iMovie08 projects and save them on our classroom server?
    I have a somewhat similar question -- it seems there should be a simple way to move the "movies" folder wherever you want, but I'm afraid to even try lest I mess everything up. I bought a 250 gig external hard drive, and I want to store all my movies on that automatically, so that I can work on them both on the new laptop and on the about-to-be-ordered iMacs.
    Can anyone help?
    Thanks!!
    susan

  • Change default directory for Creative files (such as Media Databa

    I'm using a Zen xtra with WinXP Pro on my company laptop. The Creative software puts a lot of files (7 MB!) in my user profile under Document and Settings. Unfortunately, this is making my profile larger than my company allows, since they back up the profile over the network.
    How can I change the default directory for these file? I can't find any .ini files that might declare the path, and I can't find anything in the Windows Registry that points to my profile.
    Help please?
    Thanks,
    Luke

    Thanks for the suggestion of deleting the JetFileBackup folder, Micromouse. I'll try it.
    Any other files look deletable? Without any way to move them, I may have to try deleting some and see what happens.
    I'm not even sure which Creative programs can be uninstalled (other than Nomad Explorer) and still be able to use MediaSource to play songs from my Zen Xtra (through a USB connection). Windows Add/Remove Programs says that I've used all of these programs today:
    Creative Jukebox Driver
    Creative MediaSource
    Creative MediaSource AudioSync Plugin
    Creative MediaSource NOMAD Jukebox 2/3/Zen Plugin
    Creative NOMAD Jukebox Zen Xtra
    But all I've done is open MediaSource and start a playlist from my Zen Xtra. Anybody know which of those can be uninstalled without affecting my use? (Maybe this deserves a separate topic.)
    Thanks,
    Luke

  • Changing default directory for iTunes Library.itl and iTunes Music Library.

    I need to change the default directory for the files iTunes Library.itl and iTunes Music Library.xml permanently.
    It must be relocated from the My Documents directory due to VPN reasons.
    Has anybody an idea if this is possible? I could not find a corresponding registry entry.
    Notebook Windows XP Pro

    Using TweakUI to Move or Create Your Library/My Music Location
    Use TweakUI (See: ’Disk is locked’ or ‘iTunes folder cannot be found’ when installing or opening iTunes ) to create a 'My Music' folder in a spot where you desire. iTunes should then find this location and deposit its Library files there, and the 'iTunes' folder and sub-folders as well (if you direct it to).
    First, see this Article for some background information: What are the iTunes Library files?
    If you cannot see the ‘My Music’ folder within the TweakUI drop-down selection, proceed on to the following:
    1 On the start menu go to ‘Run’
    2 Type in RegEdit
    3 Navigate in RegEdit to HKEYCURRENTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    4 Delete any entry for ‘My Music’
    5 Navigate up the tree to HKEYCURRENTUSER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    6 Make sure there is an entry for ‘My Music’ and is pointing to C:\Documents and Settings\[username]\My Documents\My Music (you can edit the value by double clicking it)
    7 Close RegEdit
    8 Reboot
    iTunes &/or TweakUI should now be able to find the folder.

  • Default directory for FIle Manager

    Hi,
    I am working on file manager for my final year project. I am using jsp, Tomcat and Linux as OS.
    The question is,
    "Is there any way to authenticate users from OS(linux or windows 2000) and how can i set user home directory(e.g. home/sahsan/) to my file manager default directory"
    I really appreciate if anybody help me in this regard. I am ready to read any article,tutorial or even any book chapter for this purpose. Coding Help will be best choice ;-)
    Thank you.
    Regards,
    Syed Ahsan

    I am not sure, i am in search of the code as well. pls let me know if u come across something. i will keep u posted if i know some.........
    Riz

  • Default directory for sql script in iSqlplus 10g

    I want to run an sql file from the url as "http://machine_name.domain:5560/isqlplus/dynamic?script=http://machine_name2.domain/myscript.sql
    ". What is the default directory to place the file myscript.sql in? Do I need to create a DAD for specifying a different directory?
    Am using Oracle 10g.
    AN

    Hi Alison,
    I tried putting the sql script on different directories on the Oracle server but the url doesnt seem to find the script at all. It gives an error "Cannot find sql script".
    I have not installed Oracle Application server 10g yet. Am only running Oracle Database 10g with iSqlplus and PL/SQL.
    AN

  • Default directory for FileRaeder

    Hi, i have a question, what is the default directory that the filereader class uses?
    I have written an application witch uses the following line:fr = new FileReader(fileName);
    i know filename is the correct name of the file because it works corretc with my other jre. But my other jre can't find it.
    Thanks for any help.
    robert

    i found out it is Thnx. I overlooked that posibility at first becausea .lnk file was starting my program.
    Thnx
    Robert

  • What is the default directory for the PHP uploads, i.e. upload_tmp_dir = ?

    I would like to know the default directory that is referenced in the php.ini file under the category of "upload_tmp_dir =" for the OS X server 10.5.8.

    This is the best info that I have found:
    http://bugs.php.net/52460
    Still, just wondering what the default for 10.5.8 is supposed to be before I go and change the php.ini entries.

  • Where do I change the default directory for print to file?

    Currently the file is placed in the Mozilla Firefox directory under the Programs files directory. I want to change the default directory.

    This is not solved as I do not know where to change the default directory.

  • Cannot change the default directory for the web services

    When I change the default directory the drive letter always changes back to the drive letter the project was loaded from.
    Software version Labview 2009.

    Did you change the default page within your code?  Everytime you start the vi, it will revert to that page.
    When you change the default directory (if it is a control on the Front Panel), did you right click the control and select save as default?
    Otherwise, each time you re-open the VI, it will revert to the actual default value, which was the previous directory.

  • How to create a directory for JSPs under infrastructure "root"?

    Hi,
    I'm not very familiar with Oracle 10gAS, but someone else got it configured and running on a Solaris 9 system, so my terminology may not be correct...
    We now have an "infrastructure" website (at port 7777) and an "ias" website (at port 8000).
    Right now, under the "infrastructure" website, we have the following applications:
    - sso
    - oiddas
    These all are "under" an OC4J instance called "OC4J_SECURITY".
    I need to somehow configure things so that I have a directory directly under the "root" of the "infrastructure" website (e.g., at http://<host>:7777/myjspdirectory) where I can run some JSPs. For example, I want to be able to put a JSP named "foo.jsp" and be able to access it at http://<host>:7777/myjspdirectory/foo.jsp.
    Is there a SIMPLE way to do this? If there is, can someone provide the specific steps (e.g., which directories, and files I need to create/modify)?
    It's not a "full" web application, so I don't want to have to create a WAR, etc.
    So far, I think that I need to add some "MountOc4j" lines to the mod_oc4j.conf file:
    Oc4jMount /myjspdirectory OC4J_SECURITY
    Oc4jMount /myjspdirectory/* OC4J_SECURITY
    But, after that I'm kind of lost :(...
    Is the only way to create a full WAR and then try to deploy it?
    Sorry if my question is somewhat confused, but I guess I am :(...
    Thanks in advance,
    Jim

    qlin,
    Ok, thanks.
    I've been working on creating a WAR the last several hours. I don't have 10g AS here at home, so I've been testing the deployment of the WAR on Tomcat.
    If the WAR deploys all right in something like Tomcat, will it deploy correctly in 10g AS also?
    Are there any "gotchas" that I should be aware of ahead of deploying the WAR on 10g AS?
    Also, I have a bunch of JSPs, but in the the web.xml that I'm using in my testing, it seems to work even though I don't list all of the JSPs. Here's what I have:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
         <servlet>
              <servlet-name>foo1</servlet-name>
              <jsp-file>foo1.jsp</jsp-file>
         </servlet>
         <display-name>WhatEverNameYouWantDisplayed</display-name>
         <description>replace this with a short description</description>
         <welcome-file-list>
              <welcome-file>foo.html</welcome-file>
         </welcome-file-list>
    </web-app>
    Is that (only including one pair of <servlet-name> and <jsp-file> tags all right, or do I have to include a pair of tags for EACH JSP?
    Other than the above, hopefully things will go all right tomorrow... I'm going to have to undo the edits that I did manually on mod_oc4j.conf (the Mount...) and in server.xml before I try the WAR deploy, I think, right?
    Jim

  • Default directory for file-upload in web.xml

    Hi,
    Does any one know how to specify a relative path for the temporary directory in the web.xml file.
    In the web.xml file under the jato_MultipartFormFilter filter I tried to change the name of the directory so that it reflects a relative path but it did not work. The deployment process gives the following exception:
    Failure creating test file in directory "tmpDir"; disabling temp file for uploads
    java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    When I tried to keep the default setting, i.e. keeping the tag empty. The server gives a permission denied since I am not accessing as the root user as shown next:
    Root cause:
    java.io.IOException: Permission denied
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.checkAndCreate(File.java:1314)
    at java.io.File.createTempFile(File.java:1402)
    The only thing I can do is specifying an absulte path from the root directoy '/' in my machine, not the root directory of the application.
    <init-param>
         <param-name>tempFileDirectory</param-name>
         <param-value>/home/Basil/myTemp</param-value>
    </init-param>
    Any help is greatly appreciated,
    Regards,
    Basil mahdi

    Todd and I discussed this last night. We did not seem to have included support for automatic detection of a relative path entry. We have issued an RFE for this. There is little that we can do if the file location cannot be opened due to permission problem. If the java.io.File temp file feature does not work for your web application then I suspect this is an issue in the application server; perhaps a misconfiguration or security policy issue. If you would like to indicate a path relative to context root then we have a workaround for you. Please use the call <ServletContext>.getRealPath("/"); and then append you relative path. This is essentially what we will end up doing when we implement the RFE. regards -matt-

  • Including Image Directory for JSPs / HTML

    I'm getting started with JDev 9.0.5 and am very impressed with the power and flexibility. I am trying to figure out how to add subfolders such as "images" and have the images included when deploying a Web app, but I must be missing something. Thanks.

    The top-level directory of a Web Application is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static Web resources are stored.

Maybe you are looking for