facebook

JAX-RS Web Service – How to get the ServletContext

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #307489 Reply

    mfkilgore
    Member

    I have followed the tutorial to create a web service (Developing REST Web Services Tutorial). This works as expected and I have a restful web service working. To build my service properly (initialize) I need access to the ServletContext to access the path to WEB-INF and resources I need there.

    I tried adding @Resource WebServiceContext wsContext; to then use the wsContext to access the ServletContext but the wsContext is always null.

    It would appear this is not the correct approach. What is the best way to resolve this and get the access I need?

    Thanks in advance

    #307542 Reply

    mfkilgore
    Member

    I was hoping to hear back before the weekend on this if possible. It appears to be a very common need and I assume I am missing something basic. That is why I started with the tutorial and only added one change for the @Resource and a reference to use it…

    Thanks

    #307584 Reply

    Brian Fernandes
    Moderator

    I believe you need the @Context annotation instead, something like

    @javax.ws.rs.core.Context 
    ServletContext context;

    There are a few additional examples here: http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features

    Hope this helps

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: JAX-RS Web Service – How to get the ServletContext

You must be logged in to post in the forum log in