• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass variable from JQuery and get that in JSP

 
gita bal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to load a div by passing a variable using JQuery and get that in JSP

My Code is

${'#MyDiv'}.load('Test.jsp',{Name:"John"},function(response,status,xhr){
});

JSP
----

<c:out value='<=%request.getParameter("Name")%>' />

But I am not getting the div loaded. Please correct what is wrong in this code.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Impossible. The JSP executes on the server to create and send the HTML page to the browser. The JavaScript executes on the browser after the response has been delivered.

Please read this article to understand how JSP operates and why this can never happen.

What are you actually trying to accomplish? If you want the value to appear on the page, you'll need to use JavaScript for that.
 
gita bal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to dynamically load a DIV without form submit by passing arguments at run time. And I have all the necessary objects in JSP as a Spring command object
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't really explain much.

But again, any beans or data that you have in the JSP are gone once the response is sent to the browser.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't really explain much.

But again, any beans or data that you have in the JSP are gone once the response is sent to the browser.

Perhaps you should back up a bit and explain what you are trying to accomplish rather than how you are trying to do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!