Wednesday, December 3, 2014

figure out what is at the URL line in Java

This suggests fishing out what is in the URL line from a .jsp page like so...

String uri = request.getScheme() + "://" + request.getServerName() +
      ":" + request.getServerPort() + request.getRequestURI() + "?" +
      request.getQueryString();

 
 

...and that seems to work really good. If you are wondering what "request" is, it seems to be per this a HttpServletRequest and it seems to just work in a .jsp page. When I attempted to wire it up to work (as suggested in the second stack overflow link in this posting) NetBeans IDE 8.0.1 told me:

variable request is already defined in method mergedScriptlets(HttpServletRequest, HttpSession, ServletContext, JspWriter, ServletConfig, JspContext, Object, PageContext, Throwable)

No comments:

Post a Comment