• 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

Send from JSP via JavaScript to a JBean

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an jsp-page with a form including two dates. The first date is entered from the user, and when the textbox is 'onBlur' the second date should be calculated and entered automatically. I have made the JBean that calculate the second date, and it works fine, but my problem is that I can't send the first date to the JBean! The JBean takes my date-String if I hardcode the date in the jsp!
Anyone who has an idea what to do?
Some code:

The most above works fine! Everything is OK when I hardcode the String parameter in the setBestDate() method but when I try to put a variable instead of the String, I get a NullpointerException:
/Emil
[ July 08, 2003: Message edited by: Emil Karlsson ]
 
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 cannot call a Javabean from Javascript.
The JSP page is executed on the server in order to render the HTML page to send to the browser. This is the point at which any Java on the page is executed -- including the snippet inside your Javascript function.
The HTML page is sent to the browser where, as a result of user action, your Javascript executes. The bean was never on the client, and has probably long been gone on the server.
If you perform a View Source in your browser, you will see that your Javascript function has no mechanism to call the Javabean, but that the HTML sent to page has the result of calling that bean (on the server) embedded in your page.
What it comes down to is this: you have server-side technology, and you have client-side technology, and you cannot mix the two.
hth,
bear
 
Emil Karlsson
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,
I should have realized that from the start.
But now I will always remember.
Emil
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic