DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    1

    Question 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?

  2. #2
    Join Date
    Feb 2008
    Posts
    1
    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

  1. Replies: 1
    Last Post: 11-12-2007, 01:56 AM
  2. Replies: 2
    Last Post: 04-18-2007, 02:34 AM
  3. Can a Delegate be passed to a Web Service?
    By Steve Hiner in forum .NET
    Replies: 7
    Last Post: 04-22-2002, 09:19 PM
  4. Re: Do consumers even want web services?
    By Robert Lantry in forum .NET
    Replies: 278
    Last Post: 03-27-2002, 01:00 PM
  5. Replies: 0
    Last Post: 02-26-2002, 10:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links