-
Trying to get ServletContext, request, and response from Web Service
I am trying to get the ServletContext Object (a.k.a. application variable), HttpServletRequest Object (a.k.a. request variable), and the HttpServletResponse Object( a.k.a. response variable) in a Web Service.
I am using Netbeans 6.0 and Tomcat 6.0.14 to do this.
When I look at my web service source, the class doesn't have any way I can get/set/etc. application/request/response/session variables.
How can I access application/request/response/session variables from a web service?
-
Are you using JAX-WS for creating the web service. If so, you can use annotations to inject a WebServiceContext, and then use that to get the request and response objects.
@Resource
private WebServiceContext wsContext;
ServletContext sContext= wsContext.getMessageContext().get(MessageContext.SERVLET_CONTEXT));
HTTpRequest req=wsContext.getMessageContext().get(MessageContext.SERVLET_REQUEST))
HTTPResponse res=wsContext.getMessageContext().get(MessageContext.SERVLET_RESPONSE))
Similar Threads
-
Replies: 1
Last Post: 11-12-2007, 01:56 AM
-
Replies: 2
Last Post: 04-18-2007, 02:34 AM
-
By Steve Hiner in forum .NET
Replies: 7
Last Post: 04-22-2002, 09:19 PM
-
By Robert Lantry in forum .NET
Replies: 278
Last Post: 03-27-2002, 01:00 PM
-
By Michael Welch in forum .NET
Replies: 0
Last Post: 02-26-2002, 10:17 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks