This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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: 5052
135
  • 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
 
Marshal
Posts: 67166
169
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: 3767
40
  • 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
Marshal
Posts: 67166
169
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!