[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Getting servlet context real path.

Hi,


I am building an OSGi container to host an application that was previously hosted on tomcat. Though I have the source code of the application, I do not want to change it.


I have bundled the application and have taken the main servlet class and I register it with HttpService. Now the problem I am facing is that, the application tries to read a config file, from a path. To construct the path for the same, it does something like the following in it's servlet's init method.


   public void init (ServletConfig config) throws ServletException

   {

    ServletContext context = config.getServletContext();

    String path = context.getRealPath(File.separator);

    ..... }



Somehow in my case the getRealPath API always returns null. In a Tomcat servlet container, I believe, this will retrieve the actual filesystem path of the extracted war file. I have the config file which I could bundle along with the jar, but not sure how I can get this to work.


I read another message on the newsgroup about deploying webapps in equinox, where Simon had mentioned that the Servlet Context is created out of the HttpContext that we create and pass to the registerServlet call. I created the same and also registered a resource folder, but got a namespace exception, and the original problem still remained the same.


Any help in this regard would be highly appreciated. Probably it would work if I use Jetty outside OSGi, but I do badly want to get this done within Equinox, for my other requirements.


Had earlier posted the same on the newsgroup, but didn't find any replies. I wanted to know if there is any way I can get this real path set, for my servlet.


Thanks,

Srijith.