• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

updating a table on jsp using jquery complex scenario

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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




 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mention jQuery and then proceed to use no jQuery at all in your code. What's up with that?

Unless I miss what you are trying to do, your problem is solved with a single use of the jQuery .load() method:
 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried it again and it worked. Looks like i was passing invalid parameters the first time.Thanks again
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic