• Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i pass integer javascript values into jsp page  RSS feed

 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



here is my code i  want to print as NO RESULTS FOUND STATEMENT
 
Tim Moores
Saloon Keeper
Posts: 3967
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean to "pass a JavaScript value to a JSP page"? JSPs are executed at the server, long before the JavaScript is executed on the client.

Or do you want to manipulate the HTML via JavaScript? If so, that's what the document.write method does: http://www.mediacollege.com/internet/javascript/basic/document-write.html
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66264
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To understand how JSP operates, please see this article.

document.write isn't the right approach: after page load, it will replace, rather than augment a page. A better approach to augment the DOM is to use the DOM API -- preferably via jQuery which not only makes it easier, but eliminates browser-specific nonsense.

If however, you really need to get a front-end value back to the server, you'll need to submit a request back to the server, either through a form submission or Ajax.
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I want to display "NO RESULTS FOUND" ...
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Dave Tolls
Ranch Foreman
Posts: 3011
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That Java code should be not be in a JSP page.
It should be called via a servlet.
At the moment you have everything piled onto one page, server logic and client logic, and I suspect you are confusing yourself about what gets executed where.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66264
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's another article you should read regarding the why and how of organizing your code: this article

Rule of thumb: keep the JSPs as stupid as possible.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!