Forums de discussion

Use script or form variable in scriptlet

Madasamy P, modifié il y a 7 années.

Use script or form variable in scriptlet

Junior Member Publications: 90 Date d'inscription: 27/07/16 Publications récentes
In myform.jsp

<input type="text" name="editor" id="editor">Editor

I want to use this form textbox value inside scriptlet in same myform.jsp without using button as,

<%String editor=???%>

Or retrieve from javascript variable as,
<script>
var editor = document.getElementById("editor").value;
</script>

retrieve this script variable editor in scriptlet
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: Use script or form variable in scriptlet

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Madasamy P:
In myform.jsp

<input type="text" name="editor" id="editor">Editor

I want to use this form textbox value inside scriptlet in same myform.jsp without using button as,

<%String editor=???%>

Or retrieve from javascript variable as,
<script>
var editor = document.getElementById("editor").value;
</script>

retrieve this script variable editor in scriptlet


Okay, maybe you don't understand this basic premise...

The JSP file lives on the server. It is compiled into a servlet to generate HTML to feed back to the browser. It does not have any access to actual browser entities because it is a completely separate context.

In the browser, it will create entities based on what the HTML says. It has no connection to the server and, in fact, no connection to the JSP because that has since been compiled away long ago.

Two completely different contexts, absolutely zero connection to one another, so no the JSP is never ever going to be able to access a browser-based element in the document.
Madasamy P, modifié il y a 7 années.

RE: Use script or form variable in scriptlet

Junior Member Publications: 90 Date d'inscription: 27/07/16 Publications récentes
Okay ,
Thank you David, I've found another solution
I've using ajax to solve this