Resource path

First I checked it was all OK without POSIX and it works:
display dialog "Open last saved or choose file" buttons {"Open last", "Open other"} default button 2
if button returned of result is "Open last" then
set val1 to alias (read file "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt")
--Read pref file to find out path of last edited file.
if val1 is "Default" then
EditFile("no")
else
EditFile(val1)
end if
else
EditFile("no")
end if
on EditFile(val2)
if val2 is "no" then
set val3 to (choose file with prompt "Please select a .txt file:
To save a text file as .txt in TextEdit, click 'Make Plain Text' in the Format menu and save the file.")
--Get file path.
else
set val3 to val2
end if
if (get eof val3) is 0 then --Read doesn't like eof (end of file) to be 0 bytes.
set val4 to ""
else
set val4 to read val3 --Read file before it gets erased.
end if
open for access val3 with write permission --Open file.
repeat
set eof val3 to 0 --Erase file.
display dialog "Edit your text." default answer val4 buttons {"Revert", "Save"}
set {val5, val6} to {text returned of result, button returned of result}
if val6 is "Save" then
write val5 to val3
exit repeat
else
write val4 to val3
end if
end repeat
--Write to file giving old data as default (to give the same affect as as read and edit).
close access val3
open for access file "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt" with write permission
set eof file "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt" to 0
write (val3 as string) to file "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt" as text
close access file "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt"
--Save path of edited file to pref file.
end EditFile
But change that 3rd line to:
set val1 to alias (read file (path to resource "Save Location Pref.txt"))
gets the error:
Can’t make file (alias "Macintosh HD:Users:Richard:Library:Scripts:Richard's Text Editor 3.scptd:Contents:Resources:Save Location Pref.txt") into type file.

Use the following as the third line:
set val1 to alias (read file ((path to resource "Save Location Pref.txt") as string))
(47286)

Similar Messages

  • Netbeans  "resource path"

    Hi!
    I'm trying to create my first midlet using Screen Design. I've got problems with loading an image. I've added ImageItem and in Inspector window in Resources there's variable of Image type used by the ImageItem. In its properties there's Resource Path property. I tried to set it in Project Properties\Build\Libraries & Resources\ (I created folder "res" with few sample png & gif images inside my project folder) but when i click in Image properties on Resource Path to set the image there are no images to choose from. Where do i have to set this Resource Path?

    well, it seems there is a bug in the image chooser - it doesn't refresh content of the folder. However, you can specify the path manually - if you have for instance
    ${project}/res/image.png, type in /image.png. Also, you will be able to see all the images after restaring the IDE. The bug wil; be fixed soon.

  • Description Resource Path Location Type .... Warning Msg ....

    Hi there,
    I'm using some code from way back and I'm trying to use it within a newer project.
    The original code is as follows:
         import mx.styles.CSSStyleDeclaration;
         import mx.styles.StyleManager;
    protected static function classConstruct ():Boolean {
        if (!StyleManager.getStyleDeclaration("Page")){
            var defaultStyles:CSSStyleDeclaration = new CSSStyleDeclaration();
            for (var i:String in DEFAULT_STYLES){
         defaultStyles.setStyle(i, DEFAULT_STYLES[i]);
         StyleManager.setStyleDeclaration("Page", defaultStyles, true);
         return true;
    This gives me a couple of Warning !
    Description Resource Path Location Type
    3608: 'getStyleDeclaration' has been deprecated since 4.0.
    Please use 'IStyleManager2.getStyleDeclaration on a style manager instance'.
    Page.as line 146 Flex Problem
    I have been trying to change it, but I get Error Msg's now !
         import mx.styles.CSSStyleDeclaration;
         import mx.styles.IStyleManager2;
    protected static function classConstruct ():Boolean {
        if (!IStyleManager2.getStyleDeclaration("Page")){
            var defaultStyles:CSSStyleDeclaration = new CSSStyleDeclaration();
            for (var i:String in DEFAULT_STYLES){
         defaultStyles.setStyle(i, DEFAULT_STYLES[i]);
         IStyleManager2.setStyleDeclaration("Page", defaultStyles, true);
         return true;
    Any help would be very much appriciated. regards aktell2007

    Get a style manager instance by calling styleManager on a UIComponent or calling StyleManager.
    getStyleManager(moduleFactory);
    Each Application/Module has a style manager so using the top-level application will only work correctly if you do not use modules or sub-applications. Otherwise if a module calls code and sets a style into the top-level style manager, the module will be pinned in memory by that reference.
    As Alex said, put a defaults.css in your library.swc to set default styles. Look at how it is done in framework.swc and spark.swc.
    -Darrell

  • Gramps 4.0.0-1 giving Resource Path error

    Is it me or is anyone else getting gramps failing to run on a fully updated system with the error:
    $ pacman -Qi gramps
    Name : gramps
    Version : 4.0.0-1
    $ gramps
    ResourcePath.ERROR: Resource Path /build/pkg/gramps/usr/share is invalid

    I'm getting it to semi-work by using just the following command (no other mods or environment variables) to generate the resource-path file (as root):
    echo -n /usr/share > /usr/lib/python2.7/site-packages/gramps/gen/utils/resource-path
    Note the "-n". The resource-path file cannot have any whitespace (including carriage return) after the path. By doing this, gramps will start (just "gramps" at the command line), though I first get the
    No handlers could be found for logger "grampslocale"
    warning, followed by a series of error panels that state things like
    2013-05-23 18:41:01.375: ERROR: grampsapp.py: line 114: Unhandled exception
    Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/gramps/gui/widgets/validatedmaskedentry.py", line 1174, in do_changed
    if self._block_changed:
    AttributeError: 'Entry' object has no attribute '_block_changed'
    After clicking through all those, my database is open and I can navigate as usual. However, I continue to get _block_changed errors as I move around. In addition, I will say that 4.0.0 looks very raw - the UI could use a lot of spit and polish to bring it up to the usability of 3.4.4.
    Mike

  • Struts - Parsing error processing resource path

    StandardContext[bmd2]Marking servlet action as unavailable
    StandardContext[bmd2]Servlet /bmd2 threw load() exception
    javax.servlet.UnavailableException: Parsing error processing resource path
         at org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.java:1035)
         at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1014)
         at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
         at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850)
         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
         at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:316)
         at org.apache.catalina.core.StandardHost.install(StandardHost.java:859)
         at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:723)
         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:473)
         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1002)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:393)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133)
         at org.apache.catalina.core.StandardHost.start(StandardHost.java:816)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518)
         at org.apache.catalina.core.StandardService.start(StandardService.java:519)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:2343)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
    struts-config.xml
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
    <!-- ======================================== Data Source Definitions -->
    <data-sources>
         <data-source>
         <set-property property="driverClass" value="com.mysql.jdbc.Driver" />
         <!-- old name is com.mysql.jdbc.Driver -->
         <set-property property="url" value="jdbc:mysql://localhost/microarray" />
         <set-property property="maxCount" value="5"/>
         <set-property property="minCount" value="1"/>
         <set-property property="user" value="apache"/>
         <set-property property="password" value=null />
    </data-source>
    </data-sources>
    <!-- ======================================== Form Bean Definitions -->
    <form-beans>
    <!-- Logon Form offers user to enter credentials to sing in -->
    <!-- name specify the name of the Bean used -->
    <!-- type specify the location and the class name -->
    <form-bean
    name="logonForm"
    type="logon.LogonForm"/>
    </form-beans>
    <!-- ================================= Global Exception Definitions -->
    <global-exceptions>
    <!-- sample exception handler
    <exception
    key="expired.password"
    type="app.ExpiredPasswordException"
    path="/changePassword.jsp"/>
    end sample -->
    </global-exceptions>
    <!-- ================================== Global Forward Definitions -->
    <global-forwards>
    <forward name="logon" path="/logon/Logon.do"/>
    <forward name="logoff"path="/Welcome.do"/>
    <!-- Default forward to "Welcome" action -->
    <!-- Demonstrates using index.jsp to forward -->
    <forward name="welcome" path="/Welcome.do"/>
    </global-forwards>
    <!-- =================================== Action Mapping Definitions -->
    <action-mappings>
    <!-- Default "Welcome" action -->
    <!-- Forwards to Welcome.jsp -->
    <action
    path="/Welcome"
    type="org.apache.struts.actions.ForwardAction"
    parameter="/pages/Welcome.jsp"/>
    <action
    path="/logon/Logon"
    type="org.apache.struts.actions.ForwardAction"
    parameter="/pages/logon/Logon.jsp"/>
    <!-- LogonSubmit action -->
    <action
    path="/logon/LogonSubmit"
    type="logon.LogonAction"
    name="logonForm"
    scope="request"
    validate="true"
    input="/pages/logon/Logon.jsp">
    <forward name="userpage" path="/pages/user/User.jsp"/>
    </action>
    </action-mappings>
    <!-- ===================================== Controller Configuration -->
    <controller
    processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
    <!-- ================================ Message Resources Definitions -->
    <message-resources parameter="resources.application"/>
    <!-- ======================================= Plug Ins Configuration -->
    <!-- ========== Tiles plugin =================== -->
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
    <set-property property="moduleAware" value="true" />
    <set-property property="definitions-parser-validate" value="true" />
    </plug-in>
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
    property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>
    Anyone can give me some hints on where the error is?
    i have struts.jar and the other struts related files in \WEB-INF\lib

    I ran your file through an XML parser and the only error was on the line:<set-property property="password" value=null />because there are no quotes around "null". Fix that and try again. If you're using an IDE, there should be an option to validate the XML file which enables you to check struts.config before starting up the app.

  • ContextConfig[]: Exception processing JAR at resource path /WEB-INF/lib/..

    Hi,
    The application deployment works fine with Tomcat 4.0.6.
    Now I'm trying to upgrade to Tomcat 4.1.24 and am getting this exception...
    Using CATALINA_BASE: /users/home/cjain/nls/projects/CKJ_loaddb/java/deploy
    Using CATALINA_HOME: /nls/apps/tomcat
    Using CATALINA_TMPDIR: /users/home/cjain/nls/projects/CKJ_loaddb/java/deploy/temp
    Using JAVA_HOME: /nls/apps/jdk
    May 16, 2003 3:26:05 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on port 80
    Starting service Tomcat-Standalone
    Apache Tomcat/4.1.24
    HostConfig[localhost]: Expanding web application archive ROOT.war
    StandardHost[localhost]: Installing web application at context path from URL file:/users/home/cjain/nls/projects/CKJ_loaddb/java/deploy/webapps/ROOT
    WebappLoader[]: Deploying class repositories to work directory /users/home/cjain/nls/projects/CKJ_loaddb/java/deploy/work/Standalone/localhost/_
    WebappLoader[]: Deploy class files /WEB-INF/classes to /users/home/cjain/nls/projects/CKJ_loaddb/java/deploy/webapps/ROOT/WEB-INF/classes
    WebappLoader[]: Deploy JAR /WEB-INF/lib/jnlp-servlet.jar to /users/home/cjain/nls/projects/CKJ_loaddb/java/deploy/webapps/ROOT/WEB-INF/lib/jnlp-servlet.jar
    ContextConfig[]: Exception processing JAR at resource path /WEB-INF/lib/jnlp-servlet.jar
    javax.servlet.ServletException: Exception processing JAR at resource path /WEB-INF/lib/jnlp-servlet.jar
    javax.servlet.ServletException: Exception processing JAR at resource path /WEB-INF/lib/jnlp-servlet.jar
    at org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:930)
    at org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:868)
    at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:647)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:243)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3567)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
    at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:307)
    at org.apache.catalina.core.StandardHost.install(StandardHost.java:772)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:400)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:718)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:358)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
    at org.apache.catalina.core.StandardService.start(StandardService.java:497)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
    at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
    at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
    ContextConfig[]: Marking this application unavailable due to previous error(s)
    Any ideas what I'm doing wrong?
    Thanks,
    chet

    Found the solution...
    The deploy directory needs to have a temp directory in
    it!!!!We have had this problem too when upgrading to 4.1.27 but are confused about which directory should have a temp directory under it, and what the permission should be. Could someone enlighten us ?
    Thanks
    Janet

  • Custom SAPUI5 app in Fiori launchpad - wrong resource path

    Hi,
    I have successfully add custom tile for my custom  app to Fiori launchpad, when the application is run from its location (https://<server>:<port>/sap/bc/ui5_ui5/sap/zcart3/index.html) everything is ok, when I try to execute it from Fiori launchpad tile I got these errors:
    Error - found in negative cache: 'view/App.view.js' from ../../resources/view/App.view.js: 404 - NOT FOUND
    I think it is because SAPUI5 tries to load files from wrong location, so I have to somehow tell SAPUI5 framework where the files are...
    in the index.html I have these entries:
    data-sap-ui-resourceroots='{
      "zcart3" : "./",
      "view" : "./view",
      "model" : "./model",
      "util" : "./util"
    I think I have to add something to Component.js file of my app .
    Many thanks Jiri
    Tags edited by: Michael Appleby

    Hi Sekihara,
    many thanks for your suggestion, but I don't want to create Fiori application, I want to add my existing SAPUI5 application (which is working standalone) to Fiori launchpad, but when exetutes from Fiori launchpad, I got this error:
    Error - found in negative cache: 'view/App.view.js' from ../../resources/view/App.view.js: 404 - NOT FOUND
    Because FioriLaunchpad changed path to my application files from
    /sap/bc/ui5_ui5/sap/zcart3 to /sap/bc/ui5_ui5/ui2/ushell/resources,so the files of my app are not found...
    please see chrome console output:
    GET https://<server>:<port>/sap/bc/ui5_ui5/ui2/ushell/resources/view/App.view.js 404 (NOT FOUND) core-min-0.js:32
    2014-07-31 08:22:36 Error - failed to load 'view/App.view.js' from ../../resources/view/App.view.js: 404 - NOT FOUND 
    Thanks Jiri

  • Problems creating file. Can't get resource path.

    Hey, I'm new to Java with an Actionscript background and I'm using NetBeans IDE.
    Now this comes with my basic lack of understanding for how Java works but I'm getting confused a lot so if someone could just steer me in the right direction I'd be very grateful.
    Essentially I'm checking for a config file and if it's not there, I want to create a default one but the paths are messing me up. class.getResource seems to use the src or the build/classes dir? What's the relationship of these? If I put assets in the src folder should they be moved to the build folder or something like that?
    The actual problem in code is that if I create a file, (config.xml) and put it in my src folder I can grab it using Main.class.getResource("config.xml"); Which is great but if the file's not there it throws an exception..
    Now In actionscript I'd use the File class, which seems very similar to Java's. I'd pass in a literal for the filename "config.xml" and prepend a constant that gives the path of the apps storage directory. If the file's not there then the File.exists property == false.
    What I need is to get the same path that getReresource("config.xml") outputs, but in a File and I can't do that with the exception being thrown because the file's not there.
    Any help appreciated.. I can't read another blog full of different setups or face another Google page of results pertaining to different problems.
    - Chris W

    RoninStretch wrote:
    Essentially I'm checking for a config file and if it's not there, I want to create a default one but the paths are messing me up. class.getResource seems to use the src or the build/classes dir?It looks relative to the classpath, as I recall.
    What's the relationship of these? If I put assets in the src folder should they be moved to the build folder or something like that?NetBeans might do that for you. It's a reasonable thing for a build system to do.
    You might be better off working without an IDE until you're more familiar with Java.
    The actual problem in code is that if I create a file, (config.xml) and put it in my src folder I can grab it using Main.class.getResource("config.xml"); Which is great but if the file's not there it throws an exception..Actually I think getResource will return null if the resource isn't there. Are you not checking for null?
    Now In actionscript I'd use the File class, which seems very similar to Java's. I'd pass in a literal for the filename "config.xml" and prepend a constant that gives the path of the apps storage directory. If the file's not there then the File.exists property == false.The Java File object refers to a path on the filesystem, not a virtual one in the manner of Class.getResource. Check the result of getResource to see if it's null.
    What I need is to get the same path that getReresource("config.xml") outputs, but in a File and I can't do that with the exception being thrown because the file's not there.Can you show us the actual exception and actual code?
    Anyway, if you're packaging all this up in a jar, you wouldn't put the new config.xml that you create in the jar anyway.
    More likely you'd do something like:
    1) check user's home directory for config.xml
    2) if it's not present, check to see if there's a config.xml packaged in your jar.
    3) if the user has any config changes, put them in a config.xml in the user's home directory.
    So you wouldn't be trying to get the path of the default config.xml anyway.
    Or maybe you can use the Preferences framework.

  • Weblogic 10.3 _wl_cls_gen.jar not honoring resource paths

    I have simple application that utilizes ADF, and also utilizes a web service end point. I am successfully able to deploy and run within JDeveloper 11g's built in server. The issue I have is when deploying to a stand alone Weblogic 10.3 server. I have my resources packaged into a war and the folder structures are correct. The issue in particular has to do with the system looking for my wsdl.
    I get the following error while trying to run the system:
    java.io.FileNotFoundException: zip:C:/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/ewpsApplication/9gfvtn/war/WEB-INF/lib/_wl_cls_gen.jar!/com/docucorp/webservices/ewps/service/DocumentService.wsdl
    I understand that it is stating that it can't find this resource, the problem is that the resource is package in the following directory:
    /com/docucorp/webservices/ewps/service/_2005_12_01/DocumentService.wsdl
    It is like the system is ignoring the _2005_12_01 directory when looking for the resource. Can anyone help me out. By the way, I'm a novice at both Jdeveloper and WebLogic.

    I too have the same problem with the wlcls_gen.jar
    Any ideas about how to make things like resources available from here? This all works fine if I manually go in and extract this jar back into the WEB-INF/classes directory.
    Can I turn off this wlcls_gen.jar from being created?

  • HELP!  Getting static resource path.

    I have a Web Module (aka Web Application, aka WAR file). In the web app, there is an image file, let's call it image.gif. It is at the root directory of the web app. The same directory as the WEB-INF folder.
    Here is my problem. I need to include the full relative URL path of the image file when my Servlet writes it to HTML output. The reason, the servlet may be called from another context, therefore a path relative to the application context would break.
    So, somehow I need to programatically get something like --
    /myApp/image.gif OR
    http://www.xyz.com/myApp/image.gif
    Can anyone please help!!! FYI, I don't know if getRealPath() is the right thing, but if anyone knows better, please help....
    Thanks a lot....

    I created the following utility class to handle this with a few more options. It will let you get either the URI or URL provided that you know the relative path. The protocol (currently only HTTP & HTTPS work), server hostname, port, and context path are all found automatically. Here is... feel free to use it (Sun, this should be in javax.servlet.http.HttpUtils!):
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ContextMapper
    private static final int HTTP_PORT = 80;
    private static final int HTTPS_PORT = 443;
    public static String getUri (HttpServletRequest request, HttpServletResponse response, String relativePath)
    return request.getContextPath() + relativePath;
    public static String getUrl (HttpServletRequest request, HttpServletResponse response, String relativePath)
    if (request.getProtocol().startsWith("HTTP/") == true)
    if (request.getServerPort() != HTTP_PORT)
    return "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + relativePath;
    else
    return "http://" + request.getServerName() + request.getContextPath() + relativePath;
    else if (request.getProtocol().startsWith("HTTPS/") == true)
    if (request.getServerPort() != HTTPS_PORT)
    return "https://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + relativePath;
    else
    return "https://" + request.getServerName() + request.getContextPath() + relativePath;
    else
    return relativePath;
    That's it... you can use it from your Servlet or JSP like this:
    ContextMapper.getUri(request, response, "/image.gif");
    ContextMapper.getUrl(request, response, "/image.gif");
    ContextMapper.getUri(request, response, "/jsp/HelloWorld.jsp");
    ContextMapper.getUrl(request, response, "/jsp/HelloWorld.jsp");
    ContextMapper.getUri(request, response, "/servlet/HelloWorld");
    ContextMapper.getUrl(request, response, "/servlet/HelloWorld");

  • How is mainBundle Resource Path Initialized?

    Hello,
    I am grafting code from a working project into a new project I've created. In the viewDidLoad method the working project creates a string like this:
    NSString* bitmapFont = [[NSBundle mainBundle] pathForResource:@"Arial_bmpFont" ofType:@"BMP" inDirectory:nil];
    This works fine. But when the same code runs in my new project (same platform, same Xcode), this call results in nil. I suspect some sort of project configuration issue, but haven't figured it out yet. I'm having the same problem trying to read files - I can open them in the old project, but not the new one, even though I've copied over the files into the same relative location.
    Any clues appreciated,
    Joe

    I've copied over the files into the same relative location.
    Doing a Finder copy won't work, you must use the Xcode 'add existing file' in the new project.
    To be clear:
    Right click on a file group, select 'Add', and then 'Existing Files".
    Message was edited by: xnav

  • How to get the output path in Java?

    Hi all,
    is there a way (method) to get the output path (where compiled classes are put) in Java?
    thx a lot!
    Michele

    If you have already successfully loaded the classes into memory, and you want to find out where the classes are physically stored, then you can use Class.getResource() to retrieve the location of the file.
    import java.net.URL;
    public class Find
      private void run(String obj) {
        try {             
          Class cls = Class.forName(obj);
          //Here is the change to input correct resource path
          //instead of class name 
          String resourcePath = "/"+obj.replace('.','/')+".class";
          URL url = cls.getResource(resourcePath);
          System.out.println(url);
        catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        Find find = new Find();
        find.run(args[0]);   
    }java Find java.lang.String
    jar:file:/usr/local/j2sdk1.4.2_13/jre/lib/rt.jar!/java/lang/String.class
    Edited by: Jin on Oct 23, 2007 10:38 AM

  • How to specify a file path in java code to run on Unix machine?

    Hi
    I have a problem when running my project Swing on Unix machine.
    In my code, the user will press a button and then the program will look for the file "ReadMe" in the folder "Documentation" , and reads the content of this file. My code is "Documentation\\ReadMe" and it works well on PC. (The folder "Documentation" is in the same directory with my Java code).
    But when I try on Unix, the program can not read the file. It can only read the file "ReadMe" if I take this file and put it in the same directory with my Java code ( this means not through another folder). So how can we make it read the file in a folder ? It seems that "Documentation\\ReadMe" does not work in Unix, or the symbol "\\" does not work.
    I would be thankful if anybody can help me with this.
    Thank you very much

    You really shouldn't use any path method, as neither are very consistant or platform independent. The JVM provides a way to grab resources from the classpath. These resources can be any data at all, in fact, it's how java itself locates classes. Here's an example how you would do this in a non-static method.
    public URL getReadMe() {
      // In this context the forward slash is universal
      String docDirectory = "Documentation/"
      // We have to use the classloader to grab the resource
      ClassLoader cl = this.getClass().getClassLoader();
      // Next we get the resource 
      URL readMeURL = cl.getResource(docDirectory + "ReadMe");
      return readMeURL;
    }The URL can be used in whatever way you need to get the information out of the resource. If it was an image you might use the "Toolkit" to make an image object out of it. The great thing about this method is it will work even if your loading the program out of a Jar file. The resource paths start at the top of the classpath, just like classes.

  • Extending Resource Catalog: How to create subfolders.

    Hi,
    we are extending the webcenter spaces application as described in this document:
    http://www.oracle.com/technology/products/webcenter/pdf/owcs_r11_extend_spaces_wp.pdf
    We have succesfully extended the Resource Catalog for both the Personal Space and the Group Spaces to include a folder with our custom taskflows. Nevertheless we could not achieve to generate (non dynamic) subfolders in order to organize our tasflows based on functionality. I haven't seen if this is possible of not anywhere but we have tried with this and it didn't work.
    <?xml version="1.0" encoding="UTF-8"?>
    <catalogDefinition id="PersonalSpaceCatalog" name="Personal WebCenter Catalog"
    description="Resource Catalog definiton for Personal WebCenter"
    resourceBundle="oracle.webcenter.webcenterapp.resource.PersonalSpaceCatalogBundle"
    definitionFilter="oracle.webcenter.webcenterapp.internal.model.catalog.PersonalSpaceCatalogFilter"
    xmlns="http://xmlns.oracle.com/adf/rcs/catalog">
    <schema>
    <descriptor searchable="true" labelKey="TITLE.PROMPT_KEY"
    endUserVisible="true" shortLabelKey="TITLE.SHORT_PROMPT_KEY"
    attributeId="Title" multivalue="false"/>
    <descriptor searchable="true" labelKey="DESCRIPTION.PROMPT_KEY"
    endUserVisible="true"
    shortLabelKey="DESCRIPTION.SHORT_PROMPT_KEY"
    attributeId="Description" multivalue="false"/>
    <descriptor searchable="true" labelKey="SUBJECT.PROMPT_KEY"
    endUserVisible="true" shortLabelKey="SUBJECT.SHORT_PROMPT_KEY"
    attributeId="Subject" multivalue="true"/>
    <descriptor searchable="true" labelKey="WEBCENTER_SERVICE_ID.LABEL"
    endUserVisible="false"
    shortLabelKey="WEBCENTER_SERVICE_ID.SHORT_LABEL"
    attributeId="WEBCENTER_SERVICE_ID" multivalue="false"/>
    <descriptor searchable="false" labelKey="TOOL_TIP.LABEL"
    endUserVisible="false" shortLabelKey="TOOL_TIP.SHORT_LABEL"
    attributeId="ToolTip" multivalue="false"/>
    <descriptor searchable="false" labelKey="ICON_URI.LABEL"
    endUserVisible="false" shortLabelKey="ICON_URI.SHORT_LABEL"
    attributeId="IconURI" multivalue="false"/>
    </schema>
    <contents>
    *<!-- My Custom Task Flows Folder -->*
    <folder id="customTaskflowsFolder">
    <attributes>
    <attribute value="Custom Taskflows" attributeId="Title" isKey="true"/>
    <attribute value="A collection of custom taskflows"
    attributeId="Description" isKey="true"/>
    <attribute value="Taskflow" attributeId="Subject" isKey="true"/>
    <attribute value="custom.oracle.webcenter.ps.taskflow"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/img/home_cs_ng.jpg" attributeId="IconURI"/>
    </attributes>
    <contents>
    *<!-- My SubFolder -->*
    <folder id="customNavigationTaskflowsFolder">
    <attributes>
    <attribute value="Navigation" attributeId="Title" isKey="true"/>
    <attribute value="Custom Navigation Taskflows"
    attributeId="Description" isKey="true"/>
    <attribute value="Navigation Taskflow" attributeId="Subject"
    isKey="true"/>
    <attribute value="custom.oracle.webcenter.ps.taskflow.navigation"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/img/home_cs_ng.jpg" attributeId="IconURI"/>
    </attributes>
    <contents>
    <resource path="navigation-taskflow-war-1.0-SNAPSHOT.jar/ADF_TaskFlow/WEB-INF+ps-local-toolbar.xml#ps-local-toolbar"
    repository="application.classpath" id="ps-local-toolbar">
    <attributes>
    <attribute value="Local Toolbar" attributeId="Title"
    isKey="true"/>
    <attribute value="Local Toolbar" attributeId="Description"
    isKey="true"/>
    <attribute value="Local Toolbar" attributeId="Subject"
    isKey="true"/>
    <attribute value="custom.oracle.webcenter.spaces.ps.taskflow.navigation.localtoolbar"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/adf/webcenter/community_qualifier.png"
    attributeId="IconURI"/>
    </attributes>
    </resource>
    </contents>
    </folder>
    *<!-- Other Taskflows -->*
    <resource path="peoplefinder-taskflow-war-1.0-SNAPSHOT.jar/ADF_TaskFlow/WEB-INF+people-finder-wide.xml#people-finder-wide"
    repository="application.classpath" id="ps-people-finder-wide">
    <attributes>
    <attribute value="People Finder (Inline results)"
    attributeId="Title" isKey="true"/>
    <attribute value="Look for people based on several attributes"
    attributeId="Description" isKey="true"/>
    <attribute value="People Finder" attributeId="Subject"
    isKey="true"/>
    <attribute value="custom.oracle.webcenter.spaces.ps.taskflow.peoplefinder.wide"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/adf/webcenter/community_qualifier.png"
    attributeId="IconURI"/>
    </attributes>
    </resource>
    <resource path="profile-taskflow-war-1.0-SNAPSHOT.jar/ADF_TaskFlow/WEB-INF+profile.xml#profile"
    repository="application.classpath" id="ps-profile-taskflow">
    <attributes>
    <attribute value="Profile" attributeId="Title" isKey="true"/>
    <attribute value="Profile" attributeId="Description" isKey="true"/>
    <attribute value="Profile" attributeId="Subject" isKey="true"/>
    <attribute value="custom.oracle.webcenter.spaces.ps.taskflow.profile"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/adf/webcenter/community_qualifier.png"
    attributeId="IconURI"/>
    </attributes>
    </resource>
    <resource id="ps-personal-snapshot" repository="application.classpath"
    path="personalsnapshot-taskflow-war-1.0-SNAPSHOT.jar/ADF_TaskFlow/WEB-INF+personal-snapshot.xml#personal-snapshot">
    <attributes>
    <attribute value="Personal Snapshot" attributeId="Title"
    isKey="true"/>
    <attribute value="Shows the personal snapshot"
    attributeId="Description" isKey="true"/>
    <attribute value="Personal Snapshot" attributeId="Subject"
    isKey="true"/>
    <attribute value="custom.oracle.webcenter.spaces.ps.taskflow.personalsnapshot"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/adf/webcenter/community_qualifier.png"
    attributeId="IconURI"/>
    </attributes>
    </resource>
    <resource id="ps-company-info" repository="application.classpath"
    path="companyinfo-taskflow-war-1.0-SNAPSHOT.jar/ADF_TaskFlow/WEB-INF+company-info.xml#company-info">
    <attributes>
    <attribute value="Company Ingo" attributeId="Title" isKey="true"/>
    <attribute value="Shows the company info for a given user"
    attributeId="Description" isKey="true"/>
    <attribute value="Company Info" attributeId="Subject" isKey="true"/>
    <attribute value="custom.oracle.webcenter.spaces.ps.taskflow.companyinfo"
    attributeId="WEBCENTER_SERVICE_ID" isKey="false"/>
    <attribute value="/adf/webcenter/community_qualifier.png"
    attributeId="IconURI"/>
    </attributes>
    </resource>
    </contents>
    </folder>
    </contents>
    </catalogDefinition>
    Could anyone throw some light on this? Can this be done? Is there anything we may be missing in our XML?
    Many thanks.

    I'm migrating 10 years of mail from Thunderbird on a dusty Dell to my brand-new Mini. I've got tons of subfolders and filters, and I want to replicate the structure using Mail 3.0.
    No matter what I do, I can't seem to add a subfolder to the email accounts I have coming off of different servers (Yahoo, Gmail and 2 on Go Daddy.)
    The Mac help advice doesn't work -- I'm just given the options to place a new mailbox "On My Mac" or as an RSS feed.
    Any other suggestions? I'd keep T'bird, except that I heard that Mozilla's not going to continue developing it. This problem seems to be unique to Leopard. Or maybe just unique to me.

  • Resource is not visible in workbench Aplication View

    Hi,
    When i write any file into the repository from Java API or Dotnet services using writeResource(), then I am not able to see this resource from Application View in Work bench.
    Though i am able to read the resource using API but not able to open it from Work bench.
    Can any one tell me why this is happening???
    Regards
    Sunil

    It's been several months since you posted, so I'm not sure whether you still need this, However, I'm trying to do the same thing -- migrate only the new or changed forms between servers using the RepositoryService APIs, and I think I've found something that works.
    When I drag a resource into an application in ES2, the resource ends up with a ResourceProperty collection.  When I add a resource using the writeResource API call, however, this ResourceProperty collection is not created.  After some trial and error, I found that I could create a ResourceProperty collection when I create the Resource itself and then use the writeResource API call to add the resource to an application.
    The ResourceProperty that makes the resource visible is in the "System" namespace.  It's named "PRIMARY" and should have the value of
    "true".
    I use the .NET APIs, not the Java APIs, but I think the concept would be the same.  In the code below, "ES2RepositoryService" is a web reference to the LC ES2 repository service and "OriginalBlob" is the Blob read in from the region from which I'm migrating.
                Dim ES2LC As New ES2RepositoryService.RepositoryServiceService
                ES2LC.Credentials = New System.Net.NetworkCredential(<logon>, <password>)
                Dim NewBLOB As New ES2RepositoryService.BLOB
                NewBLOB.contentType = OriginalBLOB.contentType
                NewBLOB.binaryData = OriginalBLOB.binaryData
                Dim NewContent As New ES2RepositoryService.ResourceContent
                NewContent.dataDocument = NewBLOB
                NewContent.size = NewBLOB.binaryData.Length
                Dim NewResource As New ES2RepositoryService.Resource
                NewResource.id = New ES2RepositoryService.Id
                NewResource.lid = New ES2RepositoryService.Lid
                NewResource.content = NewContent
                NewResource.name = <resource name>
                NewResource.description = <resource description>
                'add properties
                Dim testProps(0) As ES2RepositoryService.ResourceProperty
                Dim newProp As ES2RepositoryService.ResourceProperty
                'this one makes it visible in Workbench
                newProp = New ES2RepositoryService.ResourceProperty
                newProp.name = "PRIMARY"
                newProp.namespace = "System"
                newProp.value = "true"
                testProps(0) = newProp
                NewResource.resourceProperties = testProps
                ES2LC.writeResource(<new resource path>, NewResource, Nothing, Nothing)
    Setting this "PRIMARY" property seems to be the trick to making the resource visible under the application in Workbench.
    When I drag a resource in, many other resource properties are generated as well, and these can be added just as the "PRIMARY" property was.  In my case I saw the following in the resourceProperties collection:
    In the "System" namespace:
    LASTUPDATEDBY                              - name of the last user who updated the resource
    PRIMARY                                    - "true"
    VISIBILITY                                 - this had the value of "Private"
    PUBLISHEDSTATUS                            - this was valued as "InProgress"
    RESOURCETYPE                               - this had the value of "TLO"
    Deployment Version                         - Nothing
    Deployment ID                              - Nothing
    In the "Custom" namespace:
    extension                                  "xdp"
    scope                                      "Far"
    relative-path
    absolute-path
    application-name
    isApplication                              "false"
    version
    If the resource is an XDP that has a relationship to another file (an XSD, for example) another ResourceProperty is created where
    the value is the path to the related file and the namespace is "Reference".

Maybe you are looking for