title: How do I do an HTTP redirect in Java like res.redirect() in ExpressJS?
body: <p>I am building a Java web framework (for fun; I am not trying to "reinvent the wheel") and I want to have a redirect method like that of <code>res.redirect('/myUrl')</code> in ExpressJS. How can I do so using only the standard Java net packages (<code>java.net</code> and  <code>java.io</code>)? The method simply needs to take a string (but taking more info, such as a request object, is also fine) and redirect a user's request to the specified url with a <code>302</code> code.</p>