Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Accessing local files through a servlet in glassfish

meatwadFeb 10 2011 — edited Feb 11 2011
I need a way to access a configuration file from a servlet but keep it hidden from the end user/client. This is the method I have previously used in Oracle App server:
filepath = getServletContext().getResource("/cfgfile").getPath();
InputStream is = getClass().getResourceAsStream(filepath);
This worked. However in glassfish this technique returns a true url to a file in the document root. That would be ok but it allows the user to view it from a web browser as well and I want to prevent that. Is there a way I can do this?
This post has been answered by ramp on Feb 10 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 11 2011
Added on Feb 10 2011
2 comments
769 views