Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how can i pass integer javascript values into jsp page

 
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: 6594
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • 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: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
Master Rancher
Posts: 4666
49
  • 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: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic