How to give relative path in web.xml?

Hi All,
Im creating a servlet which has to load the properties file.
I don't want to give the location of the properties file as ABSOLUTE PATH. But I'm unable to provide the same as RELATIVE PATH.
When I give the path is given as ABSOLUTE PATH (drive:/dir/) it is working. But if I give the RELATIVE PATH(../), the same is not working.
Kindly help me in this.
Regards,
Kumar Madhavan.
My web.xml file is:
<?xml version="1.0"?>
<!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>
     <display-name>NGT - ASCII</display-name>
     <description>Application for Safety Critical Information vIew.</description>
     <welcome-file-list>
          <welcome-file>ASCII.html</welcome-file>
     </welcome-file-list>
     <context-param>
          <param-name>asciifiledir</param-name>
<!-- This is the tag in which I would like to
          <param-value>../</param-value>
     </context-param>
</web-app

Hi.
Exclude the directory path from the <param-value/> in
the web.xml and just keep the property file name.
Place the property file in the classpath and load it
like this from the servlet:
Properties props = new Properties();
String propFileName = "" // Read param-value from web.xml
try {
InputStream is = TheServlet.class.getResourceAsStream(propFileName);
props.load(is);
} catch (Exception ex) {
System.out.println("Prop file not in classpath!");
/Jesper

Similar Messages

  • How to use relative paths in Captivate 8 / Cómo usar URL's relativas en Captivate 8

    Hello, I have developed a bunch of courses which will be migrated to a new site and I am having trouble changing the absolute paths into relative URL's to resources such as PDF files inserted into the scorm packages. I cannot find information on how to use relative paths in Captivate. Please help. Thank you.

    I have the same issue with relative links using Captivate 8.  I am trying to load Captivate modules into an LMS using relative links to document files within the LMS.  The links work fine during a site page test so not an issue in the LMS, but from the Captivate module they aren't working....
    Help?

  • How to give network path while creating oracle directory.

    I have created
    CREATE OR REPLACE DIRECTORY TESTDIR AS '\\168.176.33.117\TESTDIR';
    but through this path i m not able to create text file.
    create or replace procedure WriteTest is
    f utl_file.file_type;
    s varchar2(200) := 'this is some info';
    begin
    f := utl_file.fopen('TEST2DIR','sample2.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
    end WriteTest;
    Help how to give network path while creating oracle directory.
    --when i give local machine path then it will create at local machine where oracle is installed. but not able to create at other machine.
    Zakir

    Well for starters your directory object is called TESTDIR and in your fopen statement you are referring to TEST2DIR.
    On top of that I'm not sure oracle is happy to refer to network locations. I think you have to map it to a regular drive mapping (shared directory) type path. Can't say I've every tried to do it though.

  • XCM configuration path in web.xml file

    Hi,
    Here is a requirement that all the XCM configuration files are stored at local desktop(like QAT, PRD..), and need to use them by modifying web.xml.
    Please let me know at
    1)which web.xml tag the path of XCM confiuration files to be specified.
    2) specify the names of the XCM files for configuration to be put in that folder.
    Thanks,
    Devender V

    Hi,
    1)which web.xml tag the path of XCM confiuration files to be specified.
    Try to find below lines in your web.xml
    <context-param>
            <param-name>path.xcm.config.isa.sap.com</param-name>
            <param-value>/WEB-INF/xcm/sap/system/bootstrap-config.xml</param-value>
            <description>Turns the Extended Configuration Management on if a
                path to the configuration file is specified. It is a
                relative path, with context-root of web application as root</description>
        </context-param>
    bootstrap-config.xml file contains XCM configuration related XML file path. You can modify or extend this file and give your user Define path.
    Also you can find below line in web.xml file.
    <!-- Action Servlet Configuration -->
        <servlet>
            <servlet-name>action</servlet-name>
            <servlet-class>com.sap.isa.core.ActionServlet</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>/WEB-INF/config.xml,/WEB-INF/xcmadmin-config.xml,/WEB-INF/ccmsims-config.xml,/WEB-INF/ipc-config.xml,/ipc/customer/config.xml,/WEB-INF/config_lwc_b2b.xml,/WEB-INF/scheduler-config.xml,/WEB-INF/ipcpricing-config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>config/user</param-name>
                <param-value>/WEB-INF/config_user.xml</param-value>
            </init-param>
            <init-param>
                <param-name>config/dealerlocator</param-name>
                <param-value>/WEB-INF/config_dealerlocator.xml</param-value>
            </init-param>
            <init-param>
                <param-name>initconfig</param-name>
                <param-value>/WEB-INF/xcm/sap/system/init-config.xml</param-value>
            </init-param>
    I hope this will help you.
    eCommerce Developer

  • How can I change application's web.xml in NetWeaver CE 7.1?

    Hello Experts,
    Please help me. I need to configure a J2EE application on NetWeaver 7.1, but I don't know how I can change the web.xml of the application.
    The web.xml of the app needs to be modified during the configuration. This can be achieved via single-file-update in VA in Netweaver 6.4 or 7.0. But I cannot figure out how to do that in NW 7.1.
    Please show me how to do that or at least give me some hints.
    Thank you!
    Jack

    Hi Jack,
    In SAP NetWeaver 7.1 and later, you use the SAP NetWeaver Administrator instead of Visual Administrator.
    To get some information on how to configure web applications, try [THIS|http://help.sap.com/saphelp_nwce10/helpdata/en/45/48a60a528608d1e10000000a11466f/frameset.htm] piece of documentation.
    I hope it helps.
    Best,
    Yordan

  • How to read Standard JSR Portlet Web.xml's context-param

    Hi
    I am completely new to Java.
    I want to keep some configuration in Web.xml in Context param. My Web.xml looks like
    <context-param>
    <param-name>ConfigUrl</param-name>
    <param-value>http://localhost:8083/</param-value>
    </context-param>
    How can I read these values? Can I read these values directly in my JSP file or will I have to read it in my Portlet Class in some function.
    Thanks

    As soon as I use portletConfig, it gives me NullPointerException. I am definitely using <portlet:defineObjects/>
    My Jsp looks as :
    <%@ page contentType = "text/html; charset=windows-1252"
    pageEncoding = "windows-1252"
    import = "javax.portlet.*, java.util.*, port.Port, port.resource.PortBundle,javax.portlet.PortletContext"%>
    <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <portlet:defineObjects/>
    <%
    PortletContext ctx = portletConfig.getPortletContext();
    String configpath = "Hello";
    %>
    <label>Welcome</label>
    <label><%=configpath%></label>

  • How to specify relative path for background image  in xsl

    Hi,
    I am generating a PDF from Apcahe FOP. I have an xsl for that, in the xsl fo:block I am displaying a background image. When the image path is absolute like..C:\image\logo.png it works fine. But I want to have the image in my WebContent\images folder and my xsl file is in WebContent\xsls folder. So when I try giving the relative path as ../images/logo.png, the image is not displayed.
    Can anyone tell how to do this???
    Thanks,
    Sanjeev.

    I have a fo:block like this :
    <fo:block border-style="solid" border-width="0.2pt" text-align="left"
                             background-image="url('http://localhost:8080/Project/images/table_header_center.png')"
                             font-size="8pt" font-weight="bold" color="white" padding-top="1pt"
                             padding-bottom="1pt">
                             <xsl:value-of select="tr/td/span" />
                        </fo:block>In the above code you can see that the the background-image="url('http://localhost:8080/Project/images/table_header_center.png')"
    has been given as absolute. The images folder is in my WebContent directory. I want this path to be relative to the context of my application , something like background-image="url('../images/table_header_center.png')".
    Thanks.
    sanjeev.

  • How to configure IP address thrugh web.xml doubts

    Hello there
    I want to configure my web application. How can i initialise the IP Address and ports through web.xml file?
    thanks!

    ashish.251985 wrote:
    I want to configure my web application. How can i initialise the IP Address and ports through web.xml file?You cannot do that in the web.xml.
    At least the port can be configured in one of the configuration files in the /conf directory of the application server. The exact details and procedure depends on the application server implementation. Read its documentations.

  • How I can edit the file web.xml in JSC2??

    this is my only quiestion again...

    Use "Files" view of project (if isnt visible, go to menu "View" and select "Files"), then expand web node, then WEB-INF node and here you will found web.xml.
    Regards.

  • How to give URL path of image

    Hello Exprts ,
    I have following code to load an image from the table on screen.
    method FILL_PICTURE.
        types PICT_LINE(256) type X.
        data  PICT_TAB type table of PICT_LINE.
        data  URL(255) type C.
        import PICT_TAB = PICT_TAB from database abtree(PI) id 'PICTURE'.
        call function 'DP_CREATE_URL'
             exporting
                  TYPE    = 'IMAGE'
                  SUBTYPE = 'GIF'
             tables
                  DATA    = PICT_TAB
             changing
                  URL     = URL.
        call method PICTURE->LOAD_PICTURE_FROM_URL exporting URL = URL.    call method PICTURE->SET_DISPLAY_MODE
             exporting DISPLAY_MODE = PICTURE->DISPLAY_MODE_FIT_CENTER.
      endmethod.
    Now what I need to do is I need to give a path of the image on DMS, so where should I change this code?
    OR is there any other method to convert the path into URL?
    Please Help!!!!!!

    Somehow this question seems to pop up all the time. I don't blame you for asking it, though. The problem is that there is no easy or general way of doing what you ask for. You can have a look at the following thread to see some suggestions: http://forum.java.sun.com/thread.jsp?forum=31&thread=328939
    (Take a closer look at reply 27 in that thread.)

  • How to specify relative path for file name in java class

    I have a directory structure like this.
    C:\Aurora\com\optemys\aurora\validation
    I have a class Test.java under the validation folder.
    I have various files under the same folder i.e validation.
    If I want to access the file "test.properties" in Test.java, how can I just specify "test.properties" & not "C:\Aurora\com\optemys\aurora\validation\test.properties".
    I dont want to hardcode any file path into the class. How can I specify the relative file name into the class.
    Thanks In Advance
    Sachin

    switch the name in Test.properties and use
    this.getClass().getResourceAsStream(fileName)

  • XML data source and relative path

    Hi,
    I'm developing my reports in a Windows environment and deploying it on a Linux. My problem is, I cannot seem to specify a relative path for my XML datasource. Since, my deployement is in Linux, I cannot have the standard "C:\myreport\def.xml".
    Is there a way to use a relative path? I've tried creating a environment variable but it gives me the following error.
    ERR 63001: Invalid stream in the Data Definition URL file:///%reports/data.xml null
    -John

    I guess you must be missing some "/" in the values youre passing. Remember that it's also case sensitive. Here's what I did in my report
    The data definition has this value :
    file:///&<P_XML_CFG_PATH>ReconReports.xsd
    P_XML_CFG_PATH = //reports/dtd/
    For the Datasource
    file:///&<P_XML_PATH>&<P_XML_DATAFILE>
    And the value would be something like
    P_XML_PATH = /reports/data/xml/
    P_XML_DATAFILE = <actual filename>

  • How to give manual font path location when document opening?

    Hi,
    I want to know how to give manual path location for fonts when document opening like LinoType FontExplorerX, Font Book, UTS. Please Help me its very urgent
    Thanks

    Hi, I am doing the code likthis,please give the solution.
    SQL> create or replace procedure insProc(xmlDoc IN CLOB, tableName IN VARCHAR2) is
    2 insCtx DBMS_XMLSave.ctxType;
    3 l_ctx dbms_xmlsave.ctxtype;
    4 rows number;
    5 begin
    6 insCtx := DBMS_XMLSave.newContext(tableName); -- get the context handle
    7 rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); -- this inserts the document
    8 DBMS_XMLSave.closeContext(insCtx); -- this closes the handle
    9 end;
    10 /
    Procedure created.
    SQL> begin
    2 insProc('/usr/tmp/ROWSET.xml', 'emp');
    3 end;
    4 /
    begin
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException:
    Start of root element expected.
    ORA-06512: at "SYS.DBMS_XMLSAVE", line 65
    ORA-06512: at "SCOTT.INSPROC", line 7
    ORA-06512: at line 2
    Kishore B

  • How to run java servlet without using Web.xml?

    How to run servlet without using Web.xml? From a book, I know that web.xml descriptor is optional, but the book doesn't tell us how to run java servelet without web.xm descriptor. So how to do that? Thanks a lot.

    How to run servlet without using Web.xml?But Tomcat now uses a web.xml for its global server-wide configuration.
    If you'd like to invoke a servlet with:
    http://host/servlet/ServletName
    you have to enable the invoker servlet.
    [from an HTML]
      <FORM METHOD="POST" ACTION="/servlet/HGrepSearchSJ">
    [from resin.conf of Resin Web Server 2.1.12]
      <!--
         - The "invoker" servlet invokes servlet classes from the URL.
         - /examples/basic/servlet/HelloServlet will start the HelloServlet
         - class.  In general, the invoker should only be used
         - for development, not on a deployment server, because it might
         - leave open security holes.
        -->
      <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    [from TOMCAT5.0.19/conf/web.xml, a global server-wide web.xml file]
      <!-- The "invoker" servlet, which executes anonymous servlet classes      -->
      <!-- that have not been defined in a web.xml file.  Traditionally, this   -->
      <!-- servlet is mapped to URL pattern "/servlet/*", but you can map it    -->
      <!-- to other patterns as well.  The extra path info portion of such a    -->
      <!-- request must be the fully qualified class name of a Java class that  -->
      <!-- implements Servlet (or extends HttpServlet), or the servlet name     -->
      <!-- of an existing servlet definition.     This servlet supports the     -->
      <!-- following initialization parameters (default values are in square    -->
      <!-- brackets):                                                           -->
      <!--                                                                      -->
      <!--   debug               Debugging detail level for messages logged     -->
      <!--                       by this servlet.  [0]                          -->
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    ---comment out below----------------------------------------------------------
        <!-- The mapping for the invoker servlet -->
    <!--
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>
    -->

  • Rewrite URL in SMP and Relative Path

    Hi,
    some one have an example how to use Relative Path properties?
    I have read this guide (Defining Back-End Connections - REST API Application Development - SAP Library) but is not very clear for me.
    Thanks and kind Regards,
    Elia.

    When you precompile, can you say "Keepgenerated=TRUE". It might help you track
              down the difference with the URL. You should only get a 404 error when the
              resource is not found at runtime, which is independant of when you compile. The
              difference should be in how the URL is compiled.
              Chris
              ali wrote:
              > I am using WLS 6.0 SP1, when I use relative path in <jsp:forward> in my JSPs
              > it forwards ok if I am using directly JSPs but if I am using pre-compiled
              > JSPs (and have proper servlet-mappings
              > in my web.xml), I get 404 error with the relative-path, if I change it to
              > absolute path with pre-compiled JSPs it forwards ok , then.
              > any ideas why this is so?
              > thanks,
              

Maybe you are looking for