jack
jack

Reputation: 1942

Java: how to write to folder in webapp?

I deployed my webapp in Tomcat, but when I prefix the filename with \ I end up in the root of my server (C) folder, and if I don't prefix it with \ I end up in the bin folder. The former I expected, the latter I didn't. What's the cleanest way to write to a folder in my webapp(userControlWebApp\images) because just doing ..\webapps\ + request.getContextPath() doesn't seem the cleanest way.

Upvotes: 2

Views: 3582

Answers (1)

Bozho
Bozho

Reputation: 597016

Use getServletContext().getRealPath(..)

Upvotes: 8

Related Questions