Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to retain the jsp page  RSS feed

 
Shreenivaas Reddy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi geeks!!!

This application is similar to Windows File Search option...
Using the following code im getting a page with the searched files along with links. After clicking a particular file or directory frm the search results...file/directory gets opened and the results page becomes blank...I want to retain that page of search results to click anotherfile/dir...
can any one help me out...thx in advance.

---------------------------------------recursive.jsp--------------
<HTML><body bgcolor="#CCFFFF">
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jdesktop.jdic.desktop.*" %>
<%!
public List lFiles(List list, String dir, String s) {
File dn = new File(dir);
File fList[] = dn.listFiles();

for(int i=0;i<fList.length;i++)
{
if(fList[i].isDirectory())
{
if((fList[i].getName()).contains(s))
{
list.add(fList[i].getAbsolutePath());
System.out.println(list);
}
lFiles(list, fList[i].getAbsolutePath(),s);
}
else if((fList[i].getName()).contains(s))
{
list.add(fList[i].getAbsolutePath());
System.out.println(list);
}
}
return list;
}
%>
<%
String s=request.getParameter("T1");
File f[] = File.listRoots();
for(int i=3;i<=4;i++){
String dir = f[i].getAbsolutePath();
Vector list=new Vector();
lFiles(list, dir,s);
for(int x=0;x<list.size();x++)
{
String sr=(String)list.get(x);
File fl= new File(sr);
%>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; font-family:Verdana; font-size:10pt; color:#CC3300" bordercolor="#CCFFFF" width="100%" id="AutoNumber1" height="12">
<tr>
<td width="30%" height="10%"><a href="DisplayFile.jsp?param1=<%out.println(fl);%>"><br><%out.println(fl.getName());%></a></td>
<td width="70%> height="10%"><%out.println(fl.getParent());%></td>
</tr>
</table>
<%
}
}
%>
</BODY></HTML>
--------------------------------------end of recursive.jsp----------------

---------------DisplayFile.jsp-------------------------------------

<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jdesktop.jdic.desktop.*" %>
<%
File f= new File(request.getParameter("param1"));
Desktop.open(f);
%>

-------------end of DisplayFile.jsp------------------------------
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use a hidden form field to store values of request parameters between loads,
so next load after the form is submitted will regenerate the request parameter for you.
so,

[ July 15, 2006: Message edited by: Travis Hein ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!