0

Im creating an email and the email has a url link in it. I want to get the whole url and context so I can redirect the user to where I wish. Right now my code looks like this

String baseURL = request.getScheme() + "://" + request.getServerName()
            + request.getContextPath().concat(content);

is there a way to simplify this and get the same info?

Chris Quibell
  • 339
  • 3
  • 4
  • 18

1 Answers1

0

I guess you mean something like this:

  • getRequestURL() - url without get-parameters
  • getQueryString() - get-parameters

    @Override
    public void service(ServletRequest req, ServletResponse res) 
    throws ServletException, IOException {
       ((HttpServletRequest)req).getRequestURL();
       ((HttpServletRequest)req).getQueryString();
    }
    

see also: HttpServletRequest to complete URL

Community
  • 1
  • 1
Competo
  • 133
  • 1
  • 11