jsp中多个按钮实现局部操作的实现,该怎么解决

jsp中多个按钮实现局部操作的实现
      function eat1()
  {      
   
 <%
ResultSet rs1=ServerDao.getRS1(); 
          rs=rs1;  %>    
    initMap();
  }

  function drink1()
  {  
  <%ResultSet rs2=ServerDao.getRS2(); 
rs=rs2;%>
        initMap();
  window.alert("是");  
  }
  
  function play1()
  {  
   <%ResultSet rs3=ServerDao.getRS3(); 
  
   rs=rs3;%>
   
  initMap();

  }
  
  function shopp()
  { 
   <%ResultSet rs4=ServerDao.getRS4(); 
   rs=rs4%>
 initMap();
window.alert(4);
  }
  
  function nice()
  { 
 <%ResultSet rs5=ServerDao.getRS5(); %>
     rs=rs5;
  initMap(); 

  }    
上面为<script>标签内的内容
下面是表单内部的按钮
<input type="button" name="eat" value="吃" style="background:red;color:blue;" onClick="eat1()"/>
<input type="button" name="drink" value="喝" style="background:green;color:white;" onClick="drink1()"/>
<input type="button" name="play" value="玩" style="background:black;color:white;" onClick="play1()"/>
<input type="button" name="shopping" value="购" style="background:yellow;" onClick="shopp()"/>
<input type="button" name="all" value="全部" style="background:pink;"  onClick="nice()"/>

由于jsp里面的java代码是在服务器中执行,所以我按钮实现的function()函数内部的<%%>内的代码不会因为onclick的执行
而被选择执行。
写到servlet中的session中,然后实现request.getRequestDispatch("/localMap.jsp").forward(request,response);
又会把之前页面的别的选定的东西又初始化了。所以很苦恼。
------解决方案--------------------
是不是你重新加载,以前的数据都没保存,
------解决方案--------------------
后端只讲数据发送给前端  前端组织页面 
你看下最后生成的数据是什么
------解决方案--------------------
你是要实现局部刷新吧,在页面加个<iframe name="name" id="id"></iframe>,form里面加上 target="id"即iframe的id,这样表单每次提交时实际刷新的是iframe,不会刷新整个表单,之后去掉servlet中的
request.getRequestDispatch("/localMap.jsp").forward(request,response);
加上
response.getWriter().write(“<script>parent.callback('"+obj+"')</script>"); 
//js代码,获取回显处理的数据、

function callback(obj){        
 }  
局部刷新大致就是这么个思路,具体的代码你完善就可以了