How to read configuration data from an xml file (not web.xml)?

Hi,
I want to separate the application specific configuration parameters in a separate xml file and read them as and when they are needed? I know that I can use the wb.xml but I want to separate them in a different xml file because I don't want the web.xml file to be played around later after deployment. If any change is needed then it should be done in the application-config.xml.
How can I read the parameters from this xml file in my jsp code and also what should be the location of this file if I have
../webapps/Root/application
directoty structure ?
Any help is greatly appreciated.

can you give an example of a property file and also
it is loaded in the jsp ?Hmm... loading properties in a JSP is not a very good idea. You should do it in a separate class, rather than mixing the logic with the display logic.
Properties properties = new Properties();
properties.load(UtilClass.class.getResourceAsStream("config.properties"));
// Add a try - catch block around the load
// for IOException...

Similar Messages

  • How to read the data from an excel file into MYSQL by java language

    Hi all,
    I have some data in excel spread sheet and I want to put the data into MYSQL data base. I created the tables in MYSQL> How can I write a program in JAVA that puts the value from excel sheet to mysql??
    I would appreciate your help
    regards

    By typing code at the keyboard... but presumably you meant to ask what code you should type.
    To get data out of Excel there are a few alternatives. The Google keywords I would use to find them are "java excel". I use Apache POI but there are other possibilities, I believe. As for getting the data into MySQL once you have extracted it from Excel, you would use JDBC. But you already knew that, didn't you? You did find the JDBC forum.
    In general it's better to ask a specific question on a forum. If you don't have a clue (which is the way we all start out) then just telling people that isn't going to be helpful. The best you're going to get is links to tutorials, which you could perfectly well have found for yourself by simple web searches.

  • Import data from excel/csv file in web dynpro

    Hi All,
    I need to populate a WD table by first importing a excel/CSV file thru web dynpro screen and then reading thru the file.Am using FileUpload element from NW04s.
    How can I read/import data from excel / csv file in web dynpro table context?
    Any help is appreciated.
    Thanks a lot
    Aakash

    Hi,
    Here are the basic steps needed to read data from excel spreadsheet using the Java Excel API(jExcel API).
    jExcel API can read a spreadsheet from a file stored on the local file system or from some input stream, ideally the following should be the steps while reading:
    Create a workbook from a file on the local file system, as illustrated in the following code fragment:
              import java.io.File;
              import java.util.Date;
              import jxl.*;
             Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
    On getting access to the worksheet, once can use the following code piece to access  individual sheets. These are zero indexed - the first sheet being 0, the  second sheet being 1, and so on. (You can also use the API to retrieve a sheet by name).
              Sheet sheet = workbook.getSheet(0);
    After getting the sheet, you can retrieve the cell's contents as a string by using the convenience method getContents(). In the example code below, A1 is a text cell, B2 is numerical value and C2 is a date. The contents of these cells may be accessed as follows
    Cell a1 = sheet.getCell(0,0);
    Cell b2 = sheet.getCell(1,1);
    Cell c2 = sheet.getCell(2,1);
    String a1 = a1.getContents();
    String b2 = b2.getContents();
    String c2 = c2.getContents();
    // perform operations on strings
    However in case we need to access the cell's contents as the exact data type ie. as a numerical value or as a date, then the retrieved Cell must be cast to the correct type and the appropriate methods called. The code piece given below illustrates how JExcelApi may be used to retrieve a genuine java double and java.util.Date object from an Excel spreadsheet. For completeness the label is also cast to it's correct type. The code snippet also illustrates how to verify that cell is of the expected type - this can be useful when performing validations on the spreadsheet for presence of correct datatypes in the spreadsheet.
      String a1 = null;
      Double b2 = 0;
      Date c2 = null;
                        Cell a1 = sheet.getCell(0,0);
                        Cell b2 = sheet.getCell(1,1);
                        Cell c2 = sheet.getCell(2,1);
                        if (a1.getType() == CellType.LABEL)
                           LabelCell lc = (LabelCell) a1;
                           stringa1 = lc.getString();
                         if (b2.getType() == CellType.NUMBER)
                           NumberCell nc = (NumberCell) b2;
                           numberb2 = nc.getValue();
                          if (c2.getType() == CellType.DATE)
                            DateCell dc = (DateCell) c2;
                            datec2 = dc.getDate();
                           // operate on dates and doubles
    It is recommended to, use the close()  method (as in the code piece below)   when you are done with processing all the cells.This frees up any allocated memory used when reading spreadsheets and is particularly important when reading large spreadsheets.              
              // Finished - close the workbook and free up memory
              workbook.close();
    The API class files are availble in the 'jxl.jar', which is available for download.
    Regards
    Raghu

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

  • Populate a table reading the data from a TXT file

    how can I populate a table reading the data from a TXT file?
    thanks

    Hey Kevin!
    Using FORMS.TEXT_IO to bulk load data from a file strikes me as re-inventing the wheel. It is just about justifiable in a self-service environment, but I regard the EXTERNAL TABLE is a better solution for that situation as well.
    The same applies to UTL_FILE. I think the ability to read text with UTL_FILE is primarily intended for read file-based configuration or file manipulation/processing rather than data loading.
    Re-writing a text file into SQL statements is too much like hard work (even with an editor that supports macro definition and regular expressions) for no real benefit. You lose all the bulk load peformance you would get from SQL*Loader. But for QAD I'd probably let you off with it.
    You missed out one obvious alternative: using Java to turn the contents of an XML file into a CLOB and inserting it into a table which is read by a PL/SQL procedure that parses the XML records and insert the retrieved data into a table.
    Stay lucky, APC

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • What is the 'quickest' way to read char data from a txt file

    Hello,
    What is the 'quickest' way to read character data from a txt file stored on the phone to be displayed into the screen?
    Regards

    To be even a bit more constructive...
    Since J2me does not have a BufferedInputStream, it will help to implement it yourself. It's much faster since you read large blocks at ones in stread of seperate chars.
    something line this lets you read lines very fast:
      while ( bytesread < filesize ) {
             length = configfile.read( buff, 0, buff.length );
             // append buffer to temp String
             if ( length < buff.length ) {
                byte[]  buf  = new byte[length];
                System.arraycopy( buff, 0, buf, 0, length );
                tmp.append( new String( buf ) );
             } else {
                tmp.append( new String( buff ) );
             // look in tmp string for \r\n
             idx1 = tmp.toString().indexOf( "\r\n" );
             while ( idx1 >= 0 ) {
                //if found, split into line and rest of tmp
                line = tmp.toString().substring( 0, idx1 );
             /// ... do with it whatever you want ... ////
                tmp = new StringBuffer( tmp.toString().substring( idx1 + 2 ) );
                idx1 = tmp.toString().indexOf( "\r\n" );
             bytesread += length;
          }

  • Include another xml file in web.xml

    I was able to use XML Entity to include another xml file in web.xml for older servlet specifications, i.e.:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" [
      <!ENTITY my-web SYSTEM "my-web.xml">
    ]>
    <web-app>
      &my-web;
    </web-app>This allows me to share my-web.xml among various web applications.
    How do I achieve the same thing for servlet specification 2.5, which does not have a DTD but rather an XSD?
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5">I am using Glassfish V2UR1. I know about $domain-dir/config/default-web.xml, but for reasons I won't get into I cannot put things in there.

    Hi Maksim. I understood that. It's just that I would prefer some method that doesn't require the developers to do something like extracting a file from the EAR file, changing the file and then putting it back in. As you probably know, some developers could handle it and some will most certainly make mistakes.
    When they do they come to my group and say "my app doesn't work" and then we have to spend time figuring out why.
    Plus, once the developers get used to doing things the automated way they're going to have a hard time remembering to do a manual step each time they do a build.
    I have heard that there may be some way to do something similar to this on Visual Administrator. I'm going to investigate that too.
    Thanks!
    David.

  • How to read the data from excel file and store into the table?

    Hi All,
    I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
    All the excel fields and my table columns are same.
    Can you share with me how can acheive this using LOB's?
    Thanks

    Hi OraSuirya,
    you can try with external tables .
    syntax as follows
    create table ext_table_csv (
    i Number,
    n Varchar2(20),
    m Varchar2(20)
    organization external (
    type oracle_loader
    default directory ext_dir
    access parameters (
    records delimited by newline
    fields terminated by ','
    missing field values are null
    location ('file.csv')
    reject limit unlimited;
    For this you need to create directory
    Directory Creation syntax:
    create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
    grant read, write on directory ext_dir to <User>;
    please paste the excel file in the particular directory .
    I hope this will help you.
    Please correct me if I am wrong anywhere .
    Thanks,
    Tippu.

  • How to read the data from a file in another computer with user name and password login

    How to read read the data from a file in anohter computer which need to login with user name and password?

    duplicate post:  http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2061478
    duplicate post:  http://forums.ni.com/t5/LabVIEW/do-need-to-enter-the-user-name-and-password-when-TCP-ip/m-p/2061612
    duplicate post   http://forums.ni.com/t5/LabVIEW/log-on-the-other-computer-with-user-name-and-password/m-p/2060682

  • How to read in data from MySQL to Authorware?

    Hi,
    I am trying to read in values from my database (MySQL) to
    authorware, but the best I am able to get is true or false.
    I would like to be able to get some data from the database
    and return it to AW as a string. Does anyone have any experience
    with this? Can anyone lend a helping hand in this endeavor?
    Thanks in advance for your help,
    Brad

    "Paul Swanson" <[email protected]>
    wrote in message
    news:[email protected]...
    > Kevin, you shouldn't need to worry about ODBC or OLEDB.
    Your PHP script
    > needs to handle the database connection, and you can use
    PHP's
    > mysql_connect() function for that. You really don't need
    to do anything
    > different for Authorware than you do for any PHP/MySQL
    application in
    > terms
    > of connecting to the database.
    >
    > My PHP script returns data to AW in the form of
    name=value pairs delimited
    > by the ampersand character. I then use the following
    code in AW to convert
    > them into lists:
    >
    > =========================
    > -- Use this routine to break queryString into name /
    value arrays.
    > -- Assumes a database query returns a string of
    name=value pairs
    > -- delimited by the ampersand (&) character.
    >
    > -- strip leading & from queryString
    > queryString := SubStr(queryString, 1,
    CharCount(queryString))
    >
    > -- break into list of individual lines
    > tempList := Replace("&", Return, queryString)
    >
    > listLength := LineCount(tempList)
    >
    > -- create empty arrays for name and value
    > name := Array("", listLength)
    > value := Array("", listLength)
    >
    > repeat with counter := 1 to listLength
    > singleLine := GetLine(tempList, counter)
    > name[counter] := GetWord(1, Replace("=", " ",
    singleLine))
    > value[counter]:= GetWord(2, Replace("=", " ",
    singleLine))
    > end repeat
    >
    > -- now you will need to add a separate calc icon with a
    routine to
    > -- read the data from the arrays. name[counter] matches
    value[counter]
    > =========================
    >
    > I follow this with another Calc icon (I could have done
    it all in one
    > calc)
    > that parses the names and assigns the values to my
    custom AW variables:
    >
    > =========================
    > -- get just the info we want, and store in variables
    >
    > repeat with counter := 1 to listLength
    > if name[counter] = "Lesson1Complete" then
    > Lesson1Complete := Number(value[counter])
    > else if name[counter] = "Lesson2Complete" then
    > Lesson2Complete := Number(value[counter])
    > else if name[counter] = "Lesson3Complete" then
    > Lesson3Complete := Number(value[counter])
    > else if name[counter] = "Lesson4Complete" then
    > Lesson4Complete := Number(value[counter])
    > else if name[counter] = "Lesson5Complete" then
    > Lesson5Complete := Number(value[counter])
    > else if name[counter] = "Lesson6Complete" then
    > Lesson6Complete := Number(value[counter])
    > else if name[counter] = "Lesson7Complete" then
    > Lesson7Complete := Number(value[counter])
    > else if name[counter] = "Lesson8Complete" then
    > Lesson8Complete := Number(value[counter])
    > else if name[counter] = "OverviewComplete" then
    > OverviewComplete := Number(value[counter])
    > else if name[counter] = "grade" then
    > score := Number(value[counter])
    > else if name[counter] = "passed" then
    > passed := Number(value[counter])
    > end if
    > end repeat
    I'd like to point out here that any time you have a series of
    variables that
    all have identical names except for a number in the variable
    name, you
    should be looking at lists. I'm surprised, Paul, that you
    have lists used
    to the extent that you're able to use Value[counter] on the
    right side of
    the equation, yet you're not using lists on the left side of
    the equation.
    Let's look at how this code could be made super simple by
    having ONE list
    variable, LessonComplete, instead of Lesson1Complete through
    Lesson8Complete.
    -- Assumes a database query returns a string of name=value
    pairs
    -- delimited by the ampersand (&) character.
    -- strip leading & from queryString
    --(note you could also not add this ampersand on the PHP
    side)
    queryString := SubStr(queryString, 1, CharCount(queryString))
    -- break into list of individual lines
    tempList := Replace("&", Return, queryString)
    listLength := LineCount(tempList)
    -- create empty arrays for name and value
    name := Array("", listLength)
    LessonComplete := []
    repeat with counter := 1 to listLength
    singleLine := GetLine(tempList, counter)
    name[counter] := GetWord(1, Replace("=", " ", singleLine))
    LessonComplete[name[counter] * 1] := GetWord(2, Replace("=",
    singleLine))
    end repeat
    -- now you will need to add a separate calc icon with a
    routine to
    -- read the data from the arrays. name[counter] matches
    value[counter]
    --No you don't...You're DONE :-)
    Also note that this is extensible...you can have Lesson 9,
    10, etc. and not
    have to change the code. You can also lower the amount of
    data being
    transmitted, because now instead of Lesson8Complete=1 all you
    need is 8=1.
    This lowers the server load and speeds the response. It has
    advantages on
    the Authorware side as well, because if, for instance, you
    had a series of
    buttons that were checked or not based on the completion, you
    could do the
    same type of loop. Separate variable names do not allow for
    that type of
    loop unless you use Eval (ugh).
    HTH;
    Amy

  • How to load Test data from a Text file in ECATT

    Hi,
    I have created a test configuration with a test script, system data container, and test data container.
    I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters from script in to the data container.
    I am trying to load a the data from a text file on the local work-station. The data is not being read.
    Please explain this in detail (step by step) as I am very new to ECATT.
    I am trying this on SAP ECC 6.0 IDES server.
    Thanks in Advance
    Vikas Patil

    Please explain this in detail (step by step) as I am very new to ECATT.
    Thanks in Advance
    Vikas Patil

  • How can I plott data from a text file in the same way as a media player using the pointer slide to go back and fort in my file?

    I would like to plott data from a text file in the same way as a media player does from a video file. I’m not sure how to create the pointer slide function. The vi could look something like the attached jpg.
    Please, can some one help me?
    Martin
    Attachments:
    Plotting from a text file like a media player example.jpg ‏61 KB

    HI Martin,
    i am not realy sure what you want!?!?
    i think you want to display only a part of the values you read from XYZ
    so what you can do:
    write all the values in an array.
    the size of the array is the max. value of the slide bar
    now you can select a part of the array (e.g. values from 100 to 200) and display this with a graph
    the other option is to use the history function of the graphes
    regards
    timo

  • How to retrive the data from a sqlite file(.db3) in windows phone 8.1(runtime)

    hey guys
    i installed the sqlite and sqlite-net as requested in other answers i found, changed to x86, and add the .db3 file in my project.
    but the problem is how to retrive the data that already in the file( i am not creating any table or data in the app, just read)
    all the answer i found is to create a table first and then read the table, i tried to skip the step of creating a table, and read from the table directly, but failed with " no such table", by the way, i set the property of the .db3 file as "content",
    "copy if newer"
    can anyone please help? i appreciate that !

    Hello,
    From your description, you want to read data from available sqlite file. When you add the sqlite file into your project, you need to change the sqlite file build action to content. After deploying to device, the sqlite file is located in installation folder,
    you need to copy that file into storage folder before reading data. Please try the following code snippets.
    private async void Button_Click_9(object sender, RoutedEventArgs e)
    //check if file exists in storage folder, and then copy to local storage
    bool flag = await FileExistsAsync("Data.db3");
    if (!flag)
    var folder = await Package.Current.InstalledLocation.GetFileAsync("Data.db3");
    await folder.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
    // open sqlite and read data
    public async Task<bool> FileExistsAsync(string fileName)
    try
    await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
    return true;
    catch (FileNotFoundException)
    return false;
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

Maybe you are looking for

  • Words in PDF's not showing up after being saved

    When I try to save some documents off of a website, the PDF comes up but the words and numbers are missing. Example: When I go to Comcast and I try to save the bill from the website to my computer, then try to open it, the PDF opens and there's no er

  • Keyboard keys different between models?

    I replaced the top case on a black Macbook 2.16 Core 2 Duo model, as the keyboard and trackpad were not being recognized and were not working. I had a white top case from a broken Macbook 2.0 Core 2 Duo which works okay. Finally a working keyboard an

  • Need to know more about Headstart

    I am interested in Headstart but I have little information about this product. I need to know more information, a contact channel and how we can get the product.

  • How to create worklist in CATS

    Hi All, Work items needs to be used in CATS. Can enybody  tell how  to create workitems . I am using CATS classic Thanks

  • ACE - Port-channel High Availability

    We have configured two ACEs with high Availability. ACEs link with our cores, switches cat6500, through a port-channel, ACE's ports G1/1 and G1/2. High availability works fine if some vlan down but it doesn't work if an interface down, only if both i