I have a jsp file: validate.jsp-
var rollNo=document.forms["result_form"]["studentRollno"].value;
var name=document.forms["result_form"]["studentName"].value;
$("#student_result").load("result.jsp?rollNo="+rollNo+"&name="+name);
As you can see, I am passing two data rollNo and name to result.jsp
Now in result.jsp:
String rollNo=request.getParameter("rollNo");
String name=request.getParameter("name");
out.print("Your roll number is: "+rollNo+"<br>");
out.print("Your name is: "+name);
Everything is fine. When I give rollNo=5 and name=something(in the textboxes in validate.jsp), result.jsp loads displaying the message as I intended. The only problem is, it works only as long as I don’t give spaces in the textboxes!! For ex: If I enter name=”Stalin”, it works but for name=”Stalin ” and “Stalin Subramanaim”, it doesn’t work. result.jsp page doesn’t load! Please help..!!
You are building the parameters by hand which can result in an improperly formatted query string. You should use the jQuery helper
$.paramto solve this: