• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL content in a DIV tag is not loaded after reloading that div tag  RSS feed

 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone..

I am creating a webapp project , in which i have loaded my JSP page having JSTL tags in a DIV tag successfully but when user clicks on a radio button a jquery fires which loads that perticular div tag , and the html content in that div tag is then loaded again but not the JSTL content..
why its happening?? and solution for this?

Thanks.
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that JSTL runs on the server. So the first step is that a JSP runs, including some JSTL processing, and it generates some HTML including the <div> element you are asking about. Subsequently you replace the contents of that <div> element by an AJAX call, isn't that right? In that case whatever the AJAX call returns is what gets put into the <div>.

So there's no reason to expect the results of the JSTL processing to be preserved by that process. Of course if you wanted them to be preserved, you would have to get the AJAX call to include that processing over again.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul..

Still in doubt, did you mean that i should use those JSTL elements in ajax??
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean that you're not using AJAX and you're asking whether you should, then no. You just called it a "jquery" and didn't say whether you were reloading the whole page via a normal request or whether you were reloading part of the page via AJAX.

I'm saying that if you want that data to appear in the result of your second call, however, you have to write the code to make that happen.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we connect to database using JSTL in jquery?
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course not. JQuery is Javascript and it runs on the client.

I'm getting the feeling that this "jquery" you're asking about doesn't actually send a request to the server. It would help if you said that, especially since I expressed confusion about it twice already.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, jquery is not sending any request to server, its a client side...

what should i do now so, that whenever user click on radio button, the content on the page reloads and show new data from database..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Ajax request can easily reference a servlet controller and its JSP that does whatever you want.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!