• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need an instance of ServletConfig in WebService  RSS feed

 
Paul Lessard
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, why I need the instance: We have several backend business logic components that were built for J2EE web applications, which essentially are black boxes that just work... provided you give them an instance of your ServletConfig. Specifically, the methods getServletContext().getRealPath() is of interest to these components.
I have tried having my web service extend HttpServlet and having it load on startup so I can capture the ServletConfig from the init(ServletConfig) method in a static class level variable. I've also tried just calling the getServletConfig() from inside the web service logic. Both result in NullPointer exceptions when I call getRealPath() in my tests. However, I should mention that the ServletConfig and the ServletContext are both not null, as per != null tests.
My environment is currently Tomcat 5.x and the eventual goal is WebSphere 5.x.
I looking for one of two things: 1) A valid ServletConfig so I can use the same black box components that our servlets use without rewriting them; 2) To get the RealPath of the web service. Option 1 is the preferable method, as option 2 will result in many man hours of rewriting and appending little bits and pieces to the black box components to get everything working.
Thank you,
Paul Lessard
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!