Link to home
Start Free TrialLog in
Avatar of rajneetbhatia
rajneetbhatia

asked on

Absolute application path

Dear Sir/Madam,

I am using getRealPath() for getting the application path, but it returns null when deployed with weblogic war. Please let me know how can i get the absolute path.

Suppose my file is in C:\Test\WEB-INF\classes\, then I want to get the path to be displayed as "C:\Test\WEB-INF\classes\"....

Server : weblogic 7
Langauge : Java

Wating for quick reply...
Thanks,
R S
ASKER CERTIFIED SOLUTION
Avatar of vzilka
vzilka

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rajneetbhatia
rajneetbhatia

ASKER

Thanks a lot for your quick reply, but please let me know the command or a method(s) through which I can get this.

I have to use it and finish this issue, so please let me know.
Thanking you in anticipation..
Regards,
R S
Hi. I need to see your code, and exactly what you are trying to do.
Hello Sir,

I am using request.getRealPath() for accessing the file in the application. It is working absolutely fine with tomcat but now when I tried to check my application in weblogic with war deployment then i am unable to use request.getRealPath...

The portion of code is:----

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {

 try
        {
final String strFilePath = request.getRealPath("") + strFileSeparator + "myfile"


...
....
....................

Now here, instead of using getRealPath, I need to use something else, so that I can work with file path..

Thanks,
R S
Try passing a parameter to the servlet in the web.xml. The parameter will include the file location.
I think it may not work as we don't know where(which location), client will put the application folder...
now i am going to try :-----
URL classUrl = new FilePath().getClass().getResource(strClassName);

May be this will work...
Is this file inside the classpath?
That file is not inside the classpath. It is in my main application folder...

c:\myapp\folder1
c:\myapp\web-inf\classes\folder2\file1

Here...

1. myapp is the application name.
2. folder1 contains the file which i want to access.
3. All my classes are in classes\ different folders..

I want that when client put this application (myapp), i must get the path.
(In present case the path which I want is c:\myapp)


Say myapp is saved in d:\Good\Good1\myapp....

then I want the path as d:\Good\Good1\

Thanks a lot...
Regards,
R S
Is it possible for you to give me your MSN or yahoo messenger id, so that I can discuss this with you over there..
It is against the spirit (and the laws) of the EE community.

I will research this for a while, and get it back to you.

I need physical path of my application when deployed through weblogic war...
Sorry, I think the example c:\myapp or d:\Good\... is not an appropriate one.

I have read somewhere that getResource method is an alternative we can use for getting the application path instead of getRealPath..

Please let me know any way out how can i use the same to solve my problem.
Thanks a lot..

Regards,
R S
Here is a reference to a similar discussion run in another forum. This is the best I can think of.
http://www.jguru.com/forums/view.jsp?EID=1038798
Hi bhatia,

I have answered u r problem under WebServers\... look here..
https://www.experts-exchange.com/questions/21003956/Absolute-File-Path-in-weblogic.html

R.K