I have a class of following format:

```
public class Process extends HttpServlet {
    @Override
protected void doGet(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException,IOException {
    // TODO Auto-generated method stub
    doPost(request, response);
}

@Override
protected void doPost(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException,IOException {
 if ((request.getParameter("choice")==null)&&(request.getParameter("term")!=null)){
   Bean b=new Bean(request.getParameter("term"));
  request.setAttribute("bean", b);
  request.getRequestDispatcher("result.jsp").forward(request, response);
  }
  //....many other if checks to dispatch the request to appropriate jsp pages
 }}

```

Now I want to convert this class into an API.I want to retain the functionality of it dispatching to appropriate pages, as thats how it functions for my application.But I want to be able to provide external access so that others can also make use of my application.
Right now this can be accessed by <http://mytest.com/Process?term=test>, and once i access it like that it forwards the response to result.jsp. The response is basically my other class(Bean) object and result.jsp uses the object to call its various get methods to retrieve data.

For this to be available externally I am thinking of introducing another parameter in URL, so that from external page people can send a request on <http://mytest.com/Process?term=test&request=api> and then I can check parameter to identify if its from external place, but i dunno how to send back response to the external client and if its a good idea to send the object to the client, since I don't think they will have access to class.