0

I am newbie in UI i.e. front end. I am using Javascript and JSP. I need to perform the below task.

I have a textarea in jsp page which gets populated from a text file which i read using Java. Now, I want to empty the text area and that text file on clicking a button. Emptying the file is not an issue only i don't get how to transfer call from jsp file to Servlet on clicking that button.

Please help.

Anand
  • 20,708
  • 48
  • 131
  • 198

3 Answers3

2

There are two ways to do this:

the classical way is form submission:

http://www.tutorialspoint.com/jsp/jsp_form_processing.htm

e.g. you embedded a form in your jsp page that will send the data to your server when submitted.

the second way is via ajax

https://en.wikipedia.org/wiki/Ajax_(programming)

I would suggest you google for the basics of form submission (which is not jsp specific) or doing ajax requests with javascript (with a library, for example jquery)

rawphl
  • 331
  • 2
  • 8
0

there are two ways one by jsp and another by javascript

if the button is submit type and if you are using a form then

if the button is simple a button then

function x() { window.location.replace("servlet name"); }

please tell me if you have any doubts

0

There are many ways to do so.

  1. use jquery and ajax, its so easy.

similar question here: jQuery Ajax POST example with PHP

you can find documentation here http://api.jquery.com/jQuery.ajax/

  1. or use JSNI.

    https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsJSNI

Community
  • 1
  • 1