java - programmatically get base url from inside google app engine endpoint method -


I am creating a Google Appengine Endpoint API. In one endpoint method, I have to find the base url. How can I do this in Java? According to the document, you can type in injection API methods; For example, if you use the HTTPServletRequest object as your API You can inject the method

After you have the request object, you can get the base URL as necessary. For example

  stringbuffer url = req.getRequestURL (); String uri = rick Jatrquensturai (); String ctx = req.getContextPath (); String base = url.substring (0, url.length () - uri.length () + ctx.length ()) + "/";    

Comments

Popular posts from this blog

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -

sql - PostgreSQL automatically update row at specific date -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -