Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6859049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:14:07+00:00 2026-05-27T02:14:07+00:00

When creating/deploying war files, I use a in my web.xml to define which property

  • 0

When creating/deploying war files, I use a in my web.xml to define which property file to use:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <context-param>
        <param-name>PropertiesFile</param-name>
        <param-value>/path/to/my.properties</param-value>
    </context-param>
    <display-name>MyServlet</display-name>
    <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>com.my.company.MyServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

and use that in my servlet’s init method so that I don’t have to hardcode the filename in my code:

public void init(ServletConfig config) throws ServletException
{
    super.init(config);

    log.debug("Enter init()");

    // get the properties location from web.xml
    String propertiesFile = config.getServletContext()
            .getInitParameter("PropertiesFile");

    log.info("Using properties file: " + propertiesFile);

    // Finish intiliazing...
}

Is there something similar (or completely different) to set/get the properties file for an ear that contains an EJB jar without hardcoding it in my class? The properties file won’t be included in either the jar or ear but is located on the server outside of the app server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:14:08+00:00Added an answer on May 27, 2026 at 2:14 am

    You can use environment entries and inject them using @Resource to achieve what you want.

    Take a look at this OpenEJB example.

    However, if you say something like:

    The properties file won’t be included in either the jar or ear but is
    located on the server outside of the app server.

    It doesn’t sound good for an enterprise application. You should not depend on resources outside of the container and not make any assumptions about resources you (or the container) can’t control.
    Operations on files are also discouraged (if not forbidden – don’t remember exactly.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a web service, which run in GlassFish, and I want to have
I'm creating a WAR ( TomcatHeartbeat.war ) on my Windows machine and deploying it
I am developing an web application which can upload/download a file from client to
Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?
Creating a server-side socket will fail if I'm trying to use the same port
When creating a web application, and lets say you have a User object denoting
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I'm creating a web service (and test client) that uses mutual authentication. I've used
I'm working on deploying a WAR under Tomcat 6 on a remote server. Now
I'm using eclipse with WTP plugin for creating a client to call secure web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.