I would like to get a HTTPServletResponse of an Action on a jsp page, but i don't know how...
My ajax call on the jsp:
jQuery.ajax({
url : 'actionURL',
type: "POST",
data : {input: "example"},
dataType: "html",
success: function(response) {
alert(response);
if (response == 1) {
jQuery("#message").html("done!");
}
}
});
My Action class:
public class MyAction implements ServletResponseAware {
public final String execute() throws IOException {
String return_code = "1";
try {
something...
} catch (Exception e) {
return_code = "0";
}
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write(return_code);
return "success";
}
}
How can i access only the return_code variable on jsp? Because now in the script alerts the whole page HTML code as response... Thanks!