masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry, jwenting, I was thinking of beans and wrote tags, but that is beside the point.

What I was getting at, is they mentioned using Access for their database before, and from what I have gleaned (I could be completely wrong on this, but it doesn't appear so) Access allows spaces in Field/Column names as long as you then enclose that name in brackets "[ ]" in the SQL statements (and there appear to be other reasons as to why people may want enclose them, as well). This (correct me if I am wrong), AFAIK, is not allowed in standard SQL, but (at least it seems so) nearly everyone that uses Access does this, and so, to make it uniform, often then enclose all field names in brackets. This will definately need to change.

We both know they should stick to SQL92 (and I do so as long as it is possible), but most of the time they do not know what that is, and do not look it up. They have the database they use in front of them, and see that they are allowed (in that database) to do "so and so", and so they do "so and so".

That might not be the case here, and I will truely applaud them if that is so, but I seriously doubt it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Also, what is this line?

while (m < 10 || m > 100);

You do realize that this while statement will hang forever if m is less than 10 or greater than 100, right?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You're problem isn't, however, in updating the instance variable. m and n are getting updated just fine, with what you are doing. What is not working, is that the array is not dynamically changing size along with those variables. That is not the way it works. You need to redefine the array to get it to change its size.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

if done properly, your JSPs won't have anything to do with the database so they won't change.
Your servlets won't have much to do with the database so they most likely won't change either.
Only your ORM mapping files and configuration files would change to take the different database configuration into account.

But you know very well, that all of the above is, in this case, not true. ;-)

But actually if they are going from Acess to Oracle (which is what I read from the original post), then where ever it is that they have their SQL, those statements will change because of all this "[fieldname]" stuff (At least that is what I have seen from every example/problem where Acess is asked about. Whether that is how it is done or not, I don't know, I don't use Access).

But, as you said, that should not be in the JSP at all, and only sparingly, at most, in the Servlets. Some Custom Tags, and other context items, could be be in for some major changes though (SQL wise as I said).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I am sorry to disagree, but learning on an IDE is not the way to go.

You should learn the basics (compilation, execution, jarfile packaging, classpath manipulation, basic syntax, etc.) using a simple text editor and the command line.

Whenever you do it the other way, you learn some hard lessons the first time a problem occurs, or the first time that you do not have your preferred IDE to use, because you won't have a grasp of those basics, and so will be lost as to what might be causing the problem, or as to how to do something in another IDE, since all you will know is how to manipulate your preferred IDE not what it is you are actually manipulating.

Other than, simply starting at the Sun totorial site, with "Getting Started" and working your way down the page, is sufficient to at least get started. Also, when it comes to doing the examples, type them do not cut and paste them, you will learn much more that way, whether you believe it or not.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

i found your problem...

this is not a constructor.... :) i think you put void mistakenly

Aach. Completely overlooked that. Yes, that is the problem. And also the reason why display is null, because since that is not a constructor, display never gets initialised.

I am such a fool sometimes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume, since you're using a textarea, that you are sending the mail in HTML format, right?

So simply place the href directly after the textarea. If it is not in HTML format, then simply placce the link (with the http(s)://) as plain text in the email, and if the mail program the user uses recognises links, it will automatically make it usable as a link.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you are using JDK 1.5 or later, check out the "format" method of String. And actually follow and read (completely) the "format string" link contained within the description for that method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Strange. The only thing I can suggest now, is to try running it in a debugger and observe what happens. I can't really suggest a debugger for a MIDlet as I have not tried any.

The only other suggestion is to make sure that that line is actually the one throwing an NPE.

And, as a general suggestion, to clean up the code a bit, I would move those commented parts of the constructor into their own private methods (one per commented part), and then call those methods from the constructor.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Of course there will be some changes, but they should be minor. Except that, from other examples I've seen, most of your SQL statements will need to be rewritten.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Place it as a normal link directly under the textarea.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No. I blame you. Even if something did happen that literally incapacitated you, that is still no reason to cheat. Talk to the teacher, and if it is legitimate, they will give you time. Otherwise, you're just a lazy twit.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

According to the documentation for Form and Display, and if this is actually the line throwing the null pointer exception, then display is the only thing that even can be null, since the setCurrent method will accept a null value, so currentForm is allowed to be null.

Take out all the dots and attempt to run the Class exactly as it is portrayed here. If that works, then the problem lies somewhere else in your code. Maybe there is some process somewhere in your class that sets display to null again. I don't know since I can't see the rest of the code.

As I said, however, reading the Display and Form API pages from this lcdui package, indicates that display is the only thing in that line that even could cause a NullPointerExcpetion.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And that says nothing. Those classes are those classes, this class is this class. If you do not wish to provide the info we would need to help you, then at least don't waste our time.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't put the link in a textarea. It won't work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Here is a sample of your code:

public static void main (String[] args) {
  String inputSuite;
  int nightsA;  // Here you declare, but do not define nightsA

  ...

  inputSuite = keyboard.nextLine();

  if (inputSuite.equalsIgnoreCase("A")) {
    System.out.println("How many nights do you plan on staying at the R & R?");
    nightsA = keyboard.nextInt();  // Here you define nightsA
  } else {
    System.out.println("Try one of our other suites. They might suit you better. ");
  }
  /* if the last if statement has not as yet
   * evaluated as true nightsA is not defined here
   * the compiler realizes this and flags it as an
   * error.  Change the line where you declare
   * nightsA to also make it a declaration.  i.e.
   * int nightsA = 0;
   * Or, you can set nightsA in the else side of
   * the above if statement.
   */
  if (nightsA <= 5 || nightsA >=1) {    suiteApricenoDCst = (suiteA * stateTax);
    suiteApricenoDCft = (suiteA * federalTax);
    suiteApricenoDC = (suiteA + suiteApricenoDCst + suiteApricenoDCft * nightsA); // or here
    System.out.println("Your price for your stay is " + suiteApricenoDC);
  } else if (nightsA > 5) {  // or here
    suiteADC = (suiteA * discount);
    suiteApriceDCst = (suiteADC * stateTax);
    suiteApriceDCft = (suiteADC * federalTax);
    suiteApriceDC = (suiteADC + suiteApricenoDCst + suiteApricenoDCft * nightsA);
    System.out.println("Your price for your stay is " + suiteApricenoDC);
  } else {
    System.out.println("ERROR!!!");
  }

  ...

}

Like jwenting said, you must explicitly declare all local variables. That means, before your code attempts to do anything with it, …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do Your Own Homework.

Salem commented: You tell 'em +6
thekashyap commented: Can't beleive they have so much pocket money now-a-days.. ! +2
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Thanks for replying, as I stated in my post, I'm a NOOB at this & I posted this to see if anybody could give me a suggestion on how to fix this error.

No, judging from this post, you came here for someone to give you the code to complete and functional program. Well, I'm sorry (no I'm not), but that is not how it works. Read jwenting's post again, consider his recommendation, study your code, and attempt to fix it. Surely, you have learned how to initialise variables.

(His response "No I haven't, and stop calling me Shirley!" Both halves of that sentence as senseless as the other.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Gods, what a bunch of lazy a**holes. Do your own homework. No one here, who has even a half an ounce of either sense and/or honor, will do it for you. God forbid if we did, and then had to work with your lazy, cheating a**es.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What about the Class Display.

Is it at all possible that display = Display.getDisplay(this); returns null?

Please provide this getDisplay method, or if it comes from some thrid party API, then please provide the JavaDoc from this method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Some more code is needed. According to the method showed (in a cupsule like it was) display definately would be null, since there is no evidence otherwise. Post the entire class.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

All of the methods you need are in the Math Class.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Maybe the NullPointerException refers to "display".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Maybe you're looking for a splash screen. Check out this article:
http://www.javaworld.com/javaworld/javatips/jw-javatip104.html

Edit:

And that "give me the idea immediately" is extremely rude, whether prefixed with "please" or not.
We are not here to serve you.

~s.o.s~ commented: Well said, maye the kids nowadays ought to learn some manners - ~s.o.s~ +14
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read up on JNI and/or the exec method of Runtime.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

We also know, we see it every year. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Some code might help. We have no idea how you are doing what, and so have no idea how to help you along.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And I pointed you to resources that will enable you to do that. The first one will teach you how to use JDBC. The second one will provide you the specifics (read Connection URL) for PostGreSQL, the third one will help you integrate that information into JSP (and hopefully you will do it in the proper manner and use a bean or JSTL tag for accessing the DB rather than a scriptlet).

Here are the three resources as links:

http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://jdbc.postgresql.org/doc.html
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

I am not going to simply give you ready made code. Try it yourself, and if you have problems post your code here and we will help to correct it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the JDBC tutorials at Sun, the JDBC documentation for the PostGreSQL Driver (once you download it), and the J2EE tutorial at Sun.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
$ENV{UNIXVAR}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Define validate!!!!
Define validate!!!!
Define validate!!!!


Assuming you mean verify it could be a valid IP address even if no one is using it, then you can do this with String Tokenizer or Stream Tokenizer

String tokenizer splits the string into chunks using a delimiter.
You will have to consider IP4 and IP6 formats and at the very least verify the number of chunks is correct and the values of each chunk are in range.

If you mean is there something there when you try to connect that is a whole new ball game and I would suggest thinking carefully why you would want to do that from code.

It is also possible ( and I would look it up if I needed to do so) that sun have built the check you want into their API. In that case use SUN's methods. Chances are they will have done a better job thab you could.

Um, I'm sorry, but what part of "using string tokenizer" did you not understand. I am quite sure the teacher would be satisifed with something that checks that it is four numbers between 0 and 255 seperated by a dot. I am fairly sure that this is a class exercise in the Strings and converting them to ints and not any actual networking exercise.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume the number should have a specific length front padded with zeros, right? i.e.

001
002
055
100

Well, then as I said, follow the link for "format string". You call tell format that you want the number to be three digits long and front padded with zeros. Then you do not have to decide when to pad, format will.

So, I need to ask, did you actually read what I told to read, and attempt to figure it out, or do you just want "teh codes" (mispelled on purpose).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You cannot store an integer value as an integer, and with a leading zero. I assume you only need the leading zero when printing the number, right?

Than look into the format method for String, if you are using at least 1.5. (And follow the "format string" link found in the method description for format.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API doc for Runtime.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I already sent a request to move this post to ASP section. It can be that admin/moderator is not around so post wasn't moved

Thank you, but I still find it important to tell this to the original poster, so that, hopefully, (s)he does not make the same mistake in the future.

;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What?!

No idea what you are asking. Please explain, in some detail, but without writing a novel, what it is you want to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This forum is about neither asp nor JavaScript.

JavaScript != Java.

Please find a forum dedicated to either asp and/or JavaScript and ask your question there. You will get much better results.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So use Google.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Please explain what you expect to see as output, and what you are seeing as output, as well as what was provided as input.

Also, post any exceptions you may be getting.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JavaScript and Java are two different programming languages. The name is similar, but they were developed by two different companies. JavaScript purposely took on that name to "ride the Java wave", but it has only syntactical similarities. It is not the same language. Google search for a forum dedicated to JavaScript and post your question there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And, of course, as mentioned in peter_budo's first post, that is JavaScript, not Java. Java != JavaScript. Find a JavaScript forum somewhere, rather than a Java Forum.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well this

import java.awt.*;

is a pretty indicative tip.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No. You can obfuscate your code, or possibly try to create a native executable rather than a jarfile but both of these are equally useless. If someone wants your code they are going to get it.

The only way you prevent them getting your code is to not distribute it. In otherwords provide a web service or web site so that the consumer never gets your code onto his computer. But even then, reverser engineering can still be performed by determined people.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then what you are getting from your JOptionPane is a String. You need to convert this String to a char. Here is an example (I am assuming you only have to deal with one letter):

char letter = uppercaseString.toCharArray()[0];

I assume you know what to do with the offset once you have turned the String into a char.

Also, this information is easily found in the String API doc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because the path used will not function on a unix machine. The backslants will not work as a path on a unix machine and the double backslant at the beginning of the path also means absolutely nothing to a unix machine.

To access a windows file from a unix machine in this manner (or at least something close to it) will require the installation of a service to allow it (the most popular is samba), and then the script will first have to use this software to connect to the server and then view the file using it.

You would be well served (if you truly wish to do continue in this direction) in downloading samba and then researching samba until you are able to use it, then attempt to incorporate that into your script. (I believe there is a samba module on CPAN and that it might be possible to use it without having to install samba itself)

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

tar keeps the directory path in place by default. This behaviour that your describing would be very unusual for a tar command. Something special is being done, probably an alias replacing tar with a special call (although I don't know of any options to tar that would cause this behaviour), or some options were used (again I don't any , but then again I have only Sun's tar for comparison and Gnu's tar has many more options) on the packaging tar command that caused this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Check out the GridBagConstraints.anchor field.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It depends, on Linux play around for a while with rpm -qa, on Solaris play around with pkginfo, on AIX, HP, and SCO (as well as the FreeBSD/NetBSD deriviates) I can't really help you. I don't remember there software management commands.

But as you can see, it depends on your operating system. It also depends on whether the packaging system was used at all, or if someone downloaded the source and compiled it, or maybe just a tar file version of a binary program.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, then, if you need to justify your decision to use a real JDBC Driver instead of the JDBC-ODBC Bridge, and you are using JSP/Servlet on Linux, you essentially don't need one. As mentioned, ODBC is, probably, not even available on your Linux system, and the JDBC-ODBC Bridge is not thread safe, and so not suited for Servlet/JSP in the first place.