net user
net user

Reputation: 593

How create a file inside WEB-INF folder from servlet?

I am new to servlet world.. I want create a file inside WEB-INF (or WEB-INF/some_folder) folder from servlet. and this should be done at server-startup. Please let me know how can it be done.

Thanks in advance.

Upvotes: 1

Views: 3869

Answers (1)

Point: you can access files from servlets but cant access them from web container

String filename = "/WEB-INF/somefile.xml" ;
ServletContext context = this.getServlet().getServletContext();
String pathname =context.getRealPath(filename); 

Upvotes: 2

Related Questions