REST como passar o parâmetro do caminho vazio?

Estou construindoREST aplicativo da web usandoNetbean 7.1.1 Glassfish 3.1.2

Eu tenho 2 URL:

<code>"http://myPage/resource/getall/name"  (get some data by name)

"http://myPage/resource/getall" (get all data)
</code>

Quando o cliente envia uma solicitação usando o primeiro URL, o servlet abaixo é chamado e executa algum processo.

<code>@Path("getall/{name}")
@GET
@Produces("application/json")
public Object Getall(@PathParam("name") String customerName) {
      //here I want to call SQL if customerName is not null. is it possible???
}
</code>

Mas também quero que a segunda URL chame esse servlet.

Eu pensei que o servlet seria chamado e eu posso apenas verificar customerName == null e, em seguida, chamar SQL diferente e assim por diante.

Mas quando o cliente envia solicitação usando o segundo URL (ou seja, sem o parâmetro path), o servlet não está sendo chamado porque o URL não possui o parâmetro de caminho {name}.

Não é possível chamar o segundo URL e invocar o servlet acima?

Uma alternativa que posso pensar é usarquery parameter:

<code>http://myPage/resource/getall?name=value
</code>

Talvez eu possa analisar e ver se"value" é nulo, em seguida, agir de acordo ..

questionAnswers(2)

yourAnswerToTheQuestion