• Post Reply Bookmark Topic Watch Topic
  • New Topic

resolving path to absolute on JRun

 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an upload form and I'm targeting the destination of the file to the web-inf/classes directory in the app. Working in tomcat, if I go (off the top of my head, could be slightly off):



This miraculously returns me the directory web-inf/classes. But this isn't the case for JRun, it returns me some directory inaccessible from my console manager. I'm staying away from getRealPath from the servlet context, it's way too inconsistent. How can I get a handle to web-inf/classes/ (or any directory in my app for that matter) consistently and reliably? Has anybody had to do this before? Any help is greatly appreciated. Mike.
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe not quite what you're looking for...I just set an env-parameter in the web.xml of the context.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the ServletContext.getRealPath() method.

[Oops. Missed that part in the original post. See reply below.]
[ August 27, 2004: Message edited by: Bear Bibeault ]
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, thanks for the replies. For the first one, I'm trying to go towards a more dynamic solution. Determining the absolute path, then hoping nothing get's changed in the server to alter that path is a little too risky. As for the second response I addressed that solution above:
I'm staying away from getRealPath from the servlet context, it's way too inconsistent.
This method has been known to return null in certain cases. Unless anybody knows this is a gauranteed way to determine the absolute. -Mike
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Edited for clarification]

There is no valid reason on earth that you should be avoiding using the standard methods defined by the servlet specification because a servlet container has implemented them badly. There are just way too many good choices out there to use a container -- especially one that costs good money -- that poorly implements the servlet and JSP specifications.

The getRealPath() method is the official and standard way to map a relative resource path to its absolute path, and I've used it in almost every web application I've written without a single issue under the Tomcat and Resin servlet containers. I've used JRun in a previous job and wouldn't touch it again with a 10-foot pole. Apparently it hasn't improved any in the intervening years judging by your experiences with inconsistent results.
[ August 27, 2004: Message edited by: Bear Bibeault ]
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah the JRun option was definitely not my choice, but it's the only app we have in our group for 24x7 support. I'll go back to getRealPath() then, the biggest differences I saw in its behavior had to do with whether the app's war file was exploded or not. Thanks for all your help!

- Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!