简体   繁体   English

如何将一个jsp文件的数据用于另一个

[英]How to use data of one jsp file into another

I am new in java. 我是java的新手。 By using this loop i generated data in my demo2.jsp file 通过使用此循环,我在我的demo2.jsp文件中生成数据

//it is demo2.jsp //它是demo2.jsp

 String sLabel
 String labelNames[]=request.getParameterValues("name");
   for(String str: labelNames)
   {
       out.println("<br>");
        sLabel=str;
      out.println(sLabel);
  }

by this i get output :-> software hardware(It is name of checkbox of demo1.jsp) 通过这个我得到输出: - >软件硬件(它是demo1.jsp的复选框的名称)

demo1.jsp demo1.jsp

<form method="post" action="demo2.jsp">
<input type="checkbox" id="software" name="name" value="software"/>software<br>
<input type="checkbox" id="hardware" name="name" value="hardware"/>hardware<br>

I want to use that output(software, hardware) in another jsp page from demo2.jsp. 我想在demo2.jsp的另一个jsp页面中使用该输出(软件,硬件)。 for that i already created one form for POST action 因为我已经为POST动作创建了一个表单

//it is form of demo2.jsp //它是demo2.jsp的形式

<form method="post" action="demo3.jsp">
<table>

<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</form>

In demo3.jsp how should i use output of demo2.jsp is there any kind of JSP inheritance available. 在demo3.jsp中我应该如何使用demo2.jsp的输出是否有任何类型的JSP继承可用。 Please help? 请帮忙?

Use JSP file include to have the same functionality at different JSPs. 使用JSP文件include在不同的JSP上具有相同的功能。

<%@include file="demo2.jsp" %>

in demo3.jsp 在demo3.jsp中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM