Loading properies file from JSP

Hi All,
I am storing both the jsp file and properties file in the same folder. I am using tomcat web container. When I load the JSP into a browser, I am getting file not found exception. Can you please tell me how to resolve this problem. Very urgent.
Following is the code line I used.
FileInputStream in= new FileInputStream("currentDate.properties");
Thanks,
---Nagesh

you can follow this also.
if ur jsp name is myjsp.jsp then the java file will be myjsp_jsp rite.
ur property file will be under the classes folder.
public Properties getProperty(String filename)
          InputStream is = null;
          Properties props = new Properties();       
          ClassLoader classLoader = myjsp_jsp.class.getClassLoader();      
          is = classLoader.getResourceAsStream(filename);
          if(is == null)
              String message = "Cannot locate property file " + filename + " in the classpath";
              System.out.println(message);               
          try
              props.load(is);
          catch (IOException e)
              String message = "Error reading property file " + filename;             
              System.out.println(message);     
          finally
              try
               is.close();
              catch(Throwable t)
               t.printStackTrace();
          if(props.isEmpty())
              String message = "No properties are defined in " + filename;         
              System.out.println(message);     
     return props;  
     }

Similar Messages

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • Load Flat File from App Server

    HI, all.
    I want load flat file from appliation server. I created CSV file and loaded it on app. server with FM ARCHIVEFILE_CLIENT_TO_SERVER. After I created datasource and tried load data in the infocube. In this procedure I encountered with two problem
    1. When I look file in AL11, I doesn't see cyrillic symbols, instead this symbols I see #.
    2. When I try load data with data source, I get exception RS_EXCEPTION 000 "File don't open"
    Anybody can help me resolve this problem?
    wbr, Fanil.

    Hi, kodanda pani KV.
    2. File is was closed.
    1. Can me you clearly explain what you meen?
    wbr, Fanil

  • Infopackage-Load Many Files from Application Server and later Archive/Move

    Hi All..
      I have a doubt,   I have a requirement of take many files to load into BI 7.0..  I used the infopackage before with option:
    Load Binary File From Application server
      I load information successfully... only with one file ...but If I can load many files (with different names) like the next list.. I think it's not a good idea modify the file name (path) on infopackage each time).. :
    *All of this files will be on one server that itu2019s map into AL11.. Like
    Infopfw
    BW_LOAD_20090120.txt
    BW_LOAD_20090125.txt
    BW_LOAD_OTHER_1.txt
    u2026.
    Etc..
    This directory it's not in BW server.. It's other server..but I can load form this location (one file by one)
    Could you help me with this questions:
    -     How can I Use an infopackage with routine that take all the files..one by oneu2026 in order of creation dateu2026and load into Target? Is it possible?.. I have some knowledge of ABAP.. but I don´t know exactly how I can say to system this logicu2026
    -     In addition is it possible move this files to other locationu2026 like into Infopfwarchive u2026 just to have an history of files loaded.
    I saw that in infopackage you have an option to create a routine.. in ABAP codeu2026 Iu2019m a little bit confused because I donu2019t  know how I can specify all the path..
    I try with:
    Infopfw
    InfopfwFile.csv
    Infopfw
    This is the abap code that automatically you see and you need to modifyu2026
    Create a routine for file name
    This routine will be called by the adapter,
    when the infopackage is executed.
              p_filename =
              p_subrc = 0.
    Thank you for your ideas or recommendations.
    Al

    Hi Reddy, thank you for your answer
    I have some doubuts.. when you explain me the option:
    All the above files are appending dates at the end of the file....
    You can load the files through infopackage by using Routines and pick the files based on date at the end of the file..***
    I need to ask you if you think that when you know the date of the file and the infopackage pick each file... thi can work for many files??... or how it's possible control this process?
    About this option, I want to ask you If when you menction Unix code... where it's programed this code?.. in the routine of BW Infopackage??
    ****Or
    Create two folders in your BW in Application server level, in AL11 (ask Basis team)
    I call it is F1 and F2 folders.
    First dump the files into F1 I assume that the file name in F1 is "BW_LOAD_20090120.txt", using Unix code you rename the file and then keep in the same foleder F1 or move to F2.
    Then create InfoPackage and fix the file name (i.e. you renamed), so you don't need to change everyday your file name at infopackage level.Because in AL11 everyday the file are overwrite.
    To I get BW_LOAD_20090120.txt file in F1, then I renamed to BW_LOAD.txt and loaded into BW, then tomorrow I get BW_LOAD_20090125.txt in F1, then I renamed to BW_LOAD.txt....
    so in this way it will work.You need to schedule the Ubix script in AL11.
    This is the way how to handle the application server...I'm using the same logic.
    Thank you soo much.
    Al

  • Load XML file from addon domain without cross-domain Policy file

    Hello.
    Assuming that there are two addon domains on the same server: /public_html/domain1.com       and      /public_html/domain2.com
    I try to load XML file from domain2.com into domain1.com without using cross-domain policy file (since it doesn’t work on xml files in my case).
    So the idea is to use php file in order to load XML and read it back to flash.
    I’ve found an interesting scripts that seems to do the job but unfortunately I can't get it to work. In my opinion there is somewhere problem with AS3 part. Please take a look.
    Here are the AS3/PHP scripts:
    AS3 (.swf in www.domain1.com):
    // location of the xml that you would like to load, full http address
    var xmlLoc:String = "http://www.domain2.com/MyFile.xml";
    // location of the php xml grabber file, in relation to the .swf
    var phpLoc:String = "loadXML.php";
    var xml:XML;
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest(phpLoc+"?location="+escape(xmlLoc) );
    loader.addEventListener(Event.COMPLETE, onXMLLoaded);
    loader.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHandler);
    loader.load(request);
    function onIOErrorHandler(e:IOErrorEvent):void {
        trace("There was an error with the xml file "+e);
    function onXMLLoaded(e:Event):void {
        trace("the rss feed has been loaded");
        xml = new XML(loader.data);
        // set to string, since it is passed back from php as an object
        xml = XML(xml.toString());
        xml_txt.text = xml;
    PHP (loadXML.php in www.domain1.com):
    <?php
    header("Content-type: text/xml");
    $location = "";
    if(isset($_GET["location"])) {
        $location = $_GET["location"];
        $location = urldecode($location);
    $xml_string = getData($location);
    // pass the url encoded vars back to Flash
    echo $xml_string;
    //cURLs a URL and returns it
    function getData($query) {
        // create curl resource
        $ch = curl_init();
        // cURL url
        curl_setopt($ch, CURLOPT_URL, $query);
        //Set some necessary params for using CURL
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       //Execute the curl function, and decode the returned JSON data
        $result = curl_exec($ch);
        return $result;
        // close curl resource to free up system resources
        curl_close($ch);
    ?>

    I think you might be right about permissions/settings on the server for php. Unfortunately I'm not allowed to adjust them.
    So I wrote my own script - this time I used file path instead of http address of the XML file.  It works fine in my case.
    Here it is:
    XML file on domain2.com:
    <?xml version="1.0" encoding="UTF-8"?>
    <gallery>
        <image imagePath="galleries/gallery_1/images/1.jpg" thumbPath="galleries/gallery_1/thumbs/1.jpg" file_name= "1"> </image>
        <image imagePath="galleries/gallery_1/images/2.jpg" thumbPath="galleries/gallery_1/thumbs/2.jpg" file_name= "2"> </image>
        <image imagePath="galleries/gallery_1/images/3.jpg" thumbPath="galleries/gallery_1/thumbs/3.jpg" file_name= "3"> </image>
    </gallery>
    swf  on domain1.com:
    var imagesXML:XML;
    var variables:URLVariables = new URLVariables();
    var varURL:URLRequest = new URLRequest("MyPHPfile.php");
    varURL.method = URLRequestMethod.POST;
    varURL.data = variables;
    var MyLoader:URLLoader = new URLLoader;
    MyLoader.dataFormat =URLLoaderDataFormat.VARIABLES;
    MyLoader.addEventListener(Event.COMPLETE, XMLDone);
    MyLoader.load(varURL);
    function XMLDone(event:Event):void {
        var imported_XML:Object = event.target.data.imported_XML;
        imagesXML = new XML(imported_XML);
       MyTextfield_1.text = imagesXML;
       MyTextfield_2.text = imagesXML.image[0].attribute("thumbPath");  // sample reference to attribute "thumbPath" of the first element
    php file on domain1.com:
    <?php
    $xml_file = simplexml_load_file('../../domain2.com/galleries/gallery_1/MyXMLfile.xml');  // directory to XML file on the same server
    $imported_XML = $xml_file->asXML();
    print "imported_XML=" . $imported_XML;
    ?>
    Regards
    PS: for those who read the above discussion: the first and the second script work but you must test which one is better in your situation. The first script will also work between two domains on different servers. No cross domain policy file needed.

  • Can I load xml file from SWC without using @embed

    I'm developing a mobile application in which I need to load xml files from File.applicationDirectory. This works great if the xml files are part of the main application swf. But I would like to move these xml files into a SWC so they could be shared across multiple applications.
    Using FlashBuilder 4.5, when a SWC is built, I can specify files to embed in the library that are not assets (Assets Tab of Flex Library Build Path). For various design reasons, I do NOT want to embed the xml files via @embed.
    When the swc is built and I open it up using a zip utility, I see the xml files in there just fine. So they are being bundled with the SWC. But how can I load these files in my main application that does not involve using @embed? When the main application is built, the swc setting for link type is "merged into code".
    I wouldn't expect the application to automatically pull out the xml files from the swc and place them in the File.applicationDirectory on the mobile device. I've tried loading from there just in case but file.exists is false (as expected).
    I've searched the web (and continue to do so) and all the answers seem to be to use @embed. Is there another way?
    Randy

    It's actually a lot easier than you think.
    Just reference the file like any'ol URL using a path relative to the SWC's src directory.
    So if you include the file "assets/xml/some.xml", just use that same string like you would any remote resource.
    For example:
    var loader:URLLoader = new URLLoader( new URLRequest("assets/xml/some.xml"));
    I believe it would also work like this "/assets/xml/some.xml", but I prefer relative paths so the link doesnt break if moved out of the SWC...

  • How to load jar files from remote location

    Hi all,
    I am trying to load jar files from remote server, from a servlet which is running on OC4j.
    For doing this,First I am getting ClassLoader by using ClassLoader.getSystemClassLoader() and then type casting it to URLClassLoader.
    But by doing it I am getting ClassCastException,because oc4j returns oracle.classloader.PolicyClassLoader instead of java.net.ClassLoader.
    Appreciate if anyone can tell me how to load remote jar files using oracle.classloader.PolicyClassLoader .
    Thanks
    Harish

    Hi,
    I suppose you know about this, but just in case.
    I have used jnpl to load jar files from remote location.
    Rowan

  • How to call java class file from jsp

    hi
    we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
    bye
    siva sankari

    you can call the methods in a lot of ways. you could use scriptlets with the
    <%@ page import="package.class"%> and then inside instantiate an object
    <%
         MyClass mc = new MyClass(parameters if any);
         mc.theMethodYouWantToCall();
    %>or as Madathil has stated,
    or use the JSP tags
    <jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
    or even Custom Tags

  • Problems loading RAW files from Canon 6D in Elements 10

    Elements 10 - Windows: I have been using the software for a couple of years and never had a problem loading RAW files from my Canon T2i ir 60D, however I just purchased a Canon 6D and when I try to load a RAW from the 6D I get Cannot open 'C:\User...CR2' because it is the wrong type of file.  I thought cameraraw 6.5 patch would be the fix but when trying to install I get "Error loading Updater workflow"

    Will the DNG files perform the same, meaning will I retain all the information that makes RAW important for processing?
    Yes. That's why DNGs were invented. Adobe has put a lot of work into the DNG format for this very reason.
    Raw files are proprietary and manufacturer specific. Raw formats change with every make and model of camera. Software must be updated for the new Raw format of every single camera. Adobe does an admirable job of upgrading Camera Raw for every new camera.
    DNG is also a Raw format but it's open source and works in any software which can read the DNG format. If camera manufacturers used the DNG format instead of their own Raw format, you would not have to upgrade Elements 10. But they don't, and probably never will, so you must upgrade the Camera Raw plugin (and therefore Elements 10 since it's not compatible with the new Camera Raw) to read the new Raw format from the 6D or add another step to your workflow with conversion to DNG first.
    See
    http://photographylife.com/dng-vs-raw
    http://www.adobe.com/products/photoshop/extend.displayTab2.html

  • Way to generate sql*loader ctl file from a table?

    I'm an oracle newbie. (Oracle 8i, HP Unix)Is there any way to take an existing table
    description and generate a sql*loader control file from it? If anyone has already written a procedure or knows where one can be found I'd really appreciate it. We're doing a mass conversion to oracle and would like an easy way to re-write all our loads.
    Thanks! Eileen from Polaroid.

    Hi,
    I have shell program, which will get column names from system table and create temp. control file and call sqlloader exe. and load the data automatically.
    You can customise this file, according to your needs.
    Shell Program
    if [ $# -ne 2 ]
    then
    echo " Usage : $0 table_name flat file name"
    exit
    fi
    #assigning envir. variable to unix variables
    table_name=$1
    flat_file=$2
    #creating the control file
    echo "LOAD DATA" > $table_name.ctl
    echo "INFILE '$flat_file'" >> $table_name.ctl
    echo "into table $table_name " >> $table_name.ctl
    echo "fields terminated by '\t'" >> $table_name.ctl
    #calling functions for making column name part
    #describing the table and spooling into file
    sqlplus -s $CUST_ORA_USER << sql_block
    spool $table_name.lst
    desc $table_name
    spool off
    sql_block
    # creating suitable file and add the feilds into control file
    # cutting the first line (headings)
    tail +3 $table_name.lst > temp
    rm -f $table_name.lst
    k=`wc -l < temp`
    k1=`expr $k - 1`
    #cutting the last line
    head -$k1 temp > tempx
    record_count=`wc -l < tempx`
    counter=1
    echo "(" > wxyz.ctl
    # reading file line by line
    cat tempx | while in_line=`line`
    do
    #cutting the first field
    field_name=`echo $in_line | cut -f1 -d' '`
    #calculating the no of characters
    word_cnt=`echo $in_line | wc -w`
    #calculating count in a line
    if [ $word_cnt = 2 ]
    then
    data_type=`echo $in_line | cut -f2 -d' ' | cut -f1 -d'('`
    if [ "$data_type" = "DATE" ]
    then
    data_fmt="DECODE(LENGTH(LTRIM(RTRIM(:$field_name))),'11',to_date(ltrim(rtrim(:$field_name)),'dd-mon-yyyy'),'9',to_date(ltrim(rtrim(:$field_name)),'dd-mm-yy'),'10',to_date(ltrim(rtr im(:$field_name)),'dd-mon-yy'),'yyyy/mm/dd hh24:mi:ss')"
    elif [ "$data_type" = "CHAR" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    elif [ "$data_type" = "VARCHAR2" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    else
    data_fmt="NVL(:$field_name,0) "
    fi
    else
    data_type=`echo $in_line | cut -f4 -d' ' | cut -f1 -d'('`
    if [ "$data_type" = "DATE" ]
    then
    data_fmt="DECODE(LENGHTH(LTRIM(RTRIM(:$field_name))),'11',to_date(ltrim(rtrim(:$field_name)),'dd-mon-yyyy'),'9',to_date(ltrim(rtrim(:$field_name)),'dd-mm-yy'),'10',to_date(ltrim(rt rim(:$field_name)),'dd-mon-yy'),'yyyy/mm/dd hh24:mi:ss')"
    elif [ "$data_type" = "CHAR" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    elif [ "$data_type" = "VARCHAR2" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    else
    data_fmt="NVL(:$field_name,0) "
    fi
    fi
    #if last line put );
    #else ,
    if test $record_count -eq $counter
    then
    echo $field_name \"$data_fmt\"");" >> wxyz.ctl
    else
    echo $field_name \"$data_fmt\""," >> wxyz.ctl
    fi
    #counter increamenting for each record
    counter=`expr $counter + 1`
    done
    #removing the file
    rm -f temp tempx
    cat wxyz.ctl >> $table_name.ctl
    rm -f x.ctl
    #calling the SQLLOADER
    SQLLDR $CUST_ORA_USER CONTROL=$table_name.ctl ERROR=99999999
    #removing the control file
    rm -f $table_name.ctl

  • Loading swf files from an iPhone Air App

    Although the faq says its possible ( http://bit.ly/gyxmCo  )  I can't seem to load .swf files from my app.
    There's no .AS code in the .swf file I'm trying to load.
    PNG files load with no problems, swf's fail.
    A working example would be appreciated instead of suggestions, I've spent the entire day trying out suggestions
    regards,
    Martijn

    Because I can't see any library assets in an as2.0 file.
    I've discovered that the swf fails to load as soon as you make a symbol 'export for actionscript'
    probably because it will then create a class. So you can only load SWF's as simple pictures or animations, you cant use it as an asset library with multiple animations/images/sounds in it..
    As for you other questions:
    it doesnt matter if the file is local or on the web. same results
    I created the swf file from a fla in CS4,  and I'm compiling my air project that loads the swf  with FlashDevelop.

  • Cannot Load JPG Files From Canon Powershot S2 IS

    Hi,
    I'm having a problem loading JPG files from my Canon Powershot S2 IS. When I plug the camera into the USB port, I get the Canon Camera/DV Twain Driver with a list of images to import. They are all JPEG images, which is my camera's native format. (I don't think RAW is available on this model.) But when I select an image by double-clicking it, it is imported into Photoshop Album (Starter Edition 3.0), but has somehow been converted to TIFF.
    The problem I have with this is that the TIFF format uses up about 7 time more disk space than the original JPG and I can't afford a new hard drive right now. I simply don't have enough disk space available to import all my images. (I plan to back them up on CD after importing.)
    I see that Edit -> Preferences -> Scanner has an option to save files as JPEG, but Edit -> Preferences -> Camera has no such option.
    Please help! How do I get the images to stay as JPEG?
    Thanks!
    Debbie Hunt

    Answered your other post
    Colin Walls, "Help! PSA SE 3.0 converts my images to TIFF!" #1, 9 Sep 2005 2:28 pm

  • How can I get Elements 12 to load raw files from my Nikon D5300. I have installed DNG Conv. 8.7.1

    I cannot get Elements 12 to recognise and load NEF files from my Nikon D5300. I have downloaded and installed the latest DNG coverter software 8.7.1 but Elements still refuses to load any NEF files.
    regards Ian.

    Hi,
    You shouldn't need to use the DNG converter unless you are using the MAC app version. The D5300 should be supported by Camera Raw 8.3 which should be compatible with Photoshop Elements 12.
    In the editor go to Help -> About Plug-in -> Camera Raw to see which version you have loaded. The latest for Photoshop Elements 12 is 8.5. If you have an older one then go to the Help menu and select Updates.
    If you are up to date, then you may have use old Nikon software to access the NEF files and that is known to corrupt them so that Photoshop Elements can't read them.
    Brian

  • Cannot Load NEF files from Nikon D600

    I am running CS4 but cannot load NEF files from my Nikon D600 _ Camera Raw 5.7 is also installed. Any ideas on how to reslve. I was able to load from my D200 Camera.

    Hi. Because the forum you originally posted in is for beginners trying to learn the basics of Photoshop, I moved your question to the Photoshop General Discussion forum.

  • Loading property files from a class and not a servlet...

    Hi, I was wondering if anyone has a good solution for loading property files from a class instead of a servlet. I would like to load the property file similarly to how it is done from HttpServlet.
    Here is the large picture. I have a tag library that calls a class which needs to access a database. The class needs to know what DB to access so it needs to look at some property file. The problem is that I don't want to hardcode the properties or the path of where the property file exists. I hope this all makes sense.
    Thanks.
    -PV

    I use the getResource method in the java.lang.Class class. Read about this method in the api.
    Anyways this is roughly how it's : you must put your properties file in the classpath. Then in your class :
    Properties prop = new Properties();
    URL url = this.getClass().getResource("/config/db.properties");
    prop.load(url.openStream());In this case, you must put the "config" (where you've written your db.properties file) directory's parent in the classpath.

Maybe you are looking for

  • Unable to open/edit project in project professional form PWA(project server 2010)

    i have been working perfectly and opening my projects with project professional from PWA All of a sudden,i get this error: no permission to read enterprise global file when trying to edit my projects in project professional from the PWA i have also t

  • What does rapid flashing light on my Apple TV mean, and how do I fix it?

    MMy Apple TV has always worked just fine.... No problems. Tonight, suddenly, the unit isn't working, and the front light on it is flashing quickly.... I can't get anything to work.... I tried to connect it to my computer to iTunes, but nothing comes

  • Converting word docs to PDF's

    I have created an imaged based document size A3 in Word on my Windows machine. However, when I try to save as a PDF in Acrobat XI pro it cuts off a third of the document. I have check printing settings and have confirmed its A3, but when I do a previ

  • Reader update has broken IE

    Several of our users have received the latest update to Reader and now no pdfs will open in the browser.  We are using IE 8 because we have a technical manual that will not run in 9 or 10.  We have checked the Add-On settings in IE and there is now N

  • BETTER BASS ON iPOD?? HELP!

    I just got a 30G video iPod and I was wondering what is the best thing to buy to increase the bass for my music-listening pleasures. What about those Apple ear phone that stick into your ear. I think they are $40. Are they worth the money and are the