Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4030316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:27:21+00:00 2026-05-20T11:27:21+00:00

I have a webservice method @WebMethod public void getCapturedImages(String image) System.out.println( image + image);

  • 0

I have a webservice method

  @WebMethod
 public void getCapturedImages(String image)
 System.out.println(" image " + image);
 }

And my servlet class is :

   public class GetWebApplicationPathServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static ServletContext context;

public static ServletContext getContext() {
    return context;
}

public static void setContext(ServletContext context) {
    GetWebApplicationPathServlet.context = context;
}

/**
 * @see HttpServlet#HttpServlet()
 */
public GetWebApplicationPathServlet() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {

    System.out.println("doGet(HttpServletRequest");
    String path = getServletContext().getRealPath("");

    context = getServletContext();
    String path1 = context.getRealPath("/images");
    System.out.println("path1"+path1);

    /*
     * PrintWriter writer = response.getWriter();
     * writer.println("Application path: " + path);
     */
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void doPost(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
}

can we invoke my servlet class inside that webservice method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:27:21+00:00Added an answer on May 20, 2026 at 11:27 am

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have webservice with one method which recieves xml as string: [WebMethod] public int
In my asmx file, I have [WebMethod] [ScriptMethod] public void Method(IDictionary<string, CustomClass> objectOfCustomClass) {
I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer()
I have the following web service: [ScriptService] public class Handler : WebService { [WebMethod]
If I have a web service method, e.g. [WebMethod] [XmlInclude(typeof(SportsCar)), XmlInclude(typeof(FamilyCar))] public Car[] GetCars()
I have WebService: public class Service1:WebService { private readonly MNConnection _conn; private MNLpu _lpu;
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add
I have created a console application that calls a method on a webservice. I
All the generated webservice-stubs from our backend have an equals-method similar to this one:
I have a webservice that calls a method that returns a generic list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.