in Education by
I am new to java so excuse my lame questions:) I am trying to build a web service in Java NetBeans 6.1 , but I have some troubles with configuration parameters ( like .settings in .net). What is the right way to save and access such settings in a java web service. Is there a way to read context parameters from web.xml in a web method? If no what are the alternatives for storing your configuration variables like pathnames ? Thank you JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Is there a way to read context parameters from web.xml in a web method? No, this is not easily done using the out-of-the-box. The Web Service system (JAX-WS) has minimal awareness of the Servlet engine (Tomcat). They are designed to be isolated. If you wanted to use the context parameters, your web service class would need to implement ServletContextListener and retrieve the desired parameters in the initialization parameter (or save the context for later use). Since the Servlet engine and JAX-WS would each have different instances of the object, you'd need to save the values to a static member. As Lars mentioned, the Properties API or JNDI are your best bets as they're included with Java and are fairly well-known ways to retrieve options. Use Classloader.getResource() to retrieve the Properties in a web context.

Related questions

0 votes
    What is the purpose of XML in a web service?...
asked Mar 13, 2021 in Technology by JackTerrance
0 votes
    What is the purpose of XML in a web service? A - A web services takes the help of XML to tag the data, format ... to describe the availability of service. D - None of the above....
asked Jan 12, 2021 in Technology by JackTerrance
0 votes
    What is the purpose of XML Messaging layer in Web Service Protocol Stack?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is the purpose of XML in a web service?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is the easiest way to call a web service from Excel (I am using version 2002)? Please, no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    What is the easiest way to call a web service from Excel (I am using version 2002)? Please, no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    We have a customer requesting data in XML format. Normally this is not required as we usually just hand ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    We have a customer requesting data in XML format. Normally this is not required as we usually just hand ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    The Sitecore package wizard can be used to build a package containing data and files for the local Sitecore ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    How to access global and context variables in Talend?...
asked May 30, 2021 in Technology by JackTerrance
0 votes
    How can you access global and context variable?...
asked Mar 16, 2021 in Technology by JackTerrance
0 votes
    In what cases is it necessary to synchronize access to instance members? I understand that access to static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Asynchronous Javascript and XML (Ajax) is technique for creating better, faster, and more interactive web applications. In addition to ... Perl, and C++ D. Java, ASP, and C#...
asked Mar 10, 2023 in Technology by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
...