Is it possible to communicate the online database from my applet without any conditions? or limitations?
Conditions - a restricted combination of characters that might be suspected as a
pattern of a virus that should be blocked...Security concerns
Limitations- Not all characters in ascii are welcome in an online database...
It's just a weird idea...
Im currently experimenting a simple hashcode generator in an applet...(unique patterns)
Then i would like to save it in the database,
Is there any possibilities that might change the real code(generated code) as im transfering a copy of a hashcode to an online database?
Any reply would be greatly appreciated...
sukatoa.
10 1317 BigDaddyLH 1,216
Recognized Expert Top Contributor
Is it possible to communicate the online database from my applet without any conditions? or limitations?
Conditions - a restricted combination of characters that might be suspected as a
pattern of a virus that should be blocked...Security concerns
Limitations- Not all characters in ascii are welcome in an online database...
It's just a weird idea...
Im currently experimenting a simple hashcode generator in an applet...(unique patterns)
Then i would like to save it in the database,
Is there any possibilities that might change the real code(generated code) as im transfering a copy of a hashcode to an online database?
Any reply would be greatly appreciated...
sukatoa.
I'm not a big fan of applets, but the best practice is to write your application in three layers:
1. applet
2. Middle layer on server
3. Database
Your applet doesn't communicate directly with the database. Evidence is that no java.sql classes appear in the applet class, nor in any code that gets downloaded with the applet class.
Your applet communicates with a server component and that component communicates with the database.
You may want to reconsider using an applet and write this as a web application.
I'm not a big fan of applets, but the best practice is to write your application in three layers:
1. applet
2. Middle layer on server
3. Database
Your applet doesn't communicate directly with the database. Evidence is that no java.sql classes appear in the applet class, nor in any code that gets downloaded with the applet class.
Your applet communicates with a server component and that component communicates with the database.
You may want to reconsider using an applet and write this as a web application.
Yah, i forgot to mension about the server...
so, can i assure that whatever combination of text i will be send to the server, it does not change the pattern until it saves on the database?
Sukatoa...
BigDaddyLH 1,216
Recognized Expert Top Contributor
Yah, i forgot to mension about the server...
so, can i assure that whatever combination of text i will be send to the server, it does not change the pattern until it saves on the database?
Sukatoa...
Do you have something specific in mind when you ask this? I'm not sure what you are trying to say.
Do you have something specific in mind when you ask this? I'm not sure what you are trying to say.
Im not pretty sure about the security exceptions in the cyberspace...
All i want is to generate a unique combination of characters and save it in a file for experiments....
Then after that, proceed to online database....
My question is, is the file i have generated would be stored 100% in the online database? Without changing its pattern?
For example, i have this,
*^($#7 )(*!@#@+___76544(new line transparent)
*&^%$!@%%$#()*& *&^%$
When i just open this in a textpad, the new line '\n' replaced with a rectangular box stands vertically....saved...
and when i open that file again from my applet, the pattern changed...
I get stucked in the middle of the experiment....
That was not so specific, but i think you can now understand this...
I will think again about this....
Thanks for the reply bigDaddy....
BigDaddyLH 1,216
Recognized Expert Top Contributor
Your questions keep shifting, but I believe your question now is: I can't seem to write "\n" to a file correctly. Is that correct? Post the code that is in error.
Your questions keep shifting, but I believe your question now is: I can't seem to write "\n" to a file correctly. Is that correct? Post the code that is in error.
- public void SaveFile(String path){
-
FileOutputStream writes = null;
-
String text = new String(textArea1.getText());
-
try{
-
byte out[] = text.getBytes();
-
writes = new FileOutputStream(path);
-
writes.write(out);
-
} catch(Exception e){
-
JOptionPane.showMessageDialog(null, "UNABLE TO SAVE FILE!!", "FATAL ERROR 98773", JOptionPane.WARNING_MESSAGE);
-
} finally{
-
try{
-
if(!writes.equals(null)){ //Under tracing... But no problem...
-
writes.close();
-
}
-
} catch(Exception e){
-
JOptionPane.showMessageDialog(null, "AN ERROR OCCURED WHILE CLOSING THE FILE!!", "FATAL ERROR 102", JOptionPane.WARNING_MESSAGE);
-
}
-
}
-
}
The code above has problem...
My source of text is the textArea... "Under experiment".....
After saving, try to view it in textpad... All newlines were replaced with rectangular box stands vertically... But when i open it again on my program, no problem... Maybe there is a difference of coding when it comes to newline...
The rectangular box that i mean is in 7F hex or FF hex in ASCII....
What can you suggest the way i write the text to file?
What is the weakness?....
Update me...
BigDaddyLH 1,216
Recognized Expert Top Contributor - public void SaveFile(String path){
-
FileOutputStream writes = null;
-
String text = new String(textArea1.getText());
-
try{
-
byte out[] = text.getBytes();
-
writes = new FileOutputStream(path);
-
writes.write(out);
-
} catch(Exception e){
-
JOptionPane.showMessageDialog(null, "UNABLE TO SAVE FILE!!", "FATAL ERROR 98773", JOptionPane.WARNING_MESSAGE);
-
} finally{
-
try{
-
if(!writes.equals(null)){ //Under tracing... But no problem...
-
writes.close();
-
}
-
} catch(Exception e){
-
JOptionPane.showMessageDialog(null, "AN ERROR OCCURED WHILE CLOSING THE FILE!!", "FATAL ERROR 102", JOptionPane.WARNING_MESSAGE);
-
}
-
}
-
}
The code above has problem...
My source of text is the textArea... "Under experiment".....
After saving, try to view it in textpad... All newlines were replaced with rectangular box stands vertically... But when i open it again on my program, no problem... Maybe there is a difference of coding when it comes to newline...
The rectangular box that i mean is in 7F hex or FF hex in ASCII....
What can you suggest the way i write the text to file?
What is the weakness?....
Update me...
There are several basic mistakes in your code. Here are the three biggest:
1. (Aside) Why are you making an unnecessary copy of a String? Your code: - String text = new String(textArea1.getText());
Can be written more simply as: - String text = textArea1.getText();
2. You need to understand the difference between text and binary data. You shouldn't be writing out a byte array using FileOutputStream. Take the tutorial on I/O: http://java.sun.com/docs/books/tutor.../io/index.html
3. Text components like JTextArea already have a methods to simplify I/O: check the API for methods read and write: http://java.sun.com/javase/6/docs/ap...a.lang.Object) http://java.sun.com/javase/6/docs/ap...ava.io.Writer)
Demo: - public static void writeFromTextComponent(File file, JTextComponent comp) throws IOException {
-
FileWriter out = new FileWriter(file);
-
try {
-
comp.write(out);
-
} finally {
-
out.close();
-
}
-
}
There are several basic mistakes in your code. Here are the three biggest:
1. (Aside) Why are you making an unnecessary copy of a String? Your code: - String text = new String(textArea1.getText());
Can be written more simply as: - String text = textArea1.getText();
2. You need to understand the difference between text and binary data. You shouldn't be writing out a byte array using FileOutputStream. Take the tutorial on I/O: http://java.sun.com/docs/books/tutor.../io/index.html
3. Text components like JTextArea already have a methods to simplify I/O: check the API for methods read and write: http://java.sun.com/javase/6/docs/ap...a.lang.Object) http://java.sun.com/javase/6/docs/ap...ava.io.Writer)
Demo: - public static void writeFromTextComponent(File file, JTextComponent comp) throws IOException {
-
FileWriter out = new FileWriter(file);
-
try {
-
comp.write(out);
-
} finally {
-
out.close();
-
}
-
}
Roger....
About the string, don't worry, the JVM will change the byte code for it to optimize automatically....
And, it was not finalized... I forgot it.... sorry....
So, here is my new problem...
How safe is this code? - private void CopyFile(File source){
-
try{
-
FileWriter copy = new FileWriter(new File("TEMP.COM"));
-
FileReader view = new FileReader(source);
-
int node = 0;
-
-
while((node = view.read()) != -1){
-
copy.write(node);
-
}
-
copy.close();
-
view.close();
-
}catch(Exception e){e.printStackTrace();} // for debugging
-
}
I've used it to transfer the .COM file to the original path....
Is this code has a quality enough?
Or you have the best idea how to implement it?
how is your algo if you know it BigDaddy?!!
Update me.... ;-)
BigDaddyLH 1,216
Recognized Expert Top Contributor
Roger....
About the string, don't worry, the JVM will change the byte code for it to optimize automatically....
And, it was not finalized... I forgot it.... sorry....
So, here is my new problem...
How safe is this code? - private void CopyFile(File source){
-
try{
-
FileWriter copy = new FileWriter(new File("TEMP.COM"));
-
FileReader view = new FileReader(source);
-
int node = 0;
-
-
while((node = view.read()) != -1){
-
copy.write(node);
-
}
-
copy.close();
-
view.close();
-
}catch(Exception e){e.printStackTrace();} // for debugging
-
}
I've used it to transfer the .COM file to the original path....
Is this code has a quality enough?
Or you have the best idea how to implement it?
how is your algo if you know it BigDaddy?!!
Update me.... ;-)
1. If an exception is thrown, you don't close either stream.
2. When you are copying text files, it may make more sense to do a binary copy and not copy as text. The exceptions to this include cases where you are chaning the charset encoding and when you are moving files between machines and are concerned about the difference in new-line characters between Windows and Linux, for example.
1. If an exception is thrown, you don't close either stream.
2. When you are copying text files, it may make more sense to do a binary copy and not copy as text. The exceptions to this include cases where you are chaning the charset encoding and when you are moving files between machines and are concerned about the difference in new-line characters between Windows and Linux, for example.
- 1. If an exception is thrown, you don't close either stream.
I forgot again.... - The exceptions to this include cases where you are chaning the charset encoding and when you are moving files between machines and are concerned about the difference in new-line characters between Windows and Linux, for example.
This is what i've been waiting for BigDaddy....
You got the best answer that would convence me to make changes in my codes....
Maybe we have misunderstandings in the previous posts....
I am aware of it....
Thanks.... ;-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: nathanlaan |
last post by:
This is the stupidest thing I have ever seen. Java 1.2, 1.3, and 1.4.1, and
1.4.2 all define the Applet.getDocumentBase() method differently! How am I
supposed to get the directory of the document...
|
by: Aljo_ |
last post by:
Hello!
I got a free evaluation copy of Borland's JBuilder9.
I also got a book about JAVA, and I am trying to type, compile and run some
examples from the book.
The following - very simple -...
|
by: Charlie Kim |
last post by:
Here is gnome applet source of mine.
--------------------------------------------------
#!/usr/bin/env python
import pydic
import gtk
import gnome.applet
|
by: Tormod Omholt-Jensen |
last post by:
Ï need to dynamically insert an applet into a document. In IE 6.0 my code
works fine, but there seems to be problems in Opera 7. The page looks
like there is allocated space for an applet. ...
|
by: Roberto Gallo |
last post by:
Hi;
I have two problems regarding Scripts and Applets. I need to construct a
page that has some instances of the same Applet. These instances are
responsible to get informations from the user...
|
by: Larry Martin |
last post by:
I am trying to run a Java Applet on my ascx page and am getting an IO
exception when IE6 tries to load the applet. It seems a lot of others are
getting the same problem but a search of the web did...
|
by: DKM |
last post by:
Here are the source code files to a Java applet that utilizes
LiveConnect to communicate with Javascript, and the HTML file.
The thing works both in IE 6.0 and FireFox 1.4. but with some...
|
by: ankur |
last post by:
WHEN I RUN THIS WEB APPLICATION ON Tomcat5.5.9 SERVER
MY HttpChatApplet sccessfully Loaded from ChatDispatch but
running on some another PC HttpChatApplet not loaded
my Coad
...
|
by: shanmukhi |
last post by:
Hi All
I got a problem in running java programs.
i am not able to run java applet while running i got a problem as
Loading Java Applet Failed
java.lang.NoClassDefFoundError: App (wrong...
|
by: tudyfruity18 |
last post by:
I'm suppose to write an applet that contains two buttons Investment calculator and Loan Calculator. When the Investment Calculator button is clicked, a frame appears in a new window for calculating...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |