Returning the URL of a Servlet
HTML documents often need to contain a URL that the client can use to return information to the servlet. The relative URL of the servlet is the path to the context the servlet resides in, followed by the path the servlet occupies within the context.
The following sample generates a relative URL for a servlet:
 
std::string myURL = response.encodeURL(request.getContextPath() +
request.getServletPath());