This is my jsp code for saving back the data to .properties file after editing. i used 2 Linked properties as one LinkedProperties pro is to get the data from the path and the other one to get attribute (eg: id, name, age, gender etc.) from default .properties file so that i don't have to hard code everything in every page:

String path = request.getParameter("path");
	System.out.println(path);
	File dir = new File(path);
	FileInputStream in = new FileInputStream(dir);
	LinkedProperties pro = new LinkedProperties();
	pro.load(in);
	Enumeration em = pro.keys();
			
	//default file
	File d_dir = new File("C:/workspace_indigo/Configuration/WebContent/default.properties");
	LinkedProperties d_pro = new LinkedProperties();
	FileInputStream d_in = new FileInputStream(d_dir);
	d_pro.load(d_in);
	Enumeration ems = d_pro.keys();
			
	//save to file.
			if (request.getParameter("id") != null) {
				while (ems.hasMoreElements()){
					String str = (String) ems.nextElement();
					pro.setProperty(str, request.getParameter(str));	
				}
				pro.store(new FileOutputStream(path), null);%>
				
			<script type="text/javascript">
				alert("Change Saved sucessfully.");
				//window.location.href="List_of_Repo.jsp";
			</script>
				
		<% 	}
			d_pro.clear();
			d_in.close();
                        pro.clear();
		        in.close();

I can save the file back into the corresponding .properties file but the problem is i cannot delete the file after editing is save. The error message is the file is still in used.

help me.

this discussion board is so not helping... :(

Did you ever considered that is not 24/7 coding solution, or that perhaps people do not want to do anything with coders that insist to do stuff directly from JSP or perhaps people do not know or are not interested.
Count me in the group "do not want to touch code with direct JSP manipulation". Word of advice, it is possible, I do use it often when I change CSS settings of my blog that is run on open source project called Pebble. There is your solution, go through code and find you solution there...

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.