What's the preferred way to load database properties (url...) in a web app?

In a simple stand alone app, I would normally use a properties file for the database url, username, and password instead of hardcoding the values. But I am not so sure about web apps. I don't even know where I put a properites file for a servlet to see. Is there a section in the deployment descriptor (web.xml) for me to define such properties?
Any help would be greatly appreciated.
By the way, I am using the Tomcat version that came with the jwsdp-1.3.

Don't now if it's the recommended way, but we're doing this with the context-param elements of the web.xml file.
Example :
<web-app>
<display-name>MyWebApp</display-name>
<description>
A sample Web Application
</description>
<context-param>
<param-name>driver</param-name>
<param-value>org.postgresql.Driver</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:postgresql://mydbhost/mydbname</param-value>
</context-param>
<context-param>
<param-name>user</param-name>
<param-value>dummy</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>garbled</param-value>
</context-param>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
In our Web application, we read those values in the following way :
public class MySVCImpl implements ServiceLifecycle, MySVCIF {
public void init(Object context) {
ServletEndpointContext seContext = (ServletEndpointContext) context;
ServletContext sContext = seContext.getServletContext();
String driver=sContext.getInitParameter("driver");
String url=sContext.getInitParameter("url");
String user=sContext.getInitParameter("user"),
String password=sContext.getInitParameter("password"),
Hope this helps.
Mark

Similar Messages

  • What is the preferred way to open a new url in a new window/popup?

    Hi Guys,
    I have an application that requires me to show another URL (Fedex tracking number) once a button is clicked.
    what is the preferred way to do it?
    Should I open a new browser or a popup?
    I would appreciate if you have a code example I can use.
    Thanks,
    Itay

    hi,
    For opening a URL , you could also close previous window and open a new browser.
    Follow the steps :
    -> make an outbound plug in your window.
    -> Add URL of type string as a parameter for your outbound plug.
    ->Do remember to add Component Name in the Properties Tab of View ( othervs Calling Outbound plug of win from view wont b psbl).
    Write the below mentioned code to call a URL  in the OnAction of button :
    DATA lo_zexit TYPE REF TO ig_zexit .
    lo_zexit =   wd_this->get_zexit_ctr( ).
      lo_zexit->fire_out_window_plg(
        url =   'http://www.google.com'                            " string
    here replace ig_zexit with your  ig<applicatin name>.
    Other way around is using Code Wizard ( control _ F7).
    Write the below code in the onaction of button :
    data lo_window_manager type ref to if_wd_window_manager.
    data lo_api_component  type ref to if_wd_component.
    data lo_window         type ref to if_wd_window.lo_api_component  = wd_comp_controller->wd_get_api( ).
    lo_window_manager = lo_api_component->get_window_manager( ).CALL METHOD lo_window_manager->CREATE_EXTERNAL_WINDOW
      EXPORTING
        URL            = 'http://www.google.co.in/'
        MODAL          = ABAP_FALSE
        HAS_MENUBAR    = ABAP_TRUE
        IS_RESIZABLE   = ABAP_TRUE
        HAS_SCROLLBARS = ABAP_TRUE
        HAS_STATUSBAR  = ABAP_TRUE
        HAS_TOOLBAR    = ABAP_TRUE
        HAS_LOCATION   = ABAP_TRUE
      RECEIVING
        WINDOW         = lo_window.lo_window->open( ).
    You can choose any way whichever suits your requirements.
    I hope it helps.
    Thanx.

  • What's The Best Way to Load a Replacement iPod Touch?

    I just received a replacement iPod Touch 3G for my daughter. Her iTunes library for the Touch that we returned to Apple is on her MacBook Pro. What is the best way to load the new Touch? She plans on using the same name for it. Should I restore from a previous backup or just plug it in and let in sync? Do I need to set anything on iTunes for disk management?
    Thank you,
    Bruce

    If she wants it like her old one the previous backup, if there is anything she wants to change though, now would be a perfect time to just resync it and start over. It really depends on what she wants.

  • What's the best way to load balance multiple protocols on one vserver?

    Hi,
    We have a CSM blade on a 6513, in bridge mode. I'm just wondering what is the best way to serve HTTP and HTTPS (or any two or more ports) from the same group of servers. As I see it, we have two options:
    1. Don't set a port on the vserver, so it is load balancing "any" or "tcp". This is easy but I want to be sure there isn't a downside to this, other than the obvious security issue.
    2. Create multiple vservers and point them at the same serverfarm. I tried this and I got some odd results with the health checks.
    Any ideas? Thanks a lot.

    you listed the only 2 options available.
    The advantage of solution #2 is that you can apply specific config for each protocol ie: for HTTP you can turn 'persistent rebalance' if needed.
    If you want to use specific probes [not icmp], it is also a good practice to create a different serverfarm for each protocol.
    Like this, if the HTTP service goes down but not the server, you can still have other protocols loadbalanced.
    Regards,
    Gilles.
    Thanks for rating this answer.

  • [SOLVED] What is the best way to load iptables/nftables on boot?

    Hi -
    New arch user migrating from Ubuntu/debian.  I'm used to loading netfilter iptable rules using an /etc/network/interfaces file.  What is the best way to do this using netctl/systemd?
    An RTFM of the wiki and a Google search didn't provide an answer, but maybe I'm just looking in the wrong places.
    Last edited by pgoetz (2014-06-21 08:32:01)

    Ah, OK -- got it.  I can just blindly enable the iptables.service, and systemd will make sure the interfaces are up before running the service.  How cool.  I'm still getting used to the luxury of not having to worry about stuff like this myself.  The only minor issue is it looks like I'll have to get the systemd nftables service out of AUR.
    Last edited by pgoetz (2014-02-24 19:58:53)

  • What's the best way to load FieldPoint measurement data into PI System?

    I am finding the best way to load data collected by NI Field Point (FP2220) into the PI system of our power plant.
    I found pieces of information about FieldPoint OPC server in NI.com. Not sure if it comes with Field Point Hardware, sold by NI as a separate product or it is actually non-standard NI products. Anyway, I know that there exists a thing called FieldPoint OPC server.
    The PI system I mentioned has a OPC client software called PI-OPC interface. It is able to communicate with standard OPC DA server. If that FieldPoint OPC server is a standard OPC DA server provide data collected by Field Point complying to OPC standard, than that's perfect.
    Anyone familar with PI system and NI product, please help if the above is going to work or if there is a better way to put Fieldpoint data into PI.

    Hi Eric,
    This information really helpful, thanks. Regarding to the NI OPC server for NI FieldPoint, I have the other query.
    In my setup, there are two sets of FieldPoint located in two different locations on my ethernet network. They are going to be controlled by a single PC. If I am going to connect both my FieldPoint sets with OPC standard, how many NI OPC server for FieldPoint do I need to connect to? Are there two NI OPC servers each serves one FieldPoint set? Or there is only NI OPC server which serves both FieldPoint sets?
    I am concerning about the number of NI OPC server instances running, because the number of OPC client license I need to purchase depends on how many OPC server I need to connect to. If one NI OPC server serves both my FieldPoint sets, I only need to buy one OPC client license; otherwise, I need to purchase two. In the future, I am going to have another two sets of FieldPoint sets, so the answer of my query determines how many OPC clients I need to purchase eventually - One or four. A huge price difference.
    Looking forward to your reply.
    Regards,
    Roger

  • I want to load movies in to my iPad through itune in my pc that runs window XP. First of all I am not able to add the movies to the itune ,leave aside sync to iPad .can some one suggest what is the simplest way to load movies in my iPad.

    I have plenty of DVD which I load in my laptop and watch the movies while travel, however I am not able to do that in my iPad .
    I would appreciate some one guide me the simplest way of loading the movies in to my iPad. I tried the conventional procedure of loading/copying in to itune then sync to the iPad to load all movies in it, but failed to do the first step( not able to load /copy in itune) leave aside the sync to iPad next.
    Do I need to sellout some 20 odd $ to buy a conversion software that would help?
    Is it that Apple trying to make money by not making this simplest of thing possible by the user.( ref. windows, every thing is possible with little IQ of the user).
    If it is so , I would stop many of my friends to restrain from buying a device like this by spending some 1000$   ,rather look at a good Droid that is catching up so well.

    If you are the only user on your computer you probably don't have multiple user accounts set up and can disregard that.  If you are using iTunes 11 go to View>Show Sidebar.  Now see if your iPad appears under Devices on the left side when you connect it.  If it does, click on the name of your iPad on the left side and your iTunes sync settings options will appear in folders with tabbed headings to the right.
    If it doesn't appear on the left side, follow the troubleshooting steps shown in this article: http://support.apple.com/kb/TS1538.

  • What is the best way to keep high res when saving "for web"

    the files i'm saving for web so i can get them in jpg (or gif) format are coming out very pixelated.  this is when i print the image. 
    what is the best way to save for web an image and keep the resolution good. 
    using for a business card template.  avery template will let me attach images i want to the project.  to do this..  i "get file from computer" and it drops the image in but real small... then you are supposed to enlarge it onto your work however you want.  well when i enlarge this image file, it gets pixelated badly.  i'm thinking it's the way i'm saving it.  i do not adjust anything when i save.  maybe i should.  this is where i need guidance. 
    this is what avery template notes about the images i am allowed to use - When uploading the image, the maximum size allowed is 4 MB.  You can only upload JPG and PNG images either as RGB or CMYK.  so when you recommend things, can you please keep this in mind
    thank you for oyur time.

    Aida,
    When you save with the default template using save for web it is generally a very low settings.
    While in the save window you can define the pixel size of the image you want with quality as well as resolution too.
    Refer to tv.adobe.com video save for web or Adobe help file for detailed instructions.
    Mandhir

  • What is the best way to load and convert data from a flat file?

    Hi,
    I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
    The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
    What is the best and easiest way to archive this?
    Thanks,
    Carsten.

    Hi,
    thanks for your answers so far!
    I gave them a thought and came up with two different alternatives:
    Alternative 1
    I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
    The columns of the staging table have the target format (date, number).
    The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
    Alternative 2
    The columns of the staging table are all of type varchar2 regardless of the target format.
    I define data rules for all columns that require a later conversion.
    I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
    The rows that cannot be loaded go automatically into the error table.
    When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
    What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
    Further, I would prefer using expressions in the mapping for converting the data.
    What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
    I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
    As far as I know I need the data quality option for using data rules, is that true?
    Is there another alternative without any of these drawbacks?
    Otherwise I think I will go for alternative 1.
    Thanks,
    Carsten.

  • What is the best way to copy database from overseas?

    Hello All,
    As customer need to migrate their databases(200 databases) to our data center, at this moment, we usually ask customer to send full backup by HDD and then send trn files via FTP, then we restore full backup and apply latest trn files until cutover. However
    FTP is not stable, trn files are always broken.
    The databases size are 3GB~150GB, trn file size are 1MB to 5GB, especially the big trn files are failed every time, we have set transfer mode to Binary in FTP client, but it still fails.
    I have VPN access to their database server, so in this case is there a better way to copy/migrate their databases to our server?
    Customer using Windows 2003 + SqlServer 2008
    We using Windows 2012 R2 + SqlServer 2014
    Appreciate your suggestions/advises.
    Thanks,
    Albert

    You are doing it the best way. I would also ship the tlogs via courier if time permits. Note that the tlogs get very large during maintenance operations. You may find that if you continually ship the tlogs via log shipping and stagger the cutover you may
    be able to do this in waves.
    With this many databases this sort of migration is difficult without downtime.
    looking for a book on SQL Server 2008 Administration?
    http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
    http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941

  • What is the best way to optimize database resources in a JSP centered webap

    hi, i am kindda i am new to jsp. so i make database connections on evry page.Assuming i am working on an app where there could be 300 concurrent users, what is the best approach for me to take?
    thanks
    obinna

    java_everywhere wrote:
    hi, i am kindda i am new to jsp. so i make database connections on evry page.JSP shouldn't have anything to do with database access. In any case, you shouldn't be connecting on every page either. You should be recycling connections via a pool.
    Assuming i am working on an app where there could be 300 concurrent users, what is the best approach for me to take?You will have to decide for yourself because we don't know what your app does, how much hardware you have, network latency, etc.

  • What is the preferred way to handle ASUnicode data?

    The ASUnicode typedef is incompatible with wchar_t but seems to be compatible as far as I can tell. I'm only currently dealing with ASCII-compatible characters but certainly don't want to cause any headaches down the road.
    There are only two posts here that have ASUnicode in them and both are just incidental in the presentation of source code. Both posts indicate a similar understanding to mine. PIUActionUtilities.cpp in the samples also implies that they are compatible given the use of casts in that file to LPCWSTR.
    So am I fine just using wchar_t throughout my code and casting to ASUnicode when I need to (e.g. when calling the JS scripting interface)?  And I can go the other way without issue as well, so all of my returned data can just be dealt with as wchar_t pointers?
    Thanks.

    Yes, as of now you are safe. We like to be binary compatible so a change to this in the future would probably result in a new API. There are no plans to change any of this.
    I would just add a compile check that wchar_t is the same size as ASUnicode. Depending on your compiler the default does change. Adding a sizeof(wchar_t) == sizeof(ASUnicode) check would alert you to the fact that something has changed. And use the routines as much as possible in the suite.

  • What is the proper way to set up how to stop a web worker?

    The example here uses a pair of bools which is simple and does the job.
    The sample code created when you create a web worker shows using a CancellationTokenSource & a ManualResetEvent which is quite different.
    What's the suggested approach. And if it's CancellationTokenSource & a ManualResetEvent - is there something that explains how best to use them? The sample code provides no hints about how to do this.
    thanks - dave
    What we did for the last 6 months -
    Made the world's coolest reporting & docgen system even more amazing

    Hi David,
    We usually use the worker role to host the long running application process, and we can use the Sleep method to reduce the resource usage like below:
    public class WorkerRole : RoleEntryPoint
    public override void Run()
    { while (true)
    Thread.Sleep(10000);
    //your work .......
    public override bool OnStart()
    ServicePointManager.DefaultConnectionLimit = 12;
    return base.OnStart();
    If you prefer to use the CancellationTokenSource & ManualResetEvent with WorkerRole and make your application more consecutive. There is a excellent example provided by Bibhu, I suggest you take a look at it.
    http://www.codeproject.com/Articles/810308/Creating-an-Azure-Cloud-Service
    Best Regards,
    Fuxiang
    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. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • What is the best way to load multiple instances of a button into master index page?. I have looked a

    I have successfully created an animated button that opens to reveal a quotation with a nested clickable link to the source. What I would like to do is have several of these with different quotes inside them, scattered on the page. I have looked at the composition loader available via Edge Commons, and it seems that would require some sort of Edge animate Stage 'frame' to load the instances into? Is there any way to place them directly into the master page - as div elements...?
    The outer of the buttons is the same, on hover they open partialy on click fully, to reveal  their particular text - which I thought about loading it at runtime with json, or maybe handlebars...?
    I would also like to make the buttons only take the necessary space. ie. before they expand they are only buttons. ( I have set the stage to hidden but it still takes up space). To acheive this, I think perhaps I will have to target the inner components css, and set them as display:none until the button is hovered over, then set :hover and :active pseudo classes inside edge. Is this feasible?
    Thanks in advance for any ideas/suggestions...

    Hello, Thanks for your helpful input. Based on that, and the tutorial 'http://tv.adobe.com/watch/learn-edge-animate-cc/ingesting-external-data-dc/' - I have written code to drive my button's behaviour.  (copied below...)
    var textArray =new Array();
    var currentHead = 0;
    var currentText = 0;
    var currentFoot = 0;
    var s = sym.getSymbol("textContainer");
    sym.$("textContainer")$.("text").html("");
    var sh = sym.getSymbol("headContainer");
    sym.$("headContainer")$.("head").html("");
    var sf = sym.getSymbol("footContainer");
    sym.$("footContainer")$.("footer").html("");
    $.getJSON("assets/sources1.json", function(data){
              for (var i=0; i<data.length; i++){
                        textArray.push({"head":data[i].heading,
                                  "text":data[i].text,
                                  "footer":data[i].foot,
                                  "link":data[i].link});
              sym.$("headContainer")$.("head").html(textArray[currentHead]).heading;
              sym.$("textContainer")$.("text").html(textArray[currentText]).text;
              sym.$("footContainer")$.("foot").html(textArray[currentFoot]).foot;
              sym.$("footContainer")$.("link").html(textArray[currentLink]).link;
    But there is an error I don't understand at line 7...
    Also - as you can see, at present I have several symbols in parallel. Would I be better off nesting the text containers inside the outer button container? and would I be better off creating styled mini- pages of text data, and then loading them - instead of loading them as symbols? I have had to create seperate symbols because I cannot adequately stle the text - so some is bold, some is italic etc. within one text field. Or can I? I guess I could nest several text fields inside one symbol...?
    I remain unsure how to load the finished animation button instances. In your example you were still loading into an animation But from yor example, I guess I would need to place all my examples inside an outer edge composition... but then I think positioning them accurately with css, making adjustments etc. will be fairly tricky. Is there any way to place multiple instances directly into divs in index.html? Could I simply repeat the class...? I may be answering my own questions here.

  • What is the best way to load 14 million COPA records from BW into HANA?

    I have been managing a project in which we are attempting to load COPA data from BW into HANA using Open Hub and we continue to run into memory allocation errors in BW. We have been able to load 350,000 records.
    Any suggestions on what the best approach would be along with BW memory parameters.
    Your replies are appreciated.
    Rob

    Hello,
    this seems to be issue in BW caused by big volume of migrated data. I do not think that this is HANA related problem. I would suggest to post this message into BW area - you might get much better support there.
    But to help as much as I can - I found this (see point 7):
    http://help.sap.com/saphelp_nw04/helpdata/en/66/76473c3502e640e10000000a114084/frameset.htm
    7. Specify the number of rows per data package for the data records to be extracted. You can use this parameter to control the maximum size of a data package, and hence also how many main memories need to be made available to structure the data package.
    Hope it helps.
    Tomas

Maybe you are looking for

  • Daqmx 9.02 on windows vista x64

    I tried to install the latest daqmx drivers but it gave me a bunch of errors while installing NI-VISA and a bunch of other products. Eventually it finished installation but now nidevmon.exe does not start. Here's what I'm trying to do: I already have

  • How to run 300w of video cards with precision tower 5810 685W power supply?

    I have a precision tower 5810 with 685W power supply.  In the Tech Specs it says. Support for two PCI Express® x16 Gen 2 or Gen 3 graphics cards up to 300W (total graphics in two slots with 685W PSU) So you should be able to run two 150w video cards

  • Generate a dynamic Transparent container in WD

    Hi all, i' ve created a Transparent conatiner in where i will write my text, i also created a Button (ADD) what i want now is, after clicking on the (Add) Button, a new Transparent container will appear,  how can' I do this dynamically??  i dont want

  • Why there is no manual creation of deliveries for STO...

    Individual(VL01N) : You can create one delivery for each sale order on the screen. There is no manual creation of deliveries for STOu2019s. Transaction VL01N Why there is no manual creation of deliveries for STO... Thank you very much. Hoolaa Edited

  • How to create a dynpro property on the WAS and get it in code?

    Hello, I remember that once I've read at the NWDS help that I can create dynpro properties which can be configured on the WAS's Configuration Adapter serviceand can be retreived when the dynpro application loads. I need to use it now but can't find t