I have a web service made in java in the Netbeans IDE, in which I want to bring back a url that contains special characters like the following + url example: link
When I use the get method to return the value to consult (ie the name of the course "course-v1% 3AU + AIRPOLLUTION + 2017_ENE"), it returns the following: course-v1: U AIRPOLLUTION 2017_ENE making the + signs appear as blank spaces. How can I make the url that returns the get method include the signs + that is (course-v1: U + AIRPOLLUTION + 2017_ENE)
Code
@GET
@Path("/buscarporcurso")
@Produces(MediaType.APPLICATION_JSON)
public Response getBycourseDisplayName(@QueryParam("courseDisplayName") String curso, @QueryParam("callback") String callback) throws UnsupportedEncodingException {
EdxTrackEventDao obj = new EdxTrackEventDao();
EdxTrackEvent c = null;
try{
c = obj.buscar("courseDisplayName", curso);
}catch( Exception ex){
System.out.println(ex.getMessage());
}
JSONArray array = new JSONArray();
array.add(c.getAnonScreenName());
Gson g = new Gson();
String formatoJSON = g.toJson(array);
if (callback != null) {
return Response.ok(callback + "(" + formatoJSON + ")", "application/json;charset=UTF-8").status(Response.Status.OK).build();
}
return Response.ok(formatoJSON, "application/json;charset=UTF-8").status(Response.Status.OK).build();
}