• 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 to let javascript function recgonize java bean?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using javabean and javascript in a jsp page, and having problems passing parameters to javascript function:
-------------------------------------------------------
Problem 1:

------------------------------------
Problem 2:
This is a sample jsp page. I tried two ways(two buttons in the form) to pass a variable in the jsp page to the javascript function, none of them works.
When the first button is pushed, there's no response.
When the second button is pushed, the status bar shows "Script Error!".
Any idea? Thanks!


You need to remove the space in "on click" and "on load"
 
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
You can't mix JSP and Javascript in this way.
JSP runs on the server to format an HTML page (containing your javascript) to send to the browser. Once the page is sent, the JSP and its beans go out of scope. By the time your page displays and your Javascript gets executed, your bean is long gone.
You can use JSP and beans to help create the Javascript that is sent to the page, but that's the extent of their interaction.
hth,
bear
[ September 19, 2003: Message edited by: Bear Bibeault ]
 
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
P.S. If you perform a View Source on your page, you will see that what is sent to the browser is a pure HTML/Javascript page -- no Java, no beans, no JSP.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem 1

Use in the same way you have written in Welcome line.
Problem 2
Use the code updated below
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats correct.
Java part is active at server side only.
HTML/Javascript is active in the browser(client side) only.
 
W Sun
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much! Now I have a better understanding about jsp and javascript(novice in both areas). Also I tried the alert statements and it works perfect (it works in server environment not otherwise). Actually the two problem seems addressed the same point. I guess I can always use the measure in the 2nd one to handle the situation in the 1st one: pass a variable got from the bean. Thanks again.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic