SoFunction
Updated on 2025-04-07

A brief analysis of the example of the value transmission problem between JSP pages

This article analyzes the problem of passing values ​​between JSP pages. Share it for your reference, as follows:

The simplest one is to pass the value in the href in the <a> tag.

Write in:

&lt;a href="?name1=value"&gt;&lt;/a&gt;

Then receive in:

<%
   String name2 = new String(("name1").getBytes("ISO-8859-1"),"GBK");
   ("name3",name2);
%>
<input  value="${name3}"/>

This method is relatively simple, but I have also found some problems, such as not loading dynamically, and the value is attached when the page is loading. Let me give you an example.

I have a <select> tag here, which dynamically connects some provinces and cities. Then I want to take the values ​​in <select> and can no longer use href to pass them, because I choose the values ​​in <select> and it is done by myself.

<script>
  var href = "?sd=";
  var getV = function(){
    var add = $("#ad").val();
    href = href + add;
  }
  var h1 = function(){
   = href;
}
</script>
<select  onChange="getV()"></select>
<a  href="#" onClick="hl()" ></a>

I hope this article will be helpful to everyone's JSP programming.