All'interno di un metodo REST di Jersey, vorrei inoltrare a un altro sito web. Come posso ottenerlo?Jersey URL forwarding
@Path("/")
public class News {
@GET
@Produces(MediaType.TEXT_HTML)
@Path("go/{news_id}")
public String getForwardNews(
@PathParam("news_id") String id) throws Exception {
//how can I make here a forward to "http://somesite.com/news/id" (not redirect)?
return "";
}
}
EDIT:
sto ottenendo l'errore No thread local value in scope for proxy of class $Proxy78
quando si cerca di fare qualcosa di simile:
@Context
HttpServletRequest request;
@Context
HttpServletResponse response;
@Context
ServletContext context;
...
RequestDispatcher dispatcher = context.getRequestDispatcher("url");
dispatcher.forward(request, response);
Sono interessato a un inoltro, non a un reindirizzamento. –
@DorinGrecu è sufficiente aggiungere come accedere al contesto – Dewfy
@Derwy Si prega di consultare la mia domanda modificata, non funziona immediatamente. –