This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Accessing HttpServletRequest from Restful webservice

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to access HTTPServletRequest from Restful webservice. Please let me know on how to do it.
 
Marshal
Posts: 67414
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
CFX has nothing to do with Jersey with one exception: almost everything. The differences should be minuscule.
 
We noticed he had no friends. So we gave him this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic