• 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

Using JavaScript within JSP

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have a jsp page, in this page I have declared a method lets call it writeToFile. Now I have also created a series of inputs (html) that contain or can contain data. What I am trying to do is to create a scenario where the writeToFile method in my jsp page can take data from the input tags available on the page. ie. the contents of the input tags can be used in the writeToFile method. Is this possible? and if so , how do I go about it.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this method is a javascript method use text.value to retrive the value of the controls.

onsubmit invoke this method!!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming "writeToFile" is written in JavaScript (so you intend it be processed clientside), each form element in your HTML has attributes you can access to get their value. An <input type="text" /> element for example has a "value" property which equals whatever its value is. You can process this value at any time, presuming a suitable event has happened to fire your JavaScript function. lekha phijo gives you one choice, there are a whole bunch available (see here - being aware some of these will be IE only).

Given the name of your possibly-JavaScript function, I probably should warn you that you cannot write to a file using JavaScript.

If writeToFile is a method written in Java and to be run serverside, then you just need to process the contents of the request as you would any value passed as the result of a form submission.
[ July 05, 2005: Message edited by: Paul Sturrock ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic