Hi initially i thought that i could update a whole table in a jsp using jquery.My original approach was as follows
in my jsp i had somethig like this
I was receiving the asynch response asynchronously and then replacing the html of the div section that the table was in. Using the following way
Now the problem is the code would definitely work for a raw HTML code like this passed from a servlet
but what should i do if the table that i was intending to replace in the jsp was originaly built up with a lot of loop JSTL and EL which actually got translated to HTML by the jasper translator.
What I am trying to say is that my servlet has the same object which it could pass to the jsp so that it could generate the table again (saving me the trouble of writing raw html) but the problem is this time its an asynchronous call an I''ll have to do with the raw html which would be too tedious and aggravating for me to write. I waned to know is there any way in which I could actually get the translated code and then out it to the jsp. Something like this
I am sorry I think i didnt explain it properly .. here is what i wanted
Step1:PageA.jsp(does an asynch call to servletA passing certain parameters)------------------------------>Step2: ServletA(processes the parameters received,creates an object and sets it in the attribute then it calls another jsp page to generate a table on basis of that object. The servlet extracts the html from that jsp page , stores it in a string and writes it back to PageA.jsp)
Your solution
$('#elementContainingTable').load('/url/that/generates/table');
I believe just loads a portion of a particular page into a specific section.Which is not what i am looking for
Let me recap , the servletA first receives the parameters asynchronously from pageA.jsp on the basis of which it generates an object and calls the next jsp page.The next jsp page will construct a table on the basis of the object received from the servlet. In your method the page will be called however since it does not have the object necessary to generate the table.The table will be empty. I hope all that i said makes some sense.
Rajesh Khan wrote:In your method the page will be called however since it does not have the object necessary to generate the table.The table will be empty.
Not at all. The URL that the Ajax call hits would be the servlet that preps the data and then forwards to the JSP for formatting. I don't see what the problem is -- I do this all the time.
Rajesh Khan
Ranch Hand
Joined: Oct 16, 2011
Posts: 230
posted
0
Tried it again and it worked. Looks like i was passing invalid parameters the first time.Thanks again