Can we invoke a servlet inside a webservice method?

You can issue an include using the path that would be used to invoke the servlet from a direct HTTP request.

You can issue an include using the path that would be used to invoke the servlet from a direct HTTP request: @Resource private WebServiceContext context; private void invokeServlet() throws IOException, ServletException { ServletContext servletContext = (ServletContext) context. GetMessageContext(). Get(MessageContext.

SERVLET_CONTEXT); HttpServletRequest request = (HttpServletRequest) context. GetMessageContext(). Get(MessageContext.

SERVLET_REQUEST); HttpServletResponse response = (HttpServletResponse) context. GetMessageContext(). Get(MessageContext.

SERVLET_RESPONSE); servletContext. GetRequestDispatcher("/path/to/servlet"). Include(request, response); } See also: How can I access the ServletContext from within a JAX-WS web service?

My context returns null value.. give a solution please – jennifer Mar 4 at 9:15 I created webservices using the eclipse having JboSS toolkit. Also by using the WebServiceContext annotation the context value is null.. – jennifer Mar 4 at 9:24 @jennifer According to a comment in stackoverflow. Com/questions/261348/… you should try removing common-annotations.

Jar in WEB-INF/lib as this causes a classloader conflict. Cannot investigate further at the moment. – Stefano Travelli Mar 4 at 11:11.

In order to call the class you would have to create an instance of it, construct the HttpServletRequest object yourself and then call it. Or you could make an Http request to it from the web service. Both solutions aren't recommended.

You are better off creating a class that will implement the desired functionality an call it from both places.

You might be able to, but it's problematic. What you need to do is create a method that both can call to perform the functionality you require.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions