• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can i pass integer javascript values into jsp page

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



here is my code i  want to print as NO RESULTS FOUND STATEMENT
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic