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

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

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

c++ - Redefined variable in the other module -