Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I employ a "deployment descriptor" for a Java business class in both stand-alone and servlet context

Posted on 2007-11-19
1
Medium Priority
?
193 Views
Last Modified: 2013-11-24
I am attempting to build my first Java application, with an initial goal of making it a web app.  I have followed the MVC convention and placed all of the business logic in a separate class (the Model).  I am unclear how to create a configuration file for this Model class for things like datasource information.  In my research it has been very clear how configuration works for servlets (a deployment descriptor: web.xml).  What isn't clear is how I can utilize some similar configuration scheme for the Model class, such that it will work when deployed as part of a servlet app but also as a class included by a non-web Java app (such as the test harness I built for the Model class). It seems I could use web.xml for the model class when it is part of a servlet, but then how would it work in a standalone app? The ideal solution won't make me use two different methods for using the class in a servlet vs in a standalone app.
0
Comment
Question by:bluegreenone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 2000 total points
ID: 20318106
Most people put configuration information (for non-Web apps) into a properties file, sometimes named myapp.properties.  It's in the name=value format, so it can easily be read using the methods of the Properties class.  You can put myapp.properties in the same directory as your class files, or in your .jar file (often in the top directory, but location varies).

Then, in your web.xml file, you could put the location of the myapp.properties file, which is then used to read the properties for your model class.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question