Originariamente inviato da Lucked
Ciao a tutti,
ho una servlet java, che nel metodo doGet gli faccio fare:

dispatcher = getServletContext().getRequestDispatcher("/login.jsp");
if(dispatcher != null){
dispatcher.forward(req,res);
}

viene richiamata da una pagina jsp in cui c'è questo link:
[Log-out]

il problema è che...va bene ci va alla pagina login.jsp ma sulla barra del browser..rimane:

http://localhost:8080/servlet/Contro...ction=invalida

funziona tutto bene...ma mi chiedevo...è normale?
Si, in quanto fai un forward non un redirect

A Controller servlet may perform either a forward or a redirect operation at the end of processing a request.

Forward

* forward is performed internally by the servlet
* the browser is completely unaware that it has taken place, so its original URL remains intact
* any browser reload will simple repeat the original request, with the original URL

Redirect

* redirect is a two step process, where the web application instructs the browser to fetch a second URL, which differs from the original
* a browser reload of the second URL will not repeat the original request, but will rather fetch the second URL
* redirect is always slower than a forward, since it requires a second browser request
* beans placed in the original request scope are not available to the second request