-1

I use servlets 3 and jsp and this is configuration question.

In servlet for url 'mydomain.com/builder/', I have to generate random ID and append it to my current url, like:

'mydomain.com/builder/randomID0'

Next, I want to redirect user to this url. So I need to match this new url to existent jsp page.

How to do this in servlet 3?

Jay Smith
  • 2,331
  • 3
  • 16
  • 27

1 Answers1

0

You should get the current url as a String object via the getRequestURI() method of the HTTPServletRequest class, then generate the randomID String object and concatenate one another into a newUrl String.

Then use sendRedirect(newUrl) of the HTTPServletResponse class in order to let the user navigate to that new url.

Emanuele Giona
  • 781
  • 1
  • 8
  • 20