stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Thats cause "names" is an Array of String objects and not a String itself.
If you need to display the contents of "names" use a loop like:-

for(int i=0;i<names.length;i++) {
  System.out.println(names[i]);
}

BTW you seriously need to learn how to indent your code, this should help you get started.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
public static void main( String args[] )
     {
       public String productName;  // product name
       public double number;  // product item number
       public double units;   // number of units in stock
       public double price;   // price per unit
       public double value;   // total value of all units in stock

You use the access specifiers (public,private, protected) only for Class level variables, not for local variables, I suggest you please get a good book and clear out your basics of Java.

Alex Edwards commented: Cut him some slack =P +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Use code tags please. And post the entire and complete compiler messages and/or exceptions you are getting.

I guess you forgot to mention relevant code this time too. . . . . :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Read this if you wish to receive any help.

Edit: Deleted taunt

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Thats cause you are doing a grade++; near the end of your loop. Try entering -2 and it should stop.
But I do not see any point in grade++; being there since you are anyways going to overwrite it with grade = input.nextDouble(); on the next iteration.

And please use code tags. Look here and here for more information on them. You should read the rules before posting.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

i am thinking of setting up an sms center which send sms' to subscribers

Kind of a vague description, can you elaborate what are you actually looking for ?

If you are talking about Short Message Service Centres (SMSC), these basically receive messages via the SMPP (Short Message Peer to Peer) Protocol and forward the messages to the service providers via SS7 protocol via switches etc.

If on the other hand you just want to be an aggregator (middle man) who has connections to multiple SMSCs and sells them to your clients, you need more like an SMS Gateway, There are already a few Open Source SMS Gateways available, a popular one is Kannel . However It is not based on Java but in C. But if you are planning to implementing the gateway yourself in Java you could start by learning about SMPP. Also you will need an SMPP API which will do the job of handling all low level networking tasks so that you do not have to worry about constructing the SMPP protocol data units (PDUs).
Although there are many available I recommend OpenSMPP for that, cause it has been around for a while.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Open in the jar file in WinZip or WinRAR to check if it actually contains any class file.

According to me the command for you case is :

jar cfm [jar file name] [manifest file name] [java class name].class.

And BTW please use code tags while including code in your posts

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The code worked when I did this instead of what written above

public boolean isValid(){
	valid=false;      //let by default
if((username != "")&&(password != ""))  {   valid=true;
........

I do not see any difference between this code and what you have written above for the isValid() method.

Also I don't think you have understood the concept which Peter is referring to.
Although he's already made it already as clear as possible, May be this piece of code might make you understand the difference between != (or ==) and equals() method in case of java strings.

/**
 * File Name : TestString.java
 * Here we just show the difference between
 * == (or !=) and the equals() method
 */

public class TestString {
  public static void main(String[] args){
    // Note the use of the String("") constructor instead
    // of directly initialising by ="HELLO" way, to stop the
    // JVM from optimising our code.
    String myString1=new String("HELLO");
    String myString2=new String("HELLO");

    if(myString1 == myString2) {
      System.out.println("Strings refer to the same object.");
    }
    if(myString1.equals(myString2)) {
      System.out.println("String contents are equal.");
    }

    myString1 = myString2;

    if(myString1 == myString2) {
      System.out.println("Strings refer to the same object.");
    }
  }
}

Should give you the output:-

stephen@linux-4f1r:~/Development/Java/daniweb> java TestString
String contents are equal.
Strings refer to the same object.
stephen@linux-4f1r:~/Development/Java/daniweb>

So == and != are used to check when two references are pointing to the same object, whereas the equals() method of the String(not Object) class actually checks if the strings are the same.

So your code username …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This is more of an HTML question rather than a JSP question,

You have to add the parameter selected="selected" for the Option element you want to be selected by default.

An example is as follows:-
Consider you combobox has four elements Volvo, Saab, Fiat and Audi and you want Fiat selected by default, then you would have to do the following:-

<html>
  <body>
    <form action="">
      <select name="cars">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="fiat" selected="selected">Fiat</option>
        <option value="audi">Audi</option>
      </select>
    </form>
  </body>
</html>
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I've looked everywhere but keep encountering applets and servlets

If you have encountered this scenario then you have actually already found your answer.

The code in the applets is the client side code, all you have to do is study the networking code in the Applet and implement it in your client application.

And as far as your server side code in JSPs goes ..... I think you should know that JSPs are basically extensions of servlets.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What is the error, at what line does it occur, I am pretty sure Glassfish orTomcat whichever server you are using gives you the exact error and the exact line number on which it thinks the problem exists.

connection = DriverManager.getConnection(connectionURL, "root", "root");

Using root account of the MySQL server for performing normal tasks, haven't you ever read anything about security / Safety on MySQL databases.

Also use consistent indentation in your Code, I know for a fact that Netbeans automatically indents your code so you have no right to post this inconsistently formatted code for others to view.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

hi shaikh_mshariq
if u not find jsp web hosting
go here <URL SNIPPED>
i find two free jsp hosting now, maybe it useful to u

And why d you think does a SOLVED thread with the last post in the year 2006 need to be revived ????????

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Check what encoding you have set for your web page, If it is Latin 1 (ISO-8859-1) then the Greek characters will not be displayed.
You could check for without touching you code by browsing to your page and then (in Firefox 3) go to View -> Character Encoding and select UTF-8 since thats what it seems you are using, If the characters display correctly then you will just need add the following tag in the head section of all your HTML pages:-

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

So that all the browsers treat it by default as a UTF-8 encoded page

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hmmm ........... my crystal ball tells me my previous post was correct !!! ;)


But I could be wrong cause I am using a cheap third world imitation of a crystal ball (a paper weight to be exact ;) ).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you suggest some easy reading on concurrency (I like reading in style of Deitel or OReilly books, explanation with plenty of examples to try out)

Well I don't know if this would be an overkill (especially if you just need to start up) but when it comes to concurrency, I liked Java Concurrency in Practice By Brian Goetz

Alex Edwards commented: Indeed, a very good book. +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First you need to read the rules and then you need to seriously learn the basics of Java, which you can start with the first thread titled "Starting Java"

And if you are a beginner in Java why are you starting directly with graphical user interfaces and applets, first learn to write some console based programs and then gradually as you get a good grasp of the language move ahead to slightly more advanced topics like applets and swings.

You do not start to learn swimming by diving in the middle of the ocean straight away.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Finally because of the fan fare I decided to give Chrome a go today. . . . . AND HELL I was disappointed, Flash took ages to load, sites like Orkut and Facebook wouldn't behave properly, no way to organize your favourites ... At least I couldn't find any, heck I guess Firefox and IE don't have too much to worry about (from chrome) for some time to come !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My worst day was when I once had not correctly handled a Database insert exception (instead of aborting, I was actually retrying sending the message)and I kid you not, it ended up sending 50000+ SMS messages for just one message ... sheesh . . . . . :@ :sweat:

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I disagree with this article.

The author claims that personal training and experience is far better than simply reading a book.

Without the basis, or knowledge of discrete details brought to you by experts, it's hard to say how far your personal training will go.

I suppose this is an "Eye of the beholder" opinion, but maybe you can understand how I feel with my statement?

-Alex

Well its basically how you look at it and interpret the article. For me it was more like pick up the book (any book) and read it, but do not expect any miracles out of it (as the title Learn XXX in 21 days or 24 hours etc suggests).
From my own experience I have met individuals who feel then if they just attend a course for a couple of days in X language or say System administration or ... , they are going to come out as big shot professionals in that field and thats the one attitude of many beginners this article clearly tries to address. It just says there are no magic bullets, no short cuts, if you want to learn to program you have to burn your hands by writing code from small short programs and gradually grow to a professional.
Another section of the article which I can actually apply to my case is "Talk to other programmers;", This shows the big impact of peer groups.
When I had actually first joined Engineering, I did …

~s.o.s~ commented: Oh, a ATKT kiddo ;-). BTW, well said! +23
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you don't know java why are you starting with gui when you don't know even the basics of the language?
Start by writing simple console programs and learn how to use classes, extending them . . .

Exactly when you are learning to Swim, you just don't directly jump into the middle of the ocean, you start in the baby pool first.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Are we talking of Java here ?

Then shouldn't this

public static void main()

Be this:-

public static void main(String[] args)

For normal Applications Java begins program execution in the Main method takes a String array(which contains the parameters passed to program at the command line) as an argument (and should also be public(since it should be accessible from anywhere), static (As the JVM should be able to call it even before an object of the class is created) and final(we definitely don't want someone overriding our main)), and when you try to run (after compiling) the program, it just can't find a main method which takes a String array as an argument, hence the Exception "main" java.lang.NoSuchMethodError: main is thrown.

Also let us now look at your other errors:-

int hours = 0;
		double fees = 0.0;
		double rate = 0.0;
		double tuition = 0.0;

These variables have been declared inside the main, so it is as good as they do not exist for other methods.

But frankly, you are basically destroying the concept of Object oriented programming in your code. If you go about like this chances are you may learn Java (the syntax) but will not learn how to program in Java. I suggest you go through the Starting Java thread at the start of this forum.

@llemes4011
Do not give people ready to eat food, teach them how to hunt for it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Whats the error MySQl is throwing ?

I don't think the following should make a difference but have you tried like this :

SELECT a.d_key_id, AVG(a.score) as 'avg' FROM
   (SELECT d_key_id, frequency, weighting,(frequency*weighting) as 'score'
    FROM users_to_keywords
    WHERE s_user_id=$user_id
    AND d_key_id = $score_key				 
    ORDER BY score DESC)a
    GROUP BY d_key_id
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Use code tags when pasting such content, it makes the post look cleaner and alot more organized.
See here and here for information regarding code tags.
To turn on directory browsing I think you will need to add the following directive in your httpd.conf file

DirAccess On
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Use code tags and repost your code. I am not going to stress my eyes on that right now.

For help on code-tags read this and this.

Also looking at your code you need to follow some standard naming conventions, This is a link to code conventions as specified by Sun for Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

(use -source 1.4 or higher to use 'assert' as a keyword)

Well you given only a skeleton description of the problem, why don't you try and see by doing what the toolkit is telling you that is build with -source 1.4 option and any way its been marked as a warning so I don't think it should do too much harm (Although it is still best to remove warnings also)

Also another thing do not use SMS speech here, you have a full keyboard in front of you, so type the complete words, people who visit this forum are not necessarily as proficient in English to figure out what you are saying.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I am just shooting in the dark here, but I have a feeling what you need is connected to Speech Recognition.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I said

char characterArray[] = new char[charArraySize];

I had said replace "charArraySize" with the appropriate size.
So if your array size is 20 it should be:-

char characterArray[] = new char[20];

And no BufferedReader can also read a character at a time. Refer here for more details on that.

Heres the javadocs of the String class of Java, it provides a function to export the data in a given String to a char array directly, so you wouldn't even have to initialize the char array the way we have discussed anyways.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You need to initialize your character array something like this:-

char characterArray[] = new char[charArraySize];

where the "charArraySize" implies the dimension for your array, you can replace it with 10,20, 30 or ask the user to input it.

Also how come I do not see the line where you are taking the input from the console ??

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That is definitely a must read for all those aspiring to be programmers and is the very reason is included in the 'On programming and hackers' section of the Java forum sticky along with many of its ilk. :-)

Yep just spotted it there ... I've been through that thread quite a few times ... don't know how could I have missed it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Is there a way to close one frame only?

Check out the dispose() method of the JFrame class.
You can also check this tutorial to learn more about Event Handling in Java.

The second question you mentioned is related to the concept of anonymous inner classes, but if you are beginning in Java then I suggest for now you stick to the method mentioned in The Java Tutorial which is my first link.

And please use [code] tags to post your code. Look here and here for more information of code tags

darkagn commented: Well explained :) +3
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

So what have you tried ?
Can we see the code ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Uhmmmm, I believe the contentPanes of the top-level windows use BorderLayout, but that's beside the fact.

Grrrr :@ ........ yep that's correct :) !!!

Glad at least we agree on the tutorial he should use and about the null layout.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You have not set the layout for your JFrame, and so it is using the FlowLayout.
And from your code it looks like you want to use the NULL Layout (something like what VB offers).
Refer to this tutorial from Sun to learn about Layout Managers in Java.

Also I suggest you do not use the NULL layout cause then Java cannot rearrange/resize your components depending on the User's screen size / resolution.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First indent that monster, also read this on how to use code tags correctly and then repost the RELEVANT section of the code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First run Peter's Query in your DBMS and see how the results are displayed.

Next if your JDBC concepts are good go to my second link first (the one pointing to the javadocs of the ResultSet interface).

If the answer still doesn't click, then I guess you will need to go through the tutorial till you get what you want.

Trust me if you find and correct these small mistakes yourself, you will know how to go about larger problems.

Also I will tell you where you are going wrong you are expecting all the three parameters for SL,PL and CL in one row like:.

PL     CL     SL
30     7     7

Whereas when you run the query given by Peter attached with the order by clause as shown here:-

SELECT m_leavetype, m_bal 
FROM TABLENAME
WHERE m_emp_no='1004' ORDER BY (m_leavetype);

Note the use of the order by clause to force the database to sort the way the records are stored in your ResultSet so that you will always get "cl", "pl" and "sl" in that order in your ResultSet and not in the order their rows were inserted.
You would get three rows like this:-

m_leavetype            m_bal
 cl                     7
 pl                     30
 sl                      7

So you have to just change your code to search for CL,PL and SL vertically rather than horizontally(i.e in one row).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well welcome to the World of Software Development then, and as far as JSP/Servlets basics are concerned if you would have just look a couple of threads below is a thread mentioned JSP How to Start. That should help you get your basics up in JSPs and servlets.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That shows that you have not put in an effort to go through either of my links, why should I help you then, for a guy of average IQ that should be no more than an hours work and what guarantees that you will go through the tutorial when you no longer need it.
The major reason I am not revealing the mistake is cause the mistake is too simple.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hi guys,
I just wanted to ask if it would be possible to make the Announcements section visible in the Web Development forums.
Also it would be great if certain threads like
Read this before Posting by Narue and Guide to Proper Tagging by Aia in the C Forum could be added to it or may be merged with the Please use BB Code and Inlinecode tags announcement.

Surprisingly this is I think, actually my first thread at daniweb :icon_surprised:

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

start quote:

while(rs.next());
{
balance bal = new balance();
bal.setpl_bal(rs.getString(1,"m_bal"));
bal.setsl_bal(rs.getString(2,"m_bal"));
bal.setcl_bal(rs.getString(3,"m_bal"));

bal1.add(bal);
}
con.close();

If i am doing anything wrong pls correct me.

Yes you are doing this completely wrong.
Have you tried running the query Peter gave directly in your DBMS ?
It gives you three rows(CL,PL and SL) with two columns (m_leavetype, m_bal).
and if you add an extra order by clause you will get you CL first then PL and finally SL.

Although I can give you the code directly but I think redirecting you to the JDBC tutorial would be more helpful for you.
http://java.sun.com/docs/books/tutorial/jdbc/

Cause there you will learn how to actually extract the data from the query and most probably not need our assistance on it any more.

Also check out the javadocs for ResultSet Interface. You may figure out what you are doing wrong there.

Also please use code-tags while posting code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Also do not show pride in mentioning your "straight As" they do not necessarily translate in to good programmers and I mostly from experience associate them with book worms who get lost on the first hurdle.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

See if this answers any questions.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Strange no one recommended the MySQl reference manual as yet. I found it the best guide for all my MySQL questions.


http://dev.mysql.com/doc/refman/6.0/en/index.html

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Its pretty simple. From your first chunk of code I see you know how to use Console.ReadLine() , so al you have to do is read the amount of Sales Jessica did for the current month from the console and store it in a variable named "sales".

Next you calculate you actual salary, as the question suggests, she gets 7% of her total sales.
Hence here salary=sales * 7 / 100 Next her federal tax rate is 18%, so now I assume that its 18% of her salary, so store her federal tax rate in another variable and calculate it as fedTax= salary * 18/100 Similarly you calculate and store the other parameters, and in the end after you have calculated all of them nicely format them and display them using Console.Write()

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well first lets start with the Operating Systems, there are a ton of free operating systems (better known as linux dstributions) based on Linux, Here are a few popular ones:-

Debian A popular free linux distro.
Ubuntu These guys actually ship Ubuntu CDs directly to your home without any charge whatsoever. Also it is one of the most popular Linux distributions available with excellent support. Ubuntu is based on Debian.
OpenSuse OpenSuse was developed by the Suse group initially now acquired by Novell. OpenSuse has the best desktop, in all the linux distros I have ever seen and is the OS I am using while writing this.
Slackware This is the oldest surviving distibution of linux, but this recommended for experts as you will have mostly hand edit configuration files in this distribution.
Gentoo Gentoo is also a nice operating system with a mature desktop environment. It also based on Debian.
Fedora This based on Red Hat Linux, in fact it is supposed to be the testing distro for features that will be later incorporated in to the Red Hat Enterprise Linux OS which is a free software but not free of charge. Fedora is an RPM based distribution.
Mandriva Mandriva was the first distribution that got me hooked on Linux, before I had tried Red Hat Linux 9, but later was disappointed with it and had gone back to Windows, it was Mandriva that …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Just side note, IIS can not be install on some Windows versions for example Windows XP Home and some lesser Vista Home versions (can not remember exact names). Therefore check requirements before installing.

That would be Windows Vista Home Basic and Windows Vista Home Premium.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I have seen the same happen to many sites including Yahoo and GMail, and it happened on both browsers IE6 and Firefox,
The situation in which this happened was the page was taking too long to load (mostly due to a slow net connection) and suddenly in between the connection drops or we manually stop the page from loading.
I am guessing the browser managed to download all the text / html components and was downloading the images,css etc when the connection was interrupted, so it ended up displaying the text/html components alone, I arrived at this conclusion cause in "lynx" which is a text based browser, daniweb looks pretty similar to what is shown in the screenshot.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I reached level 16 then lost interest.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

My professor just comes to the class and tells us this on our second day, after 1 lecture on basics,

Thats because only basics are needed to do this program all you need to know is how to read from the console, add,subtract,multiply and divide AND NO WE WILL NOT SPOON FEED YOU TO GET EXTRA CREDIT YOU DO NOT DESERVE, you show us that you are trying first and then will help you get there.

And last but not the least, this is not the correct forum, you should have posted this in the C# forum Care to read the rules first, If you care about getting answers to your questions.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Nice read, another article I really liked linked with developing skills in the programming field is Peter Norvig's Teach Yourself Programming in Ten Years

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Honestly I was just shooting in the dark, Even I think your(Peter) first post answers the question asked(at least what I thought he was asking) perfectly.

now i want to display the m_bal for pl,sl,cl in the jsp page for the respective userid who has logged in.