Accessing hidden files in an .ear

H

HJ

Hi,

In a j2ee web application, is it possible to package files in an
..ear or .war file, in such a way that they can be accessed by, say,
servlets, but are not accessible by browsers?
(For example, an xml or xsl file.)
Is there a common practice to do this? E.g. can i put such files
in a special subfolder, like WEB-INF, or so? And how to access such
a file, then?

Many thanks in advance.
 
O

Oscar kind

HJ said:
In a j2ee web application, is it possible to package files in an
.ear or .war file, in such a way that they can be accessed by, say,
servlets, but are not accessible by browsers?
(For example, an xml or xsl file.)
Is there a common practice to do this? E.g. can i put such files
in a special subfolder, like WEB-INF, or so? And how to access such
a file, then?

For a web application, it's overkill to use a .ear file (unless you're
talking about a full-blown j2ee application, including EJB's, tc).

Web applications have a WEB-INF directory. By design, this directory is
protected: no browser may access it. Your servlet may however, using (for
example) javax.servlet.ServletConfig#getResource(String).

For property files etc, I'd still put them in the classpath however, and
use (for example) Class#getesource(String).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top