I need to pass a String from one jsp page(say A.jsp) to other(say B.jsp) without displaying the second page(B.jsp).
I have tried setAttribute and getAttribute but null value is received on the B.jsp. Please help
A JSP that doesn't display sounds like it would be better implemented as a servlet. I would have A.jsp submit the String as a request parameter, probably by posting it with a form directed to a URL handled by my B servlet. The B servlet would have a doPost() method, and could do whatever it wanted to do with the String.
By "not displaying", do you mean you want to create a pop-under window or something similar?
Also we cannot help you out unless you TellTheDetails, or PostRealCode.
One possible reason could be incorrect variable name.
request.setAttribute() and request.getAttribute() should solve your problem.
Pay heed to this as well:
So it doesn't matter to you that your following poor practices?
Joined: Mar 01, 2013
I really appreciate the concern but the problem is i have been trying very hard to get the servlet running but its not working and the deadline for the project which i am preparing is just a few days away ,thats why i am trying to get the thing to work.I have definitely kept your advice in mind and will follow it after this project.
Manas, it will be better if you explain the exact scenario so that Javaranchers can help you.
Parameter set is retrieved as null, one of the reasons could be where you have set the parameter & how you are getting it. Have you included jsp page inside another one or you don't at all want that page to be displayed? If you don't want to display it then you should use servlet for that. If servlet is not working then there must be some mistake configuring servlet in deployment descriptor or calling properly mapped servlet.
It will all be anticipated answers. Please share more detail for perfect one.
Joined: Mar 01, 2013
OK got the servlet working heres the scenario and the real problem
I am making a registration page which performs ajax validation on email to check its validity and availablility(from database). The form should not be submitted on click of submit button if email id is invalid Now the problem is that my ajax call is simply displaying valid email or invalid ,and i need it to return true or false so that i could pass this value to form in order to prevent its submission.
I am unable to return any value from servlet KEEPING IN MIND THAT MY PAGE SHOULDN'T REFRESH.(i used request dispatcher but it refreshes the page so setattribute and getattribute wont work here).
heres my jsp code(reginfo.jsp)