For example, you have two servlets (Servlet1 and Servlet2).

In Servlet1, you have a method called getString().

In Servlet2, use

ServletContext context = getServletContext();

to get servlet context of Servlet2. Then use

 Servlet1 servlet = (Servlet1)context.getServlet("Servlet1");

to get the Servlet1 servlet object.

Now, you can Call Servlet1 method from Servlet2 with

 servlet.getString();