Create a .txt file and populate it with the value of Textarea

Hi,

In my application I have a textarea and a button. I want to enter something inside the Textarea and if I click the button the entry gets copied to a file on say c:\test.txt file.

here is my code ...

<HTML>

<HEAD>

<script language="Javascript">

function functSave()

{

<what code shud i write here>

}

</script>

</HEAD>

<BODY>

<h1>Testing ...</h1>

<textarea name="Result" id="resultId" cols="100" rows="25">

</textarea>

<input type = "button" value = "Save" onClick="functSave()">

</BODY>

</HTML>

can u help me ?

[720 byte] By [Ayan@Indiaa] at [2007-11-27 2:36:14]
# 1
it would probably be a lot easier for you to submit the form and do the file creation in Java instead of trying to create a file in javascript.
gmachamera at 2007-7-12 2:55:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

It's not only easier, cleaner and hack-safe to do it in Java, but Javascript also don't provide functions to create files ;) Thank god.

If you don't know how to, check the java.io API and tutorials.

http://www.google.com/search?q=java.io+api+site:sun.com

http://www.google.com/search?q=java.io+tutorial+site:sun.com

BalusCa at 2007-7-12 2:55:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thanxxx for ur reply .. but wht I want to actually do is .. when the user clicks the buttons the File Browser window of Windows opens and the user can save the text (from textarea) into a text file of a name of his choice ...plzz help
Ayan@Indiaa at 2007-7-12 2:55:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I know, you can do this using the java.io package. All you need to do is to create the txt file as an InputStream which can be streamed to the HttpServletResponse#getOutputStream(). Don't forget to set the content-disposition of the headers to "attachment".
BalusCa at 2007-7-12 2:55:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...