How to write .properties file from jsp

How to write .properties file from jsp

Hi i new to java i stuck here please help me... my problem is "I wrote a class to write the .properties file it is working fine when i run through normal application.But the problem is when i am using this in jsp means i have create object to this class and used it in my jsp but Iam unble to modify/write the .properties file and Iam not getting any errors".

what is the problem please explain and give if any solution to implement/write .properties file from jsp.

Regards, Venkatesh Gurram.

View Answers

November 24, 2010 at 1:20 PM

Hi Friend,

Try the following code:

1)properties.jsp:

<form method="post" action="create.jsp">
<table>
<tr><td>Enter File Name:</td><td><input type="text" name="f">.properties</td></tr>
<tr><td>Enter Key:</td><td><input type="text" name="key"></td></tr>
<tr><td>Enter Value:</td><td><input type="text" name="value"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>

2)create.jsp:

<%@page import="java.io.*,java.util.*"%>
<%
String str = request.getParameter("f");
System.out.println(str);
if(!str.equals(null)){
    try{  
        Properties p = new Properties();
        File file=new File("C:/"+str+".properties");
         p.store(new FileOutputStream(file),null);
          String key = request.getParameter("key");
          String val = request.getParameter("value");

          p.setProperty(key, val);
           p.store(new FileOutputStream(file),null);
          System.out.println("Operation completly successfuly!");
        }

    catch(IOException e){
    System.out.println(e.getMessage());
    }
}
 %>

Thanks


March 26, 2013 at 11:46 AM

Below is a simple code package com;

import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties;

public class PropertiesFile { static Properties prop;

public PropertiesFile() throws IOException {

    prop = new Properties();
    FileInputStream filestream = null;
    try {
        filestream = new FileInputStream("E://Selenium//workspace//Sample Test//src//com//sample1.properties");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    prop.load(filestream);
}
public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
        PropertiesFile sp= new PropertiesFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String name= prop.getProperty("name");
    System.out.println(name);
}

}









Related Tutorials/Questions & Answers:
How to write .properties file from jsp
How to write .properties file from jsp  Hi i new to java i stuck here... to implement/write .properties file from jsp. Regards, Venkatesh Gurram.ADS... it in my jsp but Iam unble to modify/write the .properties file and Iam not getting
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
Advertisements
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
how to write file from FileInputStream
how to write file from FileInputStream  Hi, How to Write a file.... Thanks,   Hi, For Write to file from FileInputStream in java you may use... this website Write to file from FileInputStream in java
write to file from servlet - JSP-Servlet
write to file from servlet  Hi, I have a jsp file where I input... right data on the web site. I am also trying to write this data to file... JSP Page //<
How to write properties file in java
Write properties file in java In this example we will discuss how to write property file in java. In this example We have write data to properties file. The properties file has fundamentally used to store the data configuration data
Java Write to properties file
Java Write to properties file In this section, you will learn how to write data to properties file.  The properties file is basically used to store.... Here we are going to create a .properties file and write data
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
how to write to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
How to write file from inputstream in java
How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link... link to your query "How to Write to inputStream in Java". This is good
Loading properties from a XML file
Loading properties from a XML file       This Example shows you how to Load properties from a XML... parsers. Some of the methods used for loading properties from a XML file
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
write xml file with jsp useBean - JSP-Servlet
write xml file with jsp useBean  how to write into xml files with jsp... an org.w3c.dom.Document from XML. Save the xml file at bin file of C:\apache-tomat-5.5.23\bin\. Read for more information, http://www.roseindia.net/jsp/jdo
Java Write To File From FileInputStream
Java Write To File From FileInputStream In this tutorial you will learn how to write to file from FileInputStream. Write to file from FileInputStream in java... input bytes from a file or can say it reads the streams of bytes. And to write
Java Write To File From String
Java Write To File From String In this tutorial you will learn how to write to file from string. Write to file from string using java at first we will have...;This example demonstrates you how to write a file from string"; File file
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file . look at the line with code-> Statement st=con.createStatement(); in the below example. the error is "cannot convert from java.sql.Statement
Version of com.internetitem>write-properties-file-maven-plugin dependency
List of Version of com.internetitem>write-properties-file-maven-plugin dependency
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
how to generate the pdf file with scroolbar from jsp age - JSP-Servlet
how to generate the pdf file with scroolbar from jsp age  How to generate the pdf file with scroolbar from jsp.i am not able to see the all the columns in pdf file now .it is very urgent for me plz help
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... how to write in a file."); br.close(); } catch (Exception e) { System.err.println
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... bufferedWriter object to write in the file. For more details and examples related to How to write in File of Java Program
use properties file to connect to the database in jsp..
use properties file to connect to the database in jsp..  How to use properties file to connect jsp code with database ..........   Here is a jsp code that connects to database using properties file. <%@page import
Maven Repository/Dependency: com.internetitem | write-properties-file-maven-plugin
Maven Repository/Dependency of Group ID com.internetitem and Artifact ID write-properties-file-maven-plugin. Latest version of com.internetitem:write-properties-file-maven-plugin dependencies. # Version
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... to a file from Java program. To write the Java Write To File we will use two... and execute it, this will write "Hello Java" into out.txt file. While creating
Java Read username, password and port from properties file
Java Read username, password and port from properties file In this section... the properties file and display the data from the database. Now to load the data from... to a stream or loaded from a stream using the properties file
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
Write Keys and Values to the Properties file in Java
Write Keys and Values to the Properties file in Java... how to write keys and values in the properties files through the Java program. The program for writing keys and values to the properties file has been mentioned
How to backup a selected file from the dropDown Menu in JSP?
How to backup a selected file from the dropDown Menu in JSP?  I am trying to create a dropdown menu list for some type of files contained ina... file into the backup directory. I need the jsp code that can generate
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code... ,then the value should be stored in the property file like Username = Valar
upload a file and write it in JSP using servlet
upload a file and write it in JSP using servlet  Hello, I'm facing a problem here. I want to upload a file through abc.jsp and write the contents of file using a servlet in xyz.jsp. It is supposed to be a excel file which
Retrieve data from the database and write into ppt file
Java Retrieve data from the database & write into ppt file In this section, we are going to retrieve data from the database and write into the .ppt file. For this purpose, we have used Jakarta POI api to create a .ppt file. The class
How to read properties file in java
How to read properties file in java Description of Example:- In this example... to a stream or load from a stream using the properties file. This properties... is the video tutorial of: "How to read properties file in Java?" How we
Maven Dependency write-properties-file-maven-plugin >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.internetitem >> write-properties-file-maven-plugin version1.0.0 in your project
Maven Dependency write-properties-file-maven-plugin >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.internetitem >> write-properties-file-maven-plugin version1.0.1 in your project
How to write to file using FileOutputStream
How to write to file using FileOutputStream  Hi friends, Please help me in java program. How to write to file using FileOutputStream? thanks,   Hi, To write a file using FileOutputStream, we have to use
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file... in Java.io package i.e. FileWriter and BufferedWriter file. In this section we... to write texts. In this classwe stores the character in a buffer to write
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload  Dear Sir, My issue is: How display a image on servlet from file upload I receive your answer today...: Unknown File Type From: localhost button - Find, Save, Cancel after clicking
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
How display a Image on Servlet from file upload - JSP-Servlet
How display a Image on Servlet from file upload  Dear Sir, My requirement is I want to display a Image on Servlet from File Upload... by photo gallery.that message show file format not supported by Photo Gallary. I
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
how to create text file from jsp and provide downlode option
how to create text file from jsp and provide downlode option  HI... in java/j2ee tech. my question is who do i make a jsp output in the form of text file so that pepole can downlode that text file or may be some other file
How display a Image on servlet from file upload - JSP-Servlet
How display a Image on servlet from file upload  Dear Sir, I were ask a question that How display the Image on servlet through file upload. Today I... both jar file commons-fileupload-1.2.1.jar and commons-io-1.4.jar and set
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file... passed the file name to write into a stream characters. Then we use the FileWriter Object to PrintWriter instance. How to create File to CSV in Java
how to write append file in Java
how to write append file in Java  How to write append file in Java... existing file should be retained when you are trying to write new contents...("appenToFile.txt", true); For More Details visit this link: How to Append file
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload   Dear Sir, My Question is: How display a image on servlet from file upload Your Answer: Hi... that an attempt to open the file denoted by a specified pathname has failed
How to write to file using FileWriter
How to write to file using FileWriter  hi, How to write to file using FileWriter thanks,   Hi, To writing in a file in Java program we...(File file), FileWriter(File file, boolean append), FileWriter(FileDescriptor fd
Retrieve Data from the database and write into excel file
Retrieve Data from the database and write into excel file. In this section, we are going to retrieve data from the database and write into the excel file... = connection.createStatement(); ResultSet rs = st.executeQuery("Select * from student
Reading duplicate keys from .properties file - Development process
Reading duplicate keys from .properties file  Hi, I am reading a .properties file using a basic java program.Though the .properties file will not allow duplicate keys, but still I want to develope a program to identify
Problem to print from my properties file - Java Server Faces Questions
Problem to print from my properties file  Hi, I am a new user of this site. It is very interesting. So this is my problem: I have a jsp file where i try to print some messages from my properties file but when i execute

Ads