P
PiotrJJ
Let assume that I want to send text from JTextArea from Applet to servlet
Like this:
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
url = new URL (getCodeBase().toString() + "file1.txt");
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
printout = new DataOutputStream (urlConn.getOutputStream ());
String content = jtextarea.getText();
printout.writeBytes (content);
printout.flush ();
printout.close ();
How should servlet source code luck like that receiveing data and writing it
to file1.txt on server?
Do servlets can writes files on server witch they are on ?? How do they
recognize file system ??
Or maybe that should cgi script do ??
If yes how should I write it?
This is the primary topic.
_________________________________________
2.
It would be nice if servlet can recognize session and writes data for the
session 1 to file1.txt - for the session 2 to file2.txt.
Like on chats. When first user log on chat, all what he says -servlet will
save to file1.txt then if he or someone else log again the conversation will
be save to file2.txt.
Thanks for help and sorry for my English.
Like this:
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
url = new URL (getCodeBase().toString() + "file1.txt");
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
printout = new DataOutputStream (urlConn.getOutputStream ());
String content = jtextarea.getText();
printout.writeBytes (content);
printout.flush ();
printout.close ();
How should servlet source code luck like that receiveing data and writing it
to file1.txt on server?
Do servlets can writes files on server witch they are on ?? How do they
recognize file system ??
Or maybe that should cgi script do ??
If yes how should I write it?
This is the primary topic.
_________________________________________
2.
It would be nice if servlet can recognize session and writes data for the
session 1 to file1.txt - for the session 2 to file2.txt.
Like on chats. When first user log on chat, all what he says -servlet will
save to file1.txt then if he or someone else log again the conversation will
be save to file2.txt.
Thanks for help and sorry for my English.