How does a servlet handle a scenario where it needs to redirect a client to an external website for authentication?
- request.getRequestDispatcher("externalURL").forward()
- request.sendRedirect("externalURL")
- response.forward("externalURL")
- response.sendRedirect("externalURL")
To redirect a client to an external website, a servlet should use response.sendRedirect("externalURL"). This method sends a temporary redirect response to the client, changing the URL in the browser to the specified external URL.
Loading...
Related Quiz
- To apply multiple filters to a single resource, the web.xml file must define a __________ for each filter.
- In the context of web applications, what does 'cache invalidation' refer to?
- To handle a POST request, the HttpServlet class uses the _________ method.
- How can an HTTP servlet differentiate between GET and POST requests?
- How can you retrieve the output of a stored procedure using CallableStatement?