I am requesting a servlet to get a String value , for that I am doing like this.
function histryTraceFun(){
$.get('SendNodeHistoryTracing?node='+temp,function(response){
alert("in response "+response); // Here I am not getting response
});
}
in servlet doGet() method I have,
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
String node=request.getParameter("node");
}
The controll will come to servlet but not returning to JSP , in callback function alert the value of variable response
is not comming. And actually I didnot understand how response.setContentType()
work. can any one help me in this please. Thank you.
Try this to send control back to your page :
RequestDispatcher dispatcher = request.getRequestDispatcher("/yourPage.html");
dispatcher.forward(request, response);
You can also add data in response :
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("your_response");
RequestDispatcher dispatcher = request.getRequestDispatcher("/yourPage.html");
dispatcher.forward(request, response);
Still problem then post me.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments