• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
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
 
Saloon Keeper
Posts: 4694
117
  • 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
 
Author and ninkuma
Marshal
Posts: 66786
168
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
 
Rancher
Posts: 3596
39
  • 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: 66786
168
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!