Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your braces and semicolons are out of place. Look through your if () else if () block and check them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This is easily done with the java.util.regex package.

String temp="Vendor number modified from 12345 to 00056789";
Pattern pattern = Pattern.compile("Vendor number modified from (\\d+) to (\\d+)");
Matcher matcher = pattern.matcher(temp);
if (matcher.matches()){
    String fromNumber = matcher.group(1);
    String toNumber = matcher.group(2);
    System.out.println("from: "+fromNumber);
    System.out.println("to: "+toNumber);
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Fade to Black" - Metallica

John A commented: Perhaps a bit too mushy and sentimental, but still a good song. :-) +12
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

http://www.gurusistemas.com/indexdatagrid.php?page=download


this seems to be an easy datagrid for the IE browser


I can't make the MYSQL thing work --

and it should not be difficult -- please TRY , and tell us how

(I use XAMPP software -- and got a HTDOCS folder in my computer);)

Post the code you are having problems with and the nature of those problems. Don't ask people to go download some package elsewhere, learn it, and then explain it to you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please do not drag up and hijack old threads for related questions. Post a new thread and use code tags around any code to preserve formatting.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please edit the post and add code tags around the code. Also, what is it doing that is incorrect? It helps to have some idea of the problem instead of examining every line looking for any trace of a potential error.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

IE7 is the best extension :)

Ugh - I won't touch that with a ten foot pole. :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you certain that the cookies are actually being accepted by the client? Since you already checked that your auth script isn't checking the IP, the session cookie should suffice as you are expecting - unless the cookie is getting refused and the app is not noticing. Also, have you checked that the session is not getting destroyed in some piece of code that is bugged? Just a couple of thoughts.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Currently using Adblock Plus, Cookiesafe, Googlebar, and Research Word. I like all of them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

ya, usually, it takes FEW MONTHS to have a few reply from daniweb.com

Unless you offer Materialistic goods shipped from amzon.com, you won't get a quick answer

So you drug up a two-year-old thread to post this inane and utterly inaccurate comment? Brilliant.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks to me like an extra end brace here, but it is difficult to say since you only posted a fragment of the code

}
$tSQL->Disconnect();
unset($tSQL);
}

Side note: proper indentation of your code blocks would help you spot these things more easily.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, the web.xml file goes in the WEB-INF directory of your app.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Drop the compiled classes in the /WEB_INF/lib folder. If they have a package structure you will need to duplicate that under the lib folder.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are probably getting the java.lang.NoClassDefFoundError: java/lang/StringBuilder error because you compiled the servlet under 1.5 or above and your app server is running 1.4. StringBuilder was introduced in java 1.5.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You just have your html and java code intermingled here and need to fix the tags

while (rst2.next ()) {
            %>
            <option value='<%= rst2.getString("state") %>'></option>
            <%
            }

            rst2.close();

or use out.write() to generate the html option tags instead.

(if jwenting pops in though he will tell you not to be using java in jsp pages at all, which is consistent with the current recommendations in JSP 2.0)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you have three conditions there that could be causing it to fall through

if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000)) {

Have you checked them all individually? This is just part of basic debugging. Use echo, var_dump(), or assert() statments to check these expressions individually.

Example of using assert()

<?php
// Active assert and make it quiet
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);

// Create a handler function
function my_assert_handler($file, $line, $code)
{
    echo "<hr>Assertion Failed:
        File '$file'<br />
        Line '$line'<br />
        Code '$code'<br /><hr />";
}

// Set up the callback
assert_options(ASSERT_CALLBACK, 'my_assert_handler');

$a=1;
$b=2;

// Make an assertion that should fail
assert ($a==$b);
 
?>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Though it is written for Java, you might take a look through this oop tutorial as well:
http://sepwww.stanford.edu/sep/josman/oop/oop1.htm

The concepts are the same though language implementation is different.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm sure Huw would have found this information very helpful - three years ago :P

Still, perhaps someone else will have a similar need and find it here now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, this is easily possible with JSP and Servlets. Please post the question over in the JSP forum, which is there for just such questions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

hope i've made myself clear..please help guys

This is really a question that belongs in the JSP forum. You will need to read the pollId they clicked from the GET or POST request, place that variable in your query, and display the results. It is a very standard thing for web programming.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hi, I am new to java. i want to use a switch statement on operators that are in read as strings. Like "==","!=",">=","<=".

Please help me to do this as i cannot use even their ascii value of these operators to switch the cases.

Switch statements can only be used on ints or enums. For strings you are stuck with if-else-if blocks or stucturing your code in such as way as to use subclasses to provide the behavior instead of a switch.

That said, if you really want a switch, you can provide a string switching capability with an enum if you code it right. Here's an example just for giggles

import java.util.HashMap;
import java.util.Map;

public enum Operator {
    EQUALS("=="),
    NOT_EQUALS("!="),
    GREATER_EQUALS(">="),
    LESS_EQUALS("<=");
    
    private final String token;
    private static Map<String,Operator> tokenMap;
    
    private Operator(String token){
        this.token = token;
        map(token,this);
    }
    
    private static void map(String token, Operator op){
        if (tokenMap==null) tokenMap = new HashMap<String,Operator>();
        tokenMap.put(token,op);
    }
    
    public static Operator forToken(String token){
        return tokenMap.get(token);
    }
    
    public static void main(String[] args) {
        String[] operators = new String[]{"<=","==","!=",">="};
        for (String opString : operators){
            Operator op = Operator.forToken(opString);
            switch (op) {
                case EQUALS: 
                    System.out.println("equals"); 
                    break;
                case NOT_EQUALS: 
                    System.out.println("not equals"); 
                    break;
                case GREATER_EQUALS: 
                    System.out.println("greater than or equal to"); 
                    break;
                case LESS_EQUALS: 
                    System.out.println("less than or equal to");
                    break;
            }
        }
    }
}

For your case though, you may as well just use an if-else block.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Life is too short,live out your dreams....

I fail to see why I should show up at school in my underwear unprepared for a test just because life is short.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you could get by with renumbering on insert alone, but go with whichever you prefer.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As long as the order of the lines does not change, why should it matter if there are gaps in the sequence? You can still sort them correctly with the gaps and generate the displayed line numbers yourself in the output as flagbarton indicated.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sure, just post the code that is not working for you or specific questions on concepts you don't understand. Certainly you aren't expecting us to just write it for you?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What language are you working in? "Module" is not very specific.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you been out of school for a while, it tends to be work or church!

Or the homeless shelter...
:P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
// to convert an entire string
String lowercaseString = originalString.toLowerCase();

You don't need 26 lines. You just call the toLowerCase() function on the string itself. That string can be a single letter or many letters.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, unless you are doing it for some algorithm assignment, then just use String toLowerCase()

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Dark energy and dark matter surely is a hoax perpetrated by a bunch of drunk frat boys!

The only physics most drunk frat boys are concerned with are those of beer bongs and getting laid.

(Not to imply those are not worthy pursuits though :) )

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is not really a "basic PHP template" per se, because web sites all have different needs. Granted, certain types of sites have certain standard functionality and there are templates for such things.

If you merely want to use it for layout, simply using the include function can let you break your pages into separate pieces like header.php (or .html files too), leftNavBar.php, footer.php, etc. and have these pieces automatically merged into all of your pages.

<html>
<?php include "header.html"; ?>
<p> other content stuff
<?php include "footer.html"; ?>
</html>

This of course does not even begin to touch the dynamic functionality of processing your pages with PHP, but with only a question about "layout" and nothing more specific perhaps it's a starting point for you.

If this just raises more questions than it answers, feel free to ask them!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Intresting note. Got a link here that I came across while looking this character up. http://www.alchemylab.com/AJ3-4.htm
That is just a collection of views of Hermes.
<snip>

Ouch! Holy Wall-of-Text there! Interesting comments, but please put a few paragraph breaks in!

... ok, back to your discussion...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

reCAPTCHA works well for us and was extremely easy to integrate
http://recaptcha.net/

iamthwee commented: nice +11
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

* Get the path of the returned file and somehow turn it into a class name.

I think that is your best option, but there are a couple of considerations to keep in mind.
1) you can reliably know the base path to the classes they have to choose from and the package structure is intact from that base.
2) you know or can determine the type of object being created so you can properly cast the Object from newInstance().

Given those two caveats, this tiny example illustrates using the selected file to load the class. I used two different variations for the baseDir, one which was on my classpath at the time of execution and one which was not. Both worked fine.

JFileChooser chooser = new JFileChooser();
int result = chooser.showOpenDialog(null);
if (result==JFileChooser.APPROVE_OPTION){
    File f = chooser.getSelectedFile();
    //String baseDir = System.getProperty("user.dir")+"\\build\\classes\\";
    String baseDir = "C:\\TEMP\\build\\classes\\";
    String className = f.getPath().replace(baseDir,"").replace(".class","").replace("\\",".");
    try {
        Class c = Class.forName(className);
        c.newInstance().toString();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

hi thanks for the reply can someone explain me more about the API for file locking

From FileChannel javadoc:

a file channel can be obtained from an existing FileInputStream, FileOutputStream, or RandomAccessFile object by invoking that object's getChannel method, which returns a file channel that is connected to the same underlying file.

The FileChannel has methods to obtain a FileLock object on all or part of a file channel. When no longer needed, FileLock.release() will release the lock.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The loop you are using is not actually a valid foreach. The foreach construct is used for iterating over a Collection or array.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html

Here is one example to print each char in a String:

public void hello( String st)
    {
        for(char c : st.toCharArray())
        {
            System.out.println(c);
        }    
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Applets are not started from the command line like a regular java program. You need to use the Java Applet Viewer or embed them in a small test web page. If you typed this program from a book then there are probably instructions there on how to run the applet. If not, read the following tutorial on getting started with applets:
http://java.sun.com/docs/books/tutorial/deployment/applet/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This will not be very easy to debug with just the code you posted, as there are several interacting classes here. If you do not have an IDE that will let you step through the code as it executes, then you will need to place assertions or System.out.println() statements at the various stages to verify what is being received and processed on the client and server side. I would recommend starting with testing what response the client is receiving. If that result is not correct then check how the server is processing the input. Good luck!

If you are getting specific exceptions or odd behavior you don't understand, post them back here and perhaps we can help.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First off, the code you posted is not even valid code. You have php and html mixed in together and no end form tag to boot. Have you even attempted to run this code yourself?

As far as session, you have not set the value of 'n' in the session. In your code, 'n' is a post variable. If you want it in $_SESSION[] you need to set the value yourself. If you only need it the one time, then just read it from $_POST[]. If it needs to persist, set it in $_SESSION[].

It is fairly obvious that you are not reading any of the tutorial links that were posted, but just expecting people to write the code for you. You need to take the time to read and learn from the tutorials and php manual as well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i guess it would be better live together in a rented apartment, and have two cars, (one that belonged to each other previously), and stuff...

It's certainly a lot easier that way if you want to avoid potential issues like the court cases that Christina alluded to. Living together you can at least get a feel for whether you are going to be able to stand each other for the rest of your lives =)

It takes a lot of patience for sure - and the realization that you aren't so perfect yourself, so keep it in mind when you expect perfection from your spouse!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well not exactly because as a married couple, you usually buy big things together, right?

Yes, things such as house, furniture, car, etc. It would be best to avoid purchases like that while merely living together prior to marriage. If you cannot share other lesser purchases and financial responsibilities while living together, you should just forget about marriage altogether.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't really think living together is such a good idea. I mean unless you're gonna act like roommates where... this stuff is mine and that stuff is yours. Financially, I think it gets messy... especially if or when you break up.

If you are considering marriage to the person, you are facing all of that anyway. Ownership of this or that matters little if everything is shared in an amenable fashion. It is only things like large joint purchases that present a problem and really should be avoided or handled very carefully.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why do you need to specify the size? Why must it be a longblob instead of just blob? If you have the answer to the questions then you know what size to set. This really depends on the data that you are going to store. Perhaps you need to read the documentation on the blob data type in MySQL.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i'm not married... but i'm seriously thinking on marrying this one... though i think it is a good idea to live together, to see how things work out... what do you think?

Personally, I would recommend it, though many others have religious/moral hangups regarding living together outside of marriage. Living together gives you a much better idea of how a marriage may work out. Just be wary of comingling financial obligations, as those can be rather tricky if things don't work out.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The MouseEvent getX() and getY() methods will return the coordinates relative to the source of the event. If your panel is not that source, you will have to compute the coordinates yourself by adding them to the coordinates of the source (which also has getX() and getY() methods) within that panel. It just depends on the layering of your components and which is the source of the mouse event. This tutorial has more info if you need it:
http://java.sun.com/docs/books/tutorial/uiswing/events/mousemotionlistener.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't have any output statements in there at all. You need to use print or echo (or some other appropriate stream output methods) if you want any output. What are you wanting to do with the data?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You have this same question going in two threads. Please limit these to a single thread to avoid confusion. I have responded in your other one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just run your query in the ActionListener as you had in the first listing. You will need to set the roll number as a parameter.

int rollNo = -1;
try {
   rollNo = Integer.parseInt( t1.getText() );
} catch (NumberFormatException nfe){
   JOptionPane.showMessageDialog(wscreen.this,"Not a valid roll number"); 
}
if (rollNo > -1) {
  PreparedStatement pstmt = Con.prepareStatement("SELECT * FROM s1 where RollNo=?);
  pstmt.setInt(1, rollNo);
  ResultSet rs = pstmt.executeQuery();
  if ( rs.next() ){
    // set output here
  } 
  else {
    // no record was found
  }
}

If there is a result (from .next() ), then simply set the data fields from that result. You can use a JLabel with HTML if you want a result that is similar to direct painting on the Frame, without the hassle of custom painting. Look up JLabel in the API docs for more info.

You can also define the prepared statement outside the listener and reuse it with different roll number parameters if you will be submitting it many times. I just showed it in there for convenience. Don't forget to always close statements when you are done with them, as some drivers don't release those on their own very well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You do not want to be overriding paint on the Frame to display data. If you do need to override painting code, override paintComponent() on the appropriate component and be sure that you call super.paintComponent() if required. In any case, custom painting code is not called for here.

You should use an appropriate component to display your result data such as JTable, JLabels, or JTextArea. The choice will depend on what you are trying to display, as that is not very clear from your code.