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
186 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
1 Comment
 
LVL 26

Accepted Solution

by:
mrcoffee365 earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now