JSP and interactive data JavaScirpt
Abstract: JSP and interactive data JavaScirpt
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="277" height="86" align="center" valign="top"> </ td> <td width="407" valign="top">
For WEB procedures, the front-end (JavaScript) and back-end (JSP / Servlet) is not shared data can only be a back-end process (JSP) to output data, generating pages to the front pages this time generation The JavaScript code may be only so-called jsp data. Similarly, JavaScript, only to the data submitted to the backend JSP code, JSP process can be JavaScript data.
How to achieve it in the pages of the use of JavaScript in jsp data or jsp pages use the JavaScript data?
First, the JavaScript pages of data submitted to the background of how the procedures jsp
â‘ can JavaScript data to xxx.JSP? Var1 = aaa & var2 = bbb in the form of the parameters passed as a URL JSP procedures used at this time jsp
<% String strVar1 = request.getParameter ( "var1 ");%> can get to the JavaScript scripting transfer from the data;
â‘¡ form through the use of JavaScript added to hide domain information, and then use the form to the way the data transfer to the JSP procedures.
</ Td> </ tr> </ table>
Second, in the pages of JavaScript how to use the data behind the data JSP procedures
This relatively simple, and used directly in the JavaScript scripting <strVar1%% => jsp procedures will be in the data transfer to use the JavaScript scripting.
Third, reference to the following examples:
1, test.jsp
<% @ Page contentType = "text / html; gb2312 charset ="%>
<%
String s1 = "Hello";
String s2 = "World!";
%>
<script Language="JavaScript">
/************************************************* The following
* JavaScript scripts, placed in the position of any of pages can be
* Insertclick () function to transfer access to JSP pages in the variable s1,
* JavaScript can then modify the value of this variable, and through the
* Post to the way JSP procedures to use.
************************************************** *************/
Function insertclick () (
Var1 ="<%= s1%> ";
Document.forms [ "insertForm"]. Mc.value var1 = + document.forms [ "insertForm"]. Mc.value;
Document.insertForm.submit ();
)
/ /
</ Script>
<form Name="insertForm" method="post" action="get.jsp">
<Input type = "hidden" name = "mc" value ="<%= s2%> ">
<input Type="button" value="æäº¤" onclick="insertclick()">
</ Form>
2, get.jsp
<%
String strVar1 = request.getParameter ( "mc");
Out.print (strVar1);
%>
</ Td> </ tr> <tr>
↑ Back
Tags: JSP






