FileInputStream fs = new FileInputStream("/opt/Abhishek/software/tomcat/webapps/AMS/listpass");
DataInputStream in1 = new DataInputStream(fs);
while (in1.available() !=0)
String str1=in1.readLine();
StringTokenizer st1 = new StringTokenizer(str1);
String node=st1.nextToken();
if (node.equals(sports[i]))
String pass=st1.nextToken();
out.println ("<b>"+sports[i]+" <b>");
out.println("**Your Required Password**");

Hi ,

I have a text file (named listpass in the above code) inside tomcat-webapps folder containing a node name and its password.You could see the path of the text file at the starting line of the code.The Scene behind the program is once the particular node is clicked the password is retreived for the user against the particular node.What i would need is to change the password in the text file once it is retreived. So i would need to find the password that is retreived recently and change that one with a randomnly generated new password in the text file.

So can i do this?Is it possible to search for the string in the text file and replace that with a new one using JSP.For your note i am running all my HTML amd JSP inside the same folder where i have the text file in which the string has to be replaced .

Could anyone give your comments on this please?

You do not want to do this sort of stuff in JSP. Use JSP to give you handle on the file, pass it to servelt that will read file with input stream, process it and display what ever you need on JSP page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.