0

I need to get the text a user enters in a textarea, in a script from JSP. I tried this code but get null value:

<label for="userText"></label>
<textarea name="userText" id="userText">text edited by the user</textarea>
<button onclick="myFunction()">Ok</button>

function myFunction() {
    <%System.out.print(request.getParameter("userText"));%>
}

I can i get it?

Vimal
  • 1,140
  • 1
  • 12
  • 26
tecn603
  • 211
  • 5
  • 14

1 Answers1

0

You will have to use Java Script for this

var message = $('textarea#userText').val();
Rajendra Gupta
  • 381
  • 1
  • 16
  • I need to use a user text on JSP server side – tecn603 Nov 20 '19 at 10:08
  • You will have to get this value and make a ajax call to send it to the server side – Rajendra Gupta Nov 20 '19 at 10:11
  • I tried this code but do nothing: `` I don't know Ajax well – tecn603 Nov 20 '19 at 10:55
  • put an javascript alert and check if you are getting the message, the use this link to make the ajax request https://stackoverflow.com/questions/9436534/ajax-tutorial-for-post-and-get and put a debug point on your servlet class to see if you are able to get the message there. – Rajendra Gupta Nov 20 '19 at 11:44