1

PS- I have tried using jsp, and the problem I am facing is I am unable to pass the name entered (ex John) and pass it to the jsp scriptlet.

My Current approach:

From jsp I am calling a javascript function and from there I want to pass the name to database (please note that java script and jsp code are in the same page jsp).

<script>
    s=<%=functionCall_To_Jsp_Scriptlet()%>
</script>

Can anyone suggest how can I achieve this?

Ashish Bahl
  • 1,482
  • 1
  • 18
  • 27
Ashish Burnwal
  • 626
  • 8
  • 13

1 Answers1

2

javascript runs at client, meaning in browser, and jsp created on the server, so there is no way to have any scriplets available to js, as at the time js will be working, there will be no scriplets on the page at all

If you want to make some calls to the server, you should be using ajax - it allows to send request to server, from which you can access your database and whatever, take a look at pure ajax and if you want, you can use much easier jquery(or anything else), but you'l have to include jquery library(or any other) to your page

Dmytro Grynets
  • 923
  • 11
  • 29