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.

1
  • response.sendRedirect("ProjectName/ServletName?param1`=value1") Commented May 21, 2013 at 12:29

3 Answers 3

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)

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.