users@glassfish.java.net

Re: File path in a web application

From: <glassfish_at_javadesktop.org>
Date: Fri, 01 Feb 2008 10:07:24 PST

I've found the solution: inject the WebServiceContext.

@WebService
public class MyService {

@Resource
private WebServiceContext wsContext;

@WebMethod
public String myMethod(){
try{
  MessageContext mc=wsContext.getMessageContext();
  ServletContext sc=(ServletContext)mc.get(MessageContext.SERVLET_CONTEXT);

  String path=sc.getRealPath("/resources/myMessageTemplate");
}catch(Exception e){
//TODO
}
}
}
[Message sent by forum member 'aperezymadrid' (aperezymadrid)]

http://forums.java.net/jive/thread.jspa?messageID=257042