It's Pid, and PLEASE stop sending 2 emails, you only need reply to the list.
I gave you an answer, in my first reply.
Acquire the ServletContext, and use that to obtain a usable path from
the webapp relative path you start with.
In a Servlet you can acquire the context from the ServletConfig in the
init method, in a JSP it is already made available.
ServletContext context = ...
String usablePath = context.getRealPath( relativePath );
Rajendra Sakpal wrote:
Hi Peter,
1.> You are right: "/" refers to the root of file system.
2.> What is the right way to make Tomcat write a file in the directory
: "/webapps/Jonathon/WEB-INF/etc/subscriber.txt" ?
I want to avoid specifying an absolute path to the file in my code.
Rajendra
On 3/1/07, Pid <[EMAIL PROTECTED]> wrote:
(Please reply to the list only, I don't need to get the message twice.)
Rajendra Sakpal wrote:
> Am I right to say that "/" refers to the "Tomcat" directory ?
No, you're wrong. Attempting to access "/" would result in an attempt to
write to the root of the filesystem.
> If I mention the file path as "/subscribers.txt", I don't find the
file
in
> the "TOMCAT" directory once the class is instantiated.
That's because you're made the wrong assumption above.
> regards,
> Rajendra
>
>
>
>
> On 3/1/07, Pid <[EMAIL PROTECTED]> wrote:
>>
>> Rajendra Sakpal wrote:
>> > Hi,
>> >
>> > I am using TOMCAT 5.5. I am creating a file in class that is called
>> from a
>> > JSP. However, the relative path that I have specified in the class
>> doesn't
>> > seem to work. The path that I have used is
>> > :"/webapps/Jonathon/WEB-INF/etc/subscriber.txt".
>> >
>> > Can someone please let me know, what is wrong with the relative path
?
>> >
>> > thanks in advance,
>> > Rajendra
>> >
>>
>> If you start the path with a "/" then it's not relative.
>>
>> There are functions to help you locate resources on webapp relative
>> paths.
>>
>> String absolutePath = servletContext.getRealPath( relativePath );
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]