Easiest way of adding some string initation parameters

hi I would like to add some way of letting the user specify 4 different strings in an easy to edit way to configure the application before startup I am currently using a tokenized file and finding the url like so
<servlet>
        <servlet-name>
            FindFile
        </servlet-name>
        <servlet-class>
            test.FindFile
        </servlet-class>
         <init-param>
           <param-name>file</param-name>
           <param-value>/WEB-INF/ini.properties</param-value>
         </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>Are they any another ways of solving this problem I have tried google and not come up with anything

That's the only way I know of to do it on startup. If you don't read them in the init() method, I don't see where else you'll get them.
Doesn't this work? What's wrong with your approach?
Don't worry about best or most perfect. If this works, run with it.
%

Similar Messages

  • Easiest way to create a string with a unicode supplimentary character

    In my code I had previously been declaring some strings such as:
    String s = "\u1234";Now I have gotten to a point where I want to use a supplimentary unicode character like this:
    String s = "\u12345";This, however, does not work since Java only allows for characters in the range: 0000 - FFFF.
    I've been reading over this whole codepoint thing in the Character docs but I'm still confused. What's the easiest way to make a string that contains the unicode character U+12345 (just an example number)?

    This article here:
    http://java.sun.com/developer/technicalArticles/Intl/Supplementary/
    says <quote>For text input, the Java 2 SDK provides a code point input method which accepts strings of the form "\Uxxxxxx", where the uppercase "U" indicates that the escape sequence contains six hexadecimal digits, thus allowing for supplementary characters.</quote>
    I believe it is referring to Java 5, although I don't see where it says that. However if you are dealing with supplementary characters it might be a good idea for you to move to Java 5 because of its improved support for them.
    PC&#178;

  • Is there any way to change some of the parameters in hundreds of xml file

    Hi,
    We have got hundreds of xmls to run some of the batch scripts.I need to change some of the parameters in those xmls like USER,PASSWORD,SERVERetc.All the So I am doing them manually now by opening each of the xml script ,edit -> Find and Replace.But can anyone suggest me an easy way to update hundreds of xmls.

    In the past, I've written VBA code in Excel to open all the files in a directory, then search for the strings and replace them. The files are then written out to a new directory so I was able to keep the original versions. It's pretty easy using a few loops

  • Most efficient way to do some string manipulation

    Greetings,
    I need to cleanse some data in a string by replacing unsafe characters with encoded equivalents. (FYI, this is for the purpose of transforming "unsafe" characters into encoded values as data inside an XML document).
    The following code accomplishes the task:
    Note that a string "currentValue" contains the data to be cleansed.
    A string, "encodedValue" contains the result.
      for (counter = 0; counter < currentValue.length(); counter++)
        addChar = (currentValue.substring(counter,counter+1));
        if (addChar.equals("<"))
          addChar = "#60;";
        if (addChar.equals(">"))
          addChar = "#62;";
        if (addChar.equals("="))
          addChar = "#61;";
        if (addChar.equals("\""))
          addChar = "#34;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("/"))
          addChar = "#47;";
        if (addChar.equals("\\"))
          addChar = "#92;";
        encodedValue += addChar;
      } // forI'm sure there is a way to make this more efficient. I'm not exactly "new" to java, but I am learning on my own with no formal training and often take a "brute force" approach with my initial effort.
    What would be the most efficient way to re-do the above?
    TIA,
    --Paul Galvin
    Integrated Systems & Services Group

    im a c++ programmer so im not totally up on these java classes either but...from a c++ stand point you might want to consider using the if else statment.
    by using if else, you only test the character until you find the actual "violating" character and skip the rest of the tests.
    also, you might trying using something to check for alphaNumeric cases first and use the continue keyword when you find one. since more of your characters are probably safe than unsafe you can skip all the ifs/if else statement and only do one test on the good characters. (i just looked for a way to test that and i didnt find one. c++ has a function that does that by checking the ascii number range. dont think that works in java. but maybe you can find one, it would reduce the number of tests probably.)
    happy hunting,
    txjump :)

  • Servlet init parameters common to more servlets

    Hi all,
    I have a set of servlets using each one some init parameters.
    Some of these parameters are common to a certain number of servlets.
    Does exist a place where to put this init-parameter, avoiding to repeat these values
    in all the definions of the servlets in the web xml file (I am using Tomcat 4.x) ?
    thanks in advance,
    Andrea

    instead of adding a init-param to the servlet tag you also might add a context-param tag to the web-app.
    please see the web-app DTD file to see the exact structure (i think it's named context-param and the child-elements are similar to those of init-param - but sorry - i'm not 100% sure).
    inside the servlet you could then do something like the following:
    // this = e.g. a HttpServlet
    String param = this.getServletConfig().getInitParameter("your_param");
    if(param == null) {
      param = this.getServletContext().getInitParameter("your_param");
      if(param == null) {
        throw new ServletException("Missing parameter");
    }result:
    servlet searches the servlet specific init parameters
    if the parameter could be found it will be used (servlet param "overwrites" global param)
    else the servlet searches the webapp specific init parameter
    if the parameter could be found it will be used
    else the servlet throws an exception

  • Web-inf\web.xml init parameters

    Hi,
    I use several servlets/JSPs which are using common init parameter, is there a way to specify that some init parameters are common or must I write all the parameters for all of my servlets/JPSs ?
    Thanks

    yah that's what I mean, have your parameters in your web.xml file and have a Servlet read them when the application starts up (using ServletConfig). Then you put the values into the application scope where all the JSPs and Servlets can read them. So lets say you specify a parameter called "html-path" with a value of "/www/html/" you could read this in your JSPs like this:
    String htmlPath = application.getAttribute("html-path");I can't remember how to do his off-hand but I know it works.

  • Web - What is easiest way to implement User Security and User Profiles

    Hi, I am new to these forums and kind of new to Java. Sorry if this is in the wrong forum!
    Bit of background to my experience with java
    I have been playing about with java for a number of years and have created a few basic programs such as a screen shot tool that allows you to capture to default locations and look at previews first etc. I am now venturing into web related stuff. I work in IT doing systems testing and have done bits of basic development on various things.
    What I've done so far
    I am using Netbeans IDE 6.7 and MySQL 5.0
    I am trying to learn more complex java and have decided to try build a basic web / database system that basically implements adding / amending / deleting data from a MySQL database through web pages. I am now trying to implement basic user access and profiles. I have so far got the following:
    - MySQL table with user info - username / password
    - JSP page with usual login stuff
    - Servlet that validates the username and password - if correct forwards to main menu page.
    Its as simple as that - there is nothing stopping you just typing in the URL of the main menu page and going from there.
    What I want
    I am wanting to eventually get the following:
    - User authentication so that you have to logon before you can access anything else
    - User profiles that determine what each user can or can't do, restricting the pages / services / options available (i.e. normal user can't delete etc)
    - Would it need some sort of session manager to allow multiple users etc?
    I appreciate this is a fairly open question but what is the easiest way to start implementing this? Not after specific code as I would prefer to try figger things out myself, but a point in the right direction would be great. It doesn't have to be extremely secure as this is just for me at the minute.
    I have spent all day looking at things like session data / url rewriting / security settings in web.xml / bespoke servlets and am now in java overload!

    Hi everyone,
    I've now actually gone back to the tutorial that I linked to above and implemented that using form login and j_security_check.
    Agree with Saish, and although I don't know enough about the other options to give a good reason, using realms and j_security_check just seems to be a bit cluncky and messy. I would also prefer something a bit more generic, that doesn't rely on setting users in glassfish, hence why I started with my own user table.
    Anyway, I will leave it as is for now and maybe come back and try one of the other options.
    The only problem I can see now is that to add users i will need to go through all the steps of adding users in glassfish and web.xml... Is there a way to do this through a servlet or something so I can have a jsp page to add users that also creats all the other bits for it to work?
    Thanks everyone for your help

  • What is the easiest way to create and manage very big forms?

    I need to create a form that will contain few hundred questions. Could you please give me some advise on what is the easiest way to do that? I mean for example is it easier to create everything in Word (since it is easier to manage) and than create a form based on that?
    My concern is that when I will have a very big form, containing different kinds of questions and with many scripts, managing it during work will be slow and difficult, for example adding a question in the middle of the form which would require moving half of the questions down which could smash the layout etc.
    What is the best practise for that?
    Thanks in advance

    Try using Table and Rows for this kind of forms. These forms will have the same look throught with a question and and answer section..
    In the future if you want to add a new section, you can simply add rows in between..
    Thanks
    Srini

  • What is the easiest way to open an application from Labview?

    I need to open an application from labview and depending on a user's selection, load one out of a group of files for the application that is opened. I need to know what is the best or easiest way to open an application and load a file that is used by the application based on a selection.

    Here is the response that I got from Cognex when I asked them about how to do this. Do you understand what they are talking about?
    In order to do something like this you will probably want to look into the Display Control/SDK for In-Sight. The Display Control gets installed along with In-Sight Explorer and includes a control that can be used in an environment like Labview to communicate with In-Sight sensors while the SDK is an enhanced version of the Display Control that gives you more control and functionality. I am not very familiar with the Labview environment so I will give some code snippets in VB.Net and hopefully you can adjust them as necessary. Specifically I see 3 possible avenues to do this:
     1) Using the Display Control you have access to many of the dialog boxes that are used in In-Sight Explorer including the Load Job dialog box. You can spawn this dialog box through a line of code similar to cvsInSightDisplay1.Edit.OpenJob.Execute(). I am not certain if the Labview environment will be able to spawn and display this dialog though. 2) With the addition of the SDK (additional purchase) you can directly access sensor properties including the job. There is a method called LoadJobFile to load jobs from on the sensor and LoadJobFileLocally to load jobs from the host machine. A typical line of code might be cvsInSightDisplay1.InSight.File.LoadJobFile("myjob1.job").3) If Labview cannot handle the dialogs and the SDK is not an option for you then you may still be able to do this using Native Mode commands. Native Mode commands are sent through a socket on the telnet port (typically port 23). Keep in mind that you will need to handle the username/password prompt and response when you first open the socket before issuing any Native Mode commands. The command to load a job file from the sensor would be the Load File command which would be a string similar to "LF myjob1.job". The Native Mode commands are documented in the In-Sight Explorer help file. 

  • What is the easiest way to restore to a previous backup of Time Machine?

    I was adding some simple album cover artwork to my iTunes collection when the computer locked up. I got the spinning beach ball and was unable to "force quit." So, I did a re-boot using the power key. I then launched iTunes and it opened properly with all the new Album Artwork. The files were not large in size and the "Album Artwork" folder is only 99.8MB.
    I did a Time Machine backup yesterday and the only thing changed on the computer was the artwork. However, when Time Machine launched to do a backup it said there was 30GB(!!!) to back up?!?!?
    I am assuming something got corrupted in the iTunes library file during the crash and now it thinks it has to back up part of the music.
    So, that is what caused the problem. My question is, what is the easiest way to simply restore the backup the Time Machine had completed yesterday before all this happened?? It doesn't seem like there is a simple way to accomplish this. It looks like TM is used to back up specific files or folders and not to restore the computer to a previous state.
    Any help is much appreciated.
    Thanks in advance!!

    Time Machine backs up all files except those you exclude in TM prefs. It doesn't "know" what kind a file is; it just compares info about a file on the source drive to see if it has already been backed up, or if it is new or has changed and needs to be backed up again. For unchanged files or folders, TM simply creates another hard link on the backup drive.
    iTunes artwork files are separate files. The assignments of artwork to particular music files are saved in another file within the iTunes application (which is actually a package, a folder containing other files). So if all you did was add album artwork, TM would back up each new artwork file, and a new copy of the hidden file within the iTunes application containing the artwork-music links.
    The following is speculation on my part, but it seems logical:
    TM uses records in the hidden File System Events log to identify any new or modified files. However, it is possible to have an FSE entry as to a particular file without modifying the file (e.g. open, then close). So TM doesn't "know" until it actually compares the source file with the backup file (if one exists) whether a file is new or has been modified.
    Hope this helps.

  • Easiest way to pass data to/from subpanel?

    I am new to subpanels and am kind of overwhelmed by the various responses I've read on the forums about this issue.  Some people use named references, others user events, others queues...and right now I guess I've yet to see an example that was really clear for me to understand.
    In my case I have lots of different controls and indicators within my subpanel.  Two main things I need to do:
    1. I need to pass the VI that gets loaded into the subpanel a single string and a single numeric
    2. When there is an event on the subpanel (either a value change event for any control, or a mouse up event), I need to pass out a reference to the control that caused the event.  The top-level VI will then process the top level event.
    So that's it....2 inputs (1 string, 1 numeric), 1 output (a ctrl ref).  Both inputs will be changing regularly as data from a telnet connection is read, and the output is driven entirely by user interaction with the subpanel (i.e. it's independent of the inputs).
    What's the easiest way to do this?
    thanks

    bmishoe wrote:
    I was thinking about it some more...the ctrl reference that I said I wanted to pass out - it could just as easily be a string.  The label of the control has indices as part of it's name that I use to index an array to extract a string.  There's no reason I couldn't do that within the subpanel and simply pass out the string itself.
    So to modify my question slightly - the VI loaded into the subpanel takes in a string and a numeric and outputs a string, and I want the top level VI to execute an event structure each time the output string changes.
    thanks...
    If that's how you want to handle it, you should have 3 inputs, String, Value and User event, and inside the VI you check if the string has changed, in which case you generate an event. The Main VI will subscribe to the event and execute it.
    The event has ofcourse string data so you'll send the data up to Main vi.
    Easier would ofcourse to simply have the string output from the subvi and update the main vi's indicator each time.
    Whether you show it in a subpanel or as a popup vi is just a visual thing, the VI should work the same.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • What is the easiest way to download a document from SAP DMS with C#?

    Hi,
    I've been sifting through this forum and looked at various posts and sample code, but so far my quest hasn't been fruitful.
    What is the easiest way to download a physical document file from SAP DMS using C#? I'm using the NCo 3 (SAP .NET
    Connector 3).
    Requirements
    - As few dependencies as possible (not adding or changing functionality in SAP)
    - C# code (MS Visual Studio 2012)
    - SAP Environment: NetWeaver 7.4.0
    Thanks for all help.
    Regards,
    Frank

    We've been using BAPI_DOCUMENT_CHECKOUT2, but there seems to be a limitation. From what I've found on Google, you must enable the use of the SAPGUI through the flag UseSAPGUI when connecting to SAP.  It works, but my issue is that when I use it on a web server, I end up with some error when trying to start the GUI.  There is very little recent information for this out there right now.

  • Is there a montage package in adobe. What is the easiest way to do montages?

    I would like to do professional montages the easiest way. Is there a package in adobe that I can use with my photoshop.  I use to do them on old photoshop 5, was able to have my photos and format on the same page and just move them. But its not working on cs6.
    What would be the easiest way? Bridge? Photoshop? Elements?

    Elements has some sort of collage facility.  I created a Photoshop Photo Collage Toolkit I find easy to use but then I programmed it.
    Photo Collage Toolkit  UPDATED April 30, 2013 Added border option to PasteImageRoll.
    Photoshop scripting is powerful and I believe this package demonstrates this.
    The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.
    There are eleven scripts in this package they provide the following functions:
    TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
    CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
    LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
    InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
    ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
    ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
    PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
    BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
    BatchMultiImageCollage.jsx - Used to Automatically Batch Populate Any Photo Collage template with images in a source image folder. Easier to use than the interactive script. Saved collages can be tweaked.
    BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder
    PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.
    Documentation and Examples

  • What is the easiest way to show a command line app in an appletviewer

    I'd like to convert a command line interface application to a small applet, for use in an appletviewer. What is the easiest way to implement this.

    I made something like what you are describing for a text adventure engine. It uses a big text area for output and a small text field for input.
    Here's the code
    public class myApplet extends java.applet.Applet
         implements Runnable
         TextArea output ;
         TextField input ;
    public void init()
              width = this.size().width ;
              height = this.size().height ;
         public void run()
              makeComponents() ;
              while( true ) // loop on + on + on
              try { Thread.sleep( 10 ) ; }
                        catch (InterruptedException e) {}
    public void makeComponents()
              input = new TextField() ;
              input.setSize( Math.min( 200, width - 5 ), 25 ) ;
              input.setLocation( 5, height - 30 ) ;
              add( input ) ;
              input.addActionListener( new ActionListener()
                   public void actionPerformed( ActionEvent e )
                        String temp = input.getText() ; // do something with this
              output = new TextArea( "", 0, 0, TextArea.SCROLLBARS_VERTICAL_ONLY) ;
              output.setSize( width - 10, height - 40 ) ;
              output.setLocation( 5, 5 ) ;
              add( output ) ;

  • What is the best and easiest way to speed up a Mac-MINI?

    What is the best and easiest way to speed up a Mac Mini without adding memory?

    I'd tried to reply yesterday to your question but for some reason it didn't go anywhere and I got a red message box in the Discussion post area with "error." After trying three times, including  log-out, clear cookies from browser (and history) and back in, I still was unable to add my post with links to resources for your Mini, here. And the last time I tried that, the copied text also went missing as I found it gone after considering to make a Text document of it, for later posting.
    Anyway, the http://iFixit.com site has guides on how to replace RAM in the computer you have. Note there are different models shown and from what I remember, yours is the last 'old look' Mini with an optical drive. The model after that is thin, a 2010 model with slot in front for discs; the next one has no internal optical drive.
    RAM specs:  2 - 204-pin PC3-8500 (1066 MHz) DDR3 SO-DIMM (replace pair) up to 8GB total. Best price would be an online vendor of repute, once you know about what they sell for, you could ask a local mac expert if they could get you a better than retail price. I get ram from OEMPCworld and shipping is about $1. including insurance to my post office box, priority or 1st class. At about half retail. Crucial (website) offers parts, too; and so does OWC (other world computing).
    In addition, I recommended checking into the build specs and quality of the OWC (esales) site for external enclosures with their own power supply, for hard disk drive; for storage and bootable clones on different partitions. And see about Bombiche Carbon copy cloner, it is a commercial product now, not donationware. I've used it successfully to make competely bootable clones on a suitable external HDD (drive should have own power supply, too) A 750GB HDD in a self-powered enclosure that can boot Mac OS X from a clone, is a good start on backing up your upgraded OSX in a way you can clone it back into an empty, wiped or new HDD inside the computer; and it can run from the external. You can't necessarily use a TimeMachine that way.
    This should be your Mini -- check other indicators to be sure:
    http://www.ifixit.com/Device/Mac_Mini_Model_A1283
    A serial number lookup site such as the one I end up using because I had it bookmarked is OK: http://www.powerbookmedic.com/identify-mac-serial.php & also have mactracker http://mactracker.ca
    Anyway, before I time out or exceed post content(?) This is not all I meant to write before.
    Good luck & happy computing!

Maybe you are looking for

  • Format of lcr?

    what is the format of LCRs captured at the quetable at the source?is it in xml lcr format?if it is not,can i convert in into xml lcr?so that i can make JMS to read the queue contents

  • HP G85 all in one - not printing color

    The printer display said the color was out so I bought a new cartridge.   So, installed it, did a test print but no color so I chose the clean cartridge several times - still no color at all.   Printer is not complaining about the cartridge, no error

  • Why won't my Macbook charge a battery???

    I bought a battery on ebay a few months back when I thought I was buying a macbook from another guy with a bad battery macbook. It has sat out for a few months but it only shows having 3 cycles in the "about this mac" page. It was new as of a few mon

  • Bug in ALL_TABL_COLUMNS ?

    It seems like ALL_TAB_COLUMNS doesn't tell column data types properly... (Oracle 9i Lite 502) I create ANY table that have a DATE column. Ok. Create table LEO (id number, my_date date); When I query ALL_TAB_COLUMNS, the column "my_date" from table "L

  • SXMB_MONI displays Errors only

    hi all, Due to some reason SXMB_MONI is displaying ERRORS only even if I select all the messagse. Is there a config setting that need to be changed ? Please advise, Thanks. FS