aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes getServletContext() getRealPath() problem in packaged J2EE application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "getServletContext() getRealPath() problem in packaged J2EE application" Watch "getServletContext() getRealPath() problem in packaged J2EE application" New topic
Author

getServletContext() getRealPath() problem in packaged J2EE application

Simon Kelly
Greenhorn

Joined: Oct 02, 2002
Posts: 11
What java code do I need to write to find files for my application dynamically as resources i.e. under the WEB-INF/classes directory of my web app installation (war file)?
The issue of virtual paths within the archive files used to package J2EE applications has thrown my application off kilter. Previously the application was deployed as an exploded directory under Apache Tomcat. As I move to deploy it on WebLogic 7.0 it falls over because it uses "getServletContext().getRealPath("/")" to construct the searchpath for the files which are located below the web application root. As this call fails to return anything the
If anyone has an answer to the specific question above or any alternative useful suggestions as to how to approach solving this problem I would be very grateful!
Thanks in advance....
Brendan Birt
Greenhorn

Joined: Nov 27, 2002
Posts: 2
Use the classloader to load your resources from your war file (the files must be in the classpath, like all your .class files).
getResourceAsStream from java.lang.Class is a good place to start looking for how to do this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getServletContext() getRealPath() problem in packaged J2EE application
 
Similar Threads
Uploading file in a folder under context root problem
getRealPath returns null in Linux(Fedora)
Add Link to a file outside of Context
Urgent: cannot find property file in war when packaged in ear
Why won't my images display right in JSP under tomcat?