Reputation: 668
Here is what I want to do (this is the way I am doing, if there is any better way please suggest).
Page 1 (jsp) : accept form data. jquery binds the submit for form button. validates input and then submits.
Page 2 (jsp) : static HTML is loaded. Now, using the data submitted as part of form on page1, I want to make a ajax call (jquery) which will populate page2 dynamic part.
<% out.println(request.getParameter("someparam"));%>
above doesnt work inside script tag.
so one option : get these form variables in the jsp. set some hidden variables and then in jquery process those form variable.
Any better option?
Upvotes: 0
Views: 960
Reputation: 376
Correct me if I'm wrong, but seems like you're making an AJAX call to a JSP page and displaying the response/HTML. With the out.println, you seem to be printing a request param of the AJAX call into a script tag within the HTML. It's difficult to say what's wrong without sample code.
Since you're looking for a better alternative to this, I would highly recommend using a client-side templating engine and exchanging only data (json, xml) with the server-side. This would help reduce data transfered as well as improve responsiveness of the front-end.
Consider using Backbone or AngularJS, and refactoring the server-side to exchange data/JSON with the browser.
Upvotes: 1