masijade 1,351 Industrious Poster Team Colleague Featured Poster

Nevermind. Totally misread, I was assuming you were trying with regex.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So write some. If you have problems, and a specific question, then come back and we will help, but for God's/Allah's/Buddha's/<insert additional diety names here>'s sake, Do Your Own Homework, or at least make an attempt at it.

~s.o.s~ commented: :) +21
masijade 1,351 Industrious Poster Team Colleague Featured Poster

What, three's the charm? Or what? Seeing as how the other two didn't get it, and the comments that went with their denials, what makes you think we'll give it to you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Show an example (of the input and the desired output), as well as the code you have for doing it (at least what you have so far).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, first of all, in an ArrayList you will have Integers, not ints (you may have added ints, but they will have been autoboxed into Integers). Secondly, you will need to tell ArrayList what type of Object[] array will be output, otherwise it will output an Object[], i.e.

Integer[] nums = intArrayList.toArray(new Integer[0]);

Once you have an Integer array, you can then use each of its elements as if it were an int, thanks to autoboxing, but if you want a real int array, you will have to create one yourself, and copy the contents from the ArrayList (or the Integer[]) into the int[] (you can, once again, let autoboxing make the conversions, but you will have to copy the elements "manually", so to say).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It is actually better to place it inside of WEB-INF/lib, unless you are certain that it is needed by, and will not interfere with, other applications on the same server.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No.

Ezzaral commented: Agreed +3
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try using a preparedStatement rather than cobbling together a query statement like that.

See the API and Sun tutorials (a link can be found in the API) for more info.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API for File, namely the method listRoots.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And anyone doing that with filenames should be shot. And no you don't need the braces, but it is good form to keep them, and no, you do not need to quote the variable, unless there are spaces in the filename, which is bad form anyway, IMO.

Edit: And yes, I could have replaced `ls`with * in mine, as well, but then you have him asking "What does the * mean?", as well as anybody else looking at the script later who does not realise that you can use the * in that form at that location (which many people don't), so it is simply much clearer to call ls (and the cost, for a single instance anyway) is negligible.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
int countChar = string.replaceAll("\\s*", "").length();

Just to be an @ss! ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm assuming he wanted to work with each line that he got, and even if not, that he didn't want the filename header before or the blank line after each line that head -1 * produces.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
for i in `ls`
do
  head -1 ${i}
done

And I hope to God, that this is not homework assignment.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

An application designed to be used over the internet (usually through the use of a browser), written in Java.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Where does a servlet run? On the client or on the server. Once you answer that question you will know whether or not you can perform client side validation in a servlet.

Also, your application should never rely on any kind of operations on the client side. They may have the needed resources disabled, or they may be spoofing the results, whatever, you don't know. It should always, always, be checked again on the server side. You can have client side validation, but it should only be used for convenience (i.e. giving the user the opportunity to correct an entry before it is sent to the server), and should never be relied upon by the server.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, it does, but that "source file" is still not any kind of standalone application code. It is a servlet. You do understand the differences between servlet/jsp (i.e. code that runs in an application container) and a standalone application, right?

And, since you would probably only be providing a compiled application to "the customer", you won't be providing him any "code", anyway, so there is no reason to attempt to turn it into a native application, either. They can also be decompiled, you know.

Also, if your "customer" is paying you to write this application, he may (and probably does) have a right to the code. You need to take a close look at whatever your agreement is and make sure of who has the rights to the code, according to the contract.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That would be true, if he were, in this instance, interested in doing any updates.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
ResultSet rs=st.executeQuery("Select * from Employees where LastName='elm'");

should be

ResultSet rs=st.executeQuery("Select * from Employees where LastName='" + elm + "'");

PS as follows:

PreparedStatement ps = conn.prepareStatement("Select * from Employees where LastName=?")
ps.setString(1, elm);
ResultSet rs = ps.executeQuery();
masijade 1,351 Industrious Poster Team Colleague Featured Poster

yes u have be little more specific ...................

Yes, definately. Considering, however, that this thread is three years old, I believe his due date is long past.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

(num1,num2,num2));

Classic typo. And isn't it grand! ;-)

I hazard to guess, that it is a little embarrassing to have it come this far before being found, though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The problem is quoting. The "last name" should be quoted in the SQL with single quotation marks ('). To avoid errors like this in the future (and to prevent SQL injection attacks), use PreparedStatement and its setString method. See the API for more information.

Ezzaral commented: good advice +3
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, code would definately help, but an applet is not a J2EE application. It is a simple standalone application that just happens to be able to be run in a browser, and can be downloaded by the browser, just like an image (no more, no less) before being executed.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why did you start a new thread? Because you didn't like the answers you were getting?

Please, do not multi-post in this manner. Stick with the original thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the "Getting Started" Tutorial. And don't save anything to the "bin" directory (or any other directory inside of the jdk directory).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That or use NumberFormat.
To any sane person (and a computer in that regard is a sane person) the leading zeros are utterly unimportant, a darned nuisance even, and thus stripped and ignored.

None of you except sos realised that apparently. None of you took the trouble to actually look at how numbers are represented in a computer, and thus realised that there are no leading zeros anywhere.
The number is stored as a series of bits representing a number, NOT a string, and a number never has leading zeros.

Obviously my posts were facetious. This idoicy of storing a double as a string and converting back and forth to do math with it is just that, idoicy. Obviously you simply use (and store) a double as a double and format the output as you want it, when it comes time to produce output, and not before. Anything else, is, as already stated, idiocy.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is not a Julian Date. That is simply the number of milliseconds since the "epic" (00:00:00 Jan 1st 1970 UTC) (i.e. a completely normal date as known in nearly all programming languages, excpet that some use seconds rather than milliseconds).
Simply do new Date(1187610073812); .

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why not == '>' ?

Edit: And, of course not 0. Try userData.length() - 1.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because the shell will automatically expand those filename expansion characters before passing the arguments to the script. You might try using \* instead of *, but then, don't expect that the * will work as designed later (it may, then again it may not, I have not tried to "mask" the file expansion during initialisation then using it later).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Go through the tutorials without using any IDE whatsoever. Once you understand all the concepts (such as classpath and the like), then you can start worrying about an IDE.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JavaScript != Java

You have shown only JavaScript. There is no Java anywhere in that post.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Repeat reply #5.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Check which quote you are using. On the keyboard it should be the one that slants from the upper left to the lower right, not the other way around and not straight up and down. In the code, it should also appear to slant in that direction and not appear in one of the other two ways.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read http://java.sun.com/products/jdk/faq/faq-sun-packages.html to find out about sun.* packages (and this includes com.sun.* packages as well). Ezzaral, I would suggest you read this to, if you have not before, as a sun.audio.* class is not "an old part of the api", I'm sorry to say.

Have fun reading. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Awwwwwwwww, but how do I get the leading zeroes back?! Will be his next post.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean "you want to pass it as a parameter". Explain, without reference to URLs, JOptionPanes, Parameter Passing, or anything else technical, what it is, exactly that you want to accomplish.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API for JOptionPane. I assume you're letting him enter a URL, in that case you already have the URL, you simply need to capture the return value of the JOptionPane method. As I said, read the API for that (and the tutorial), it explains it completely.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

-n means suppress output (i.e. read the lines in the file, but don't output them). s/ *\|/\|/g; means replace all occurrences of of zero or more whitespace followed ba a "|" (i.e. "|", or " |", or " |") with "|" .

And the print after that means output the lines where the "command" actually did anything (i.e. any line that did not have any occurrences of "|" will not be output). ${AHS_DATA} is a variable holding a directory name. ${i} is the variable from the loop (table1 or table2 or table3 etc), and references a file of that name in the above directory. sed will read this file for the "lines" of input referenced above. > ./${i}.dat means that all output should go into a file in the currect directory called table1.dat (or table2.dat , or table3.dat , etc, depending on the value of ${i} )

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You tried to do "java mynote.java" when you should be doing "java mynote" after compiling. Than again, seeing as how you are talking about compiling you may have done "java mynote.java" when you should have done "javac mynote.java".

And, start your own thread when you have a question rather than hijacking another.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the Swing tutorial. You are looking for ActionListener.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what the h3ll do you think you need to know?! God, it's not (as he said) rocket science. Geesh. Study the protocol. I myself, have no idea what the protocol looks like, but I assume it will be (in the basic form) text streamed over TCP/IP. So, obviously, you need networking (TCP/IP) and String handling (probably regex as well as some more basic functions). But God, read the protocol, and if you know Java at all, as you claim to do, it should be more than enough to get you started.

Edit: And, more than likely SSL, so study the JSSE as well, of course.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This implies that am gonna read the File and store my values in someBuffer.....

Well, that is not what it does. It simply buffers the read stream so that every read function does not have to actually be directly reflected on the disk. It saves a little time (in your case, with such a small file and only a few reads necessary, a miniscule amount, but that is the principle).

You still need to actually "read" the data, using readLine, split the line using split() storing each value as an int (probably). Read the API for BufferedReader, String, and Integer, as well as the IO Tutorials. http://java.sun.com/docs/books/tutorial/essential/io/index.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you tried simply removing the "-" characters from those three lines? Some XML Parsers (possibly Tomcat's included) are a little picky.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do it in three steps. First use grep and (sed, cut, or awk) to retreive the groups that the user already has, then place these groups, along with the new groups, in a comma separated list string, then call usermod -G ${stringvar} ${user}

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what are the defining methods of an Applet and what is the defining method of a console application. If you can answer that question, then a quick (and I do mean quick) look at the code will tell you which class to run and (at least generally) how to run it. If it is (were) an Applet a little more diggin would be necessary to discover the parameters.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It's a Swing application, not an Applet, and, I'm sorry, but, if you can't figure out both that, and how to run it, from looking at the code, then I don't think the code is going to do you much good.

What do you want it for?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The same response I gave in the JSP forum for this question. Move all of this scriptlet stuff out of the JSP into one, or more, beans.

iamthwee commented: You can tell em but they don't listen. +9
masijade 1,351 Industrious Poster Team Colleague Featured Poster

A very simple answer, move all that scriptlet stuff out of this JSP into a (or probably multiple) beans.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

grep will return false if it does not find the searched for String. So an easy way to this is to change

if [ $fname = `| grep $fname sname.txt` ] ; then
  fname=stored_fname
elif [ $fname != `| grep $fname sname.txt` ] ; then
  fname >> sname.txt ; then
  fname=stored_fname 

to

if grep $fname sname.txt ; then
  fname=stored_fname
else
  fname >> sname.txt ; then
  fname=stored_fname
fi

And, you had forgotten the ending fi (unless of course, the rest of what posted was suppossed to be part of the "elif").

Edit:
Of course, you may wish to add the -w switch to grep so that something like smith does not produce a match for smithison, or something to that effect.

Edit Again:
You may also wish to "throw away" the output of the grep command so that is not printed to STDOUT. In end effect, your grep command should look as follows:

grep -w "${fname}" sname.txt >/dev/null 2>&1
# The complete if statement would then be as follows, of course:
if grep -w "${fname}" sname.txt >/dev/null 2>&1 ; then
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Edit: Nevermind, silly me, thinking of something completely different.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, if your company were to use a proxy server that the other machines would have to use to reach the internet, you would already have this information.