Pegar o "cidade" do http://localhost:8080/cidade

Olá pessoal o título diz tudo…

Como faço para pegar o “cidade” do do http://localhost:8080/cidade no JSP.

Sem usar servlet. Apenas pegar o nome literal… exemplo http://localhost:8080/saopaulo

Eu poder pegar o saopaulo para fazer o select.

Obrigado.

Tente assim:

[code]String url=“http://localhost:8080/saopaulo”;
String arrURL=url.split("/");

int len=arrURL.length;

//A parte procurada:
String procurada=arrURL[len-1];
[/code]

[quote=Roger75]Tente assim:

[code]String url=“http://localhost:8080/saopaulo”;
String arrURL=url.split("/");

int len=arrURL.length;

//A parte procurada:
String procurada=arrURL[len-1];
[/code][/quote]

viu, vc ta brincando né. eu ri disso ai.

Ele quer pegar dinamico não fixo…

A idéia é pegar dinâmico. E também queria saber como quando for chamado http://localhost:8080/cidade ele entrar no jsp principal.jsp e fazer a consulta pela cidade.

Pelo request você consegue pegar algumas informações da url:

request.getServletPath() request.getServerName()

Dê uma Lida em REST