• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing HttpServletRequest from Restful webservice

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to access HTTPServletRequest from Restful webservice. Please let me know on how to do it.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps a little information on how you are implementing the API might be helpful, do you think?

If it's the Jersey project, there's a simple annotation (@Context) that will inject this into a field member.
[ December 19, 2008: Message edited by: Bear Bibeault ]
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Balaji Sundararaju:
I'm trying to access HTTPServletRequest from Restful webservice.



Why? Even with JAX-RS (Jersey) there is no guarantee that the web service is deployed inside a servlet container. Some of the equivalent functionality may be found elsewhere - but what specifically are you looking for?
 
Balaji Sundararaju
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a JAX-RS (Jersey) project and I used the @Context annotation to get hold of the WebServiceContext object.

When I tried accessing the message context from the web service context object I'm getting null.

Please let me know what I'm missing here.

Below is the beans.xml I'm using

 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Balaji Sundararaju:
It is a JAX-RS (Jersey) project



Looks to me that it actually is an Apache CXF JAX-RS project - which as far as I can tell has nothing to do with Jersey.

According to the JSR-311 API (JAX-RS) you should be able to get

javax.ws.rs.core.UriInfo
javax.ws.rs.core.Request
javax.ws.rs.core.HttpHeaders
javax.ws.rs.core.SecurityContext
javax.ws.rs.ext.Providers

from javax.ws.rs.core.Context

javax.xml.ws.WebServiceContext and javax.xml.ws.handler.MessageContext are JAX-WS objects that have no meaning in the JAX-RS context.
[ December 22, 2008: Message edited by: Peer Reynders ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CFX has nothing to do with Jersey with one exception: almost everything. The differences should be minuscule.
reply
    Bookmark Topic Watch Topic
  • New Topic