Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass one JSP to another JSP?
    text
    copied!<p>I am creating small web apps and I am facing the following problem. I have 2 JSPs and when I click the submit button, it repeats the value every time. What I want is that when I click on the submit button it should give only the corresponding value.</p> <p><strong>index.jsp</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;%@page import="java.io.*,java.util.*" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Class Video&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="second.jsp" method="post"&gt; &lt;table&gt; &lt;% File f=new File("C:/Users/SHAKTI/Desktop/video"); File[] list=f.listFiles(); if(list.length!=0){ String s[]=new String[list.length]; for(int i=0;i&lt;list.length;i++){ s[i]=list[i].toString(); String fi=list[i].getName(); %&gt; &lt;tr&gt;&lt;td&gt;&lt;%=fi %&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="file" value="&lt;%=s[i] %&gt;"&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="play" value="Play"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;%}} else{ %&gt; &lt;tr&gt; &lt;td&gt;There is no any files in the database...&lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>second.jsp</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;form action="" method="post"&gt; &lt;% response.setHeader("Cache-Control","no-cache"); response.setHeader("Pragma","no-cache"); response.setDateHeader ("Expires", 0); String id=request.getParameter("file"); out.println("id = "+id); %&gt; &lt;input type="submit" name="submit" value="submit&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload