masijade 1,351 Industrious Poster Team Colleague Featured Poster

You invalidate the session. I would have to look up how to do it in JSP myself, but if your using a servlet, or a filter to accomplish the logout, then that is going to be Java code, and there it is

yourHttpSessionVariable.invalidate();

I hope your not starting every page with the equivalent of

HttpSession session = request.getSession();
// or
HttpSession session = request.getSession(true);

as those create a new session if no valid session already exists. That method should only be used on the initial login every other should use

HttpSession session = request.getSession(false);

this one will return null if there is no valid session.

The best place to do this is in a Filter, as there you can redirect the user to a login site (when no valid session exists), and once the user is logged in the Filter can then redirect back to the site the user originally wanted.

Sulley's Boo commented: You are a star :cool: +5
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, nothing is fool proof.

You need to use the no-cache and expires pragmas/headers, and use some JavaScript to wipe out the history on the browser (Google "javascript history", although this might also be deactivated).

But, no matter what you do, you need to have a session check on each and every page (easiest to use a filter) so that the user, at least, can't do anything on the pages.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, reality often is.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Remove the "private" from "private int option ...".

Access modifiers only apply to class/instance variables, not local variables.

Add something to case 1 (or don't if you wish, as I believe that "error" is only a warning).

And, if that is really your complete code, most of the other errors may simply be a result of the first, so change that one and compile again.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

1.) using BigDecimal will still not give u the right answer it just gives you a longer floating point value plus this problem does not exist in c# so Sun should have done something about it regardless of floating point representation.

Then C# is doing nothing other than the multiply divide playing around that has already been suggested (it just looks at where it starts to repeat and "rounds" it half-way intelligently). I would definately wonder what the performance cost is though (and there is one, whether you wish to believe it or not).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is not a Java probelm. This is a problem with the binary representation of certain numbers (such as 1/3) It can't be done.

Read this entire site http://en.wikipedia.org/wiki/Floating_point specifically the section on Accuracy Problems.

Edit: IOW use BigDecimal if you must 1000% percent accurate (and yes, 1000 was intentional).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That the method returns an int (as its declaration will show), and these are the lines that do that, obviously.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read reply #5. I had already told you to change the name of the field, again (after having changed it from timestamp). You are much, much, much better off not using reserved words in table or column names. Even if there is a "workaround" to allow it. It is, at the very least, a very bad practice with nasty side-effects (as you have just seen).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, is this an update or an insert? Your query was a bit mixed last time, and I created an insert out of it (moving ID into the column and value list). If you simply removed ID, then there are only three fields, and that it why it complains on #4. If you want an update then your query is all wrong, and should look like this:

PreparedStatement ps = conn.prepareStatement("Update Questions Set Question = ?, Answer = ?, WhateverYouCallItNow = 'this has been updated', Author = ?, Customer_Useful = 0, Customer_NotUseful = 0 Where ID = ?");
ps.setString(1, Question);
ps.setString(2, Answer);
ps.setString(3, Author);
ps.setString(4, ID);

You really need to read through both the JDBC tutorial, and an SQL tutorial before continuing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Date is also a reserved word, and you need to look at the "edited" version of the post, as that Where clause is not something that belongs in an insert statement.

Edit: And take a careful look at the PreparedStatement as it appears in my post, and as it appears in yours. You haven't not excahnged any of those cobbled areas of the statements (i.e. the '" + var + "' areas) with the question mark placeholders.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have a JSP which inserts date into a MS Access database. But I keep receiving the error:

24: statement.executeUpdate("INSERT INTO Questions WHERE ID ='"+ID+"'(\"Question\", \"Answer\", \"Timestamp\", \"Author\", \"Customer_Useful\", \"Customer_NotUseful\") VALUES ('"+Question+"','"+Answer+"','this has been updated','"+Author+"','0','0')");

I have checked and checked all the values are there and correct and that the database is expecting to receive the correct types. I'm sure its just a comma or something. Thanks for your help!

Use a PreparedStatement, rather than a cobbled together Statement (which could contain bad values in the variables), and this probably usually won't happen.

statement.executeUpdate("INSERT INTO Questions WHERE ID ='"+ID+"'(\"Question\", \"Answer\", \"Timestamp\", \"Author\", \"Customer_Useful\", \"Customer_NotUseful\") VALUES ('"+Question+"','"+Answer+"','this has been updated','"+Author+"','0','0')");

Should be (as you have it)

statement.executeUpdate("INSERT INTO Questions (ID, Question, Answer, \"Timestamp\", Author, Customer_Useful, Customer_NotUseful) VALUES ('"+ID+"', '"+Question+"','"+Answer+"','this has been updated','"+Author+"',0,0)");

Assuming that the last two fields are number fields. The "TimeStamp" column needs quotes because that is a reserved word in nearly all DBs. You should change that column name. Also, if either question, or answer, has "special" characters (such as an apostrophy), the insert will fail (unless you do some leg work to prevent it that PreparedStatement does for you).

Better, your statement should be like this:

PreparedStatement ps = conn.prepareStatement("INSERT INTO Questions (ID, Question, Answer, \"Timestamp\", Author, Customer_Useful, Customer_NotUseful) VALUES (?, ?, ?,'this has been updated',?,0,0)");
ps.setString(1, ID);
ps.setString(2, Question);
ps.setString(3, Answer);
ps.setString(4, Author);
ps.executeUpdate();

This prevents SQLinjection attacks and it automatically properly escapes all special characters in the values used. You should …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

management. With your lack of knowledge it's the only place you'll ever succeed.

Aside from the fact that he suppossedly has a "Master" (although I have to assume he meant major here, and not masters) and he is just now going to start looking for an entry level development position?

It's all lies!

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Post your code, and the complete error messages and we will help you to correct them (and use code tags).

[code]
// your code here
[/code]
looks like this

// your code here
masijade 1,351 Industrious Poster Team Colleague Featured Poster

What exactly do you not understand?

We are not here to do your (home)work for you. That is expressly forbidden by the terms and conditions you agreed to when you opened a membership here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

With a text editor and javac.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See my first post in your other thread. The same applies here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And what have you got so far, and what part of it, exactly, are you having problems with. No one here is simply going to do it for you. We will give you hints and nudges in the right direction, but you are going to be the one to have to do it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I bleieve he actually asking about PATH not CLASSPATH.

@OP This is a pure OS issue, not a Java issue. find a (seemingly) Windows forum, or use google.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Set a socketTimeout on the ServerSocket and place the accept in a while loop so that it will "interrupt" every once in a while.

I.E.

ServerSocket ss = .....
ss.setSoTimeout(1000);
while(true) {
  Socket s = ss.accept();
  // do whatever you normally do with s (if it is defined);
  // check whatever you want to check to possibly reassign your ServerSocket and then do so
}
shaikh_mshariq commented: Perfect Solution Thanx +2
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Good For you.

You're Welcome.
Masijade

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Arrays.sort(array);

Read the API docs.

Edit: Also read the API doc for Calendar, as the months, and Days of the week already have assigned int values.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but when I see things like the following few snippets

{public class DVD(); }
{ setDefaultCloseOperation(); //EXITONCLOSE();
{ setVisible("true");
{ setSize ("410, 380");
{public class Inventory.java

All I can say is, start over.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Adding to the "build" path on Netbeans is adding to the classpath (at least within Netbeans).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Read the API doc for ArrayList.

http://java.sun.com/javase/6/docs/

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because "UserListIn" is an ArrayList of GymUser objects, it is not a GymUser object itself. You need to retreive the GymUser object from the ArrayList using get(i), then call getID() on that.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is the thin driver, and yes you need to use it.

Place it anywhere you want to place it, and refer to it on the CLASSPATH.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do you have the oci or the thin Oracle Driver. If you have the oci driver, then yes, I believe you do need to have an Oracle client install on your machine (at least you don't need a complete Oracle install, just a couple of libraries and a few config files). If you have the thin driver, then you don't need that (it has less functions, fromwhat I've heard, than the oci Driver, but I've never missed them). If you have the oci Driver, then I would say to dowload and use the thin Driver.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean "refresh onload". That's useless. Do you mean that you don't want the browser, or any proxies in the middle, caching it. So that everytime the page is referenced it must be retrieved anew, rather than simply loaded from cache? If so, look at the expires and no-cache headers and pragmas (google those terms).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Use the TimeStamp class to get and set the field in the DB, not the Date class. In SQL a Date, is a Date, and does not contain a Time. You can then transfer that value to a Date object later, if you wish.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
tf2.setText(tf1.getText());

in an ActionListener. If you don't know what an ActionListener is, or how to use one, then read the Swing Tutorials. (addActionListener on a JTextField will cause "Enter" to fire an ActionEvent)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why are you using a tomcat to poll clients? That's not the way its done. I know you want info from the client, that's obvious. The real question is why? What information do you need, and what are you building that you need it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To tell you the truth, there is nothing secure about http. Https (in some ways) yes, but not simple http.

What is you want to do? Not how you want to do it (which is what you have described here), but rather what you want to do, and why.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your loading the wrong Driver though. Also, look in the logfiles for the web container and get the "real" stacktrace, not the InternalServerError one.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Nobody is going to read all that (especially unformatted code). In any case, the error message is pretty self explanatory. You are essentially doing something like add(parent) or container.add(parent), where container and parent are variables represents some component, of course.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what doers the stack trace show?

One thing though,

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin@10.192.22.17:1521:AIPUAT1");

Why are you loading the driver for the JDBC-ODBC Bridge, then using a url for the Oracle JDBC Thin Driver?

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public static void main(String[] args)
{
    String AQC1_UID = "";
    String AQC1_USER_PWD = "";

    public Login(String AQC1_UID,String AQC1_USER_PWD)
    { 
        this.AQC1_UID=AQC1_UID;
        this.AQC1_USER_PWD=AQC1_USER_PWD;
    }
.....

When indented properly, the error becomes obvious. Do you see it?

I believe you meant to close of main as an empty method, but didn't.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because that is cc and not gcc. Read the documentation for the two, figure out what those two options are in cc and use the corresponding options in gcc, and make sure the paths are correct.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

gcc?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry. ) and ; are together taken as smiley in my above reply.

Use code tags, and that won't happen.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By using SimpleDateFormat to parse the "String" into a date, then compare the two Date objects.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public class SRTF {
    // Your code here
}

Well, there's a start.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Like I said, simply open the fileoutputstream to the place where you want to put the file. There is no reason to create a new file alongside the old file, then "move" it to where you want it, simply create the fileoutputstream where you want the new file from the very beginning.

And, as far as "moving" the "copied/edited" version of the original file, renameTo() still works.

And none of your posts have addressed the original question yet, which was how you "move" a single file as oppossed to "all of the files", as you put it. I would say that's pretty easy. Perform whatever action it is that you're performing to "move" the files on only one file, rather than all of them.

As far as posting code for moving a file, here

File a = new File("/tmp/bogus.sh");
a.renameTo(new File("/var/tmp/moved.sh"));
masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you "have to keep it in the same folder", then why are you doing

src.delete();

And why did you ask how to move a file, when you want to copy it, in that case.

I don't know what your problem is now. If you want to write a file to some place other than where you are "reading" info from, then open a FileOutputStream to that location. What's the problem?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't know about you, but I see all sorts of documentation links here http://www.snmp4j.org/

P.S. Google (or whatever search engine you prefer) is your friend.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

My company is named Matrix, and we use Oracle, so I guess you could ask me. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Classic!

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As far as the functioning of that code it should be okay, but the complaint is that all files were getting "moved". This will definately only "move" (actually copy and delete, which isn't the same thing) one file, so, obviously, we would need the code from which you are calling this.

A few points to this code, however.

Your copy method should use a finally method to close the streams (otherwise you will, not might leak open file descriptors).

I really have no idea why you would synchronize these two methods, there is absolutely (and I mean absolutely) no reason to.

You should simply use the rename() method of file rather than copying the file and deleteing it (this loses all "history" information on the file, and will change the files accessability and ownership specs, whereas rename doesn't).

If you insist on copying and deleteing the file, then at least look into using the transferFrom or transferTo method of FileChannel.

Edit: Another point about rename versus copying. When you copy the file, you must read and write every byte, of course, which takes time (more time as the file gets larger). Rename simply (where applicable) modifies the OSes references to the file, which is only a few bytes worth of actual data manipulation, and it takes the same few milliseconds to perform for a 100 byte as it would for a 1 GB file. The only time where this doesn't apply (at least usually, …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, post your code, but file.rename(), on a single file, shouldn't be beyond you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

TRY MY SUGGESTIONS AT YOUR OWN RISK!
I ACCEPT NO RESPONSIBILITY FOR ANYTHING ADVERSE CAUSED BY MY ADVICE

Does it happen so often that you need a disclaimer? ;-)