~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Read the Sun socket tutorials for more clarification.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I see that ~s.o.s~ pointed you to an AJAX article.

It was because he mentioned Javascript hence a reference to the Ajax article was in order.

Or I can set a timer using Javascript for a function to be executed from time to time to send asynchronous requests to the server and check if there are any new messages? but this seems not so efficient...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Questions related to specific Javascript libraries are better asked in the respective forums for a quicker response.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i just thought you guys would of liked a challenge lol

I have got enough challenges in my daily life, I guess I'll just pass. :-)

But don't give up hope, who knows, masijade might just end up dropping in a jar file here with a "meh" look on his face. ;-)

caps_lock commented: thankyou for the hope! +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are many classes in the java.nio package which have package visibility and hence don't show up in the Javadocs. Look into the Java standard library source in the java.nio package for more details on how to extend the ByteBuffer / MappedByteBuffer classes.

BTW, clicking on the USE link when browsing the Javadocs of a given class gives you complete information on all the classes which refer the given class, just in case...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

so just to add more detail because theyre may be confusion

Im basically trying to get files with equal file size first, then im trying to put those in an array, then the files in the array need to be compared possibily by length (bytes) (not file names but files contents), the comparison need to be made maybe by binary contents or by generating an MD checksum which ever ones easier.

Like it has already been mentioned by masijade, you have to make a stab at this and post again if you have any problems. Just putting in random conditional statements here and there won't cut in. Since you already seem to know the logic, you can at least try implementing it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It most likely seems to be a Javascript error which is causing your script to execute intermittently. Using Firebug should show you all the errors along with the line numbers; if you still aren't able to understand them, post the exact errors here along with the line numbers.

Also, please consider formatting your code; I can't seem to make anything out of it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> int generator1 = generator.nextInt(20)+1/2;

Operator precedence anyone?

> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */

I am surprised how someone can churn out such an unformatted code even after using an IDE / advanced text editor.

> class Math12 { /* */ }
> class Math5 { /* */ }
> class Math7 { /* */ }

The very fact that multiple classes are created which do the same thing is a clear indication of design problems with the application. Consider customizing the class instance by having constructors/factory methods.

...and many other things.

If your friend really wants to learn, tell him to start some serious reading. A lot of beginner resources are mentioned in the sticky; starting with the Java beginner tutorials ain't that bad an idea.

stephen84s commented: You must have really put in some effort to read all that <Ugh> code +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I don't do standalone application development using Swing, a few obvious comments.

> Class.forName("com.mysql.jdbc.Driver").newInstance(); .

You don't need to do this for every invocation. As soon as the Driver class is loaded, it registers itself with the DriverManager and that's it; no more Class.forName() required. Also, you don't need to create a new instance, just doing Class.forName() is sufficient.

> String computer = ""; .

Try to avoid this. String computer = null; is good to go.

> getConnection("jdbc:mysql://IP_ADDRESS:3306/DB", "USERNAME", "PASSWORD"); .

Don't use magic numbers/literals in your program. Either load these configurable parameters via an external resource [properties file] or at least move them to a separate class/interface as constants and refer them throughout your application.

> public void Refresher() throws SQLException .

Follow Java coding conventions; don't use uppercase characters for method names. It is a bad programming practice to expose checked exceptions to your client[given that the method is public]. Since a SQLException is almost always unrecoverable, catch it and either rethrow it wrapped in your own application specific Exception class or just log the exception for debugging/troubleshooting/analysis purposes.

You never release your database resources! You need to close the ResultSet , Statement and Connection object. Read the JDBC tutorials for more information.

public void some() {
  Connection conn = null;
  PreparedStatement pStmt = null;
  ResultSet rs = null;
  try {
    try {
      //grab connection
      // use statement and resultset
    } finally {
      if(rs != null) …
Ezzaral commented: All good suggestions. +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What do you mean by *doesn't work*? No output, doesn't work as expected?

Use Firefox with the Firebug addon for development which provides a means of debugging Javascript code, inspecting variables etc. If you have any Javascript errors, they would be shown in the Firebug console. Search the web for Firebug tutorials to help you get started with Firebug.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A piece of advice: use a debugger, given that we have no way of reproducing the scenario and the code posted so far looks OK.

BTW, why are you catching a NullPointerException ? Catching unchecked exceptions without any kind of processing is *always* a bad practice and screams of a pre-condition check. Instead put null checks before closing the database resources [like result sets and statements].

Connection conn = null;
Statement stmt = null;
try {
  try {
    // do something
  } finally {
    if(stmt != null) stmt.close();
    if(conn != null) conn.close();
  }
} catch(Exception e) {
  e.printStackTrace();
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I worked with ajax, I can do this with a submit button, but when I i
> put the form tag, not work any more.

It worked because Ajax doesn't depend on a FORM element for shipping data to and fro; it uses the XMLHttpRequest object for this purpose.

Also, doesn't work is a pretty useless description, we need more description or a sample snippet which showcases the problem at hand.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Given that the problem description is pretty abstract, there isn't much I can comment on though here are a few thoughts.

I am pretty sure there is nothing which an advanced Javascript toolkit like YUI/jQuery/Dojo *can't* do. Have you tried asking your queries in the concerned forums since there are many things which aren't apparent when using a library? Asking or discussing with people who have been using the library for production use might shed a new light on things.

Also, looking at a sample online SQL designer might help your cause.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but i am able to recieve just 1 image i think only the first snapshot

...because it seems that the ImageIO. read() ends up reading the same byte representation of the image over and over again since there is no mechanism of moving ahead or skipping to the next image stream in the client loop.

To get around this, fire off multiple requests from the client which ends up serving the byte representation of the image at that point in time. Or you can write out the list object which holds the byte representation of the given image to the socket stream [using ObjectOutputStream ] which would then be deserialized by the client [using ObjectInputStream ] to retrieve the list object. This obviously involves the additional overhead of serialization/deserialization and makes heavy use of ImageIO.read / ImageIO.write .

Also, to serve multiple requests, you need to modify the server implementation to continuously wait for client requests and process each request in a separate thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Are you sure you are not overwriting the file by not providing a unique file name for each image? Also, a working sample of the code which showcases your problem might go a long way in getting people to respond to your queries.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't change the contract specified in the problem statement; don't change the invocation; change the logic which resides in the overloaded methods.

// Error handling and input sanity checking left out for
// brevity
public static void main(String[] args) {
  double salary = 10000.0;
  String str = /* accept the commission in double format */;
  double comPct = Double.valueOf(str);
  double com = compute(salary, comPct);
  
  str = /* accept commission in integer format */;  
  int comInt = Integer.valueOf(str);
  com = compute(salary, comInt);
}

public double compute(double salary, double comPct) {
  return salary * comPct;  // e.g. 10,000 x 0.07
}

public double compute(double salary, int comInt) {
  return salary * (comInt / 100.0); // e.g. 1000 x (7/100.0)
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Indeed, given that the underlying protocol used in almost all the cases, viz. TCP is connection oriented i.e. following the request/response model, you have to resort to some sort of callbacks or regular polling. Frankly speaking, asynchronous I/O, push pull technology etc. are pretty advanced concepts, not to be messed if you are just starting out. But anyways, to get started read this article which provides a sneak peek into Asynchronous messaging.

For creating standalone IM clients [not web based], look into the different protocols specifically aimed at IM, especially XMPP.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't see any import for the Base64 class? Have you rolled in your own implementation of Base64 or are you using a library which provides such an implementation?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is there a way to display the source of the iframe or the html file
> that is being displayed in the iframe in the web browsers address
> bar?

AFAIK, no. It seems pretty logical that the URL in the address bar doesn't change given that the user hasn't navigated away from the resource/web page and is shown new content which is shipped to and fro via remote scripting.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is with the inner classes present in the Base64.java file. Post the code present in the Base64.java file. Also a little background on what exactly are you doing in Training.java would be helpful.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but i dont think it has had any change in the list of results brought
> to the terminal window

And what were you expecting by checking if the file size is less than or equal to one byte?

Maybe posting/uploading a virtual directory structure along with the expected output might help others in collaborating for a better solution.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Eclipse and it gave me a red box error message saying "the import
> java.xml can not be resolved"

...because a package by the name java.xml.* doesn't exist; it's javax.xml.* Refer the Javadocs for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As per the rules laid down, we provide help only to those who put in some effort to solve their problems; handing out free code is not encouraged here. Give your lab assignment a go, post the problems you face and then someone might help you out on this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A quick useful update: to know the airing date for your favorite ongoing anime, use the AnimeCalendar online service; useful, effective. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Can you be more specific please .
> I know that int data type store/hold integers or whole numbers.

It's pretty simple; you just need to create two methods which have different contracts defined as part of the problem definition. One takes in a double precision number of the form x/100 [e.g. 0.07 for 7%] and the other takes in an integer of the form x [e.g. 7 for 7%]. Some test invocations would look like this:

double comPct = 0.07;
double comm = compute(salary, comPct);
int comInt = 7;
comm = compute(salary, comInt);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

hello...i am confused,,it is possible that a linkedstack will be full??i only implement a method that isEmpty(),,and it reads the method if the stack is empty..but if the stack is full, it do not even read the method i made....would someone help me?/,,,thank you ahead...

The Collection classes of Java increase in capacity on demand. If the number of elements added to an ArrayList exceed its default capacity, it grows on demand automatically to make space or room for the newly added elements.

The only practical limit to the number of items that can be added to a List is the amount of physical memory allocated to the process [java process] and hence there seems to be no reason or need to implement a isFull() method for a collection class. If you need such a behavior, either subclass the AbstractSequentialList class to add an upperbound to the number of elements that can be added or just use arrays if the exact number of elements are known.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Detection of duplicate files isn't that simple; refer a similar thread. If that's not what you intend, a bit more explanation is needed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Javascript, at least broswer embedded Javascript can't do this in a standard compliant way; moving to VB section.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How at that point is it not possible to figure out that sending a PM
> to xxx will fail?

Technically, it's pretty much possible. I guess what you speak of is a default vBulletin behavior and hence remains that way. Though such things don't happen very often, it's but logical that such a check be in place.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but whats problem with this syntax?

The changes to internal implementation of the model [business logic + data] which affect the view which shouldn't be the case. Also a design which employs separation of concern is far more easier to maintain, change and troubleshoot.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

*Ahem*, time to bring this thing on topic.

> i have to submit project in java....next month.....
> please help me.....

As per the rules laid down, we provide help only to those who put in some effort to solve their problems; handing out free code is not encouraged here. Give your project a go, post the problems you face and then someone might help you out on this.

masijade commented: Well, at least someone's trying to rescue this thread. Sorry 'bout that. ;-) +11
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Re MD5: I guess we are talking about two different things here: security and file uniqueness, hence the confusion. I would personally use MD5 hashing since it seems to be a widely used technique for testing file uniqueness and optimize if and only if required. Also, coming up with a good hash solution [if that is what you were suggesting to the OP] is far from a walk in the park, though it seems to be a good exercise in learning more about hash functions.

> Yep-- the OS will generally automatically cache data read from file.

If you are talking about kernel file caching which results from reliance on system calls to do I/O, memory mapping the file solves that issue.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> is there any solution that IE will not block my java script so the IE
> user's can directly see it

Simply put, no, otherwise there would be little point in providing security settings for browsers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want to execute an action [i.e. send a HTTP request] without reloading the page, you have two options:
- Remote scripting via hidden IFRAME
- Using the XMLHttpRequest object to make async requests

./sos

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> it's designed to be a secure hash function, and trades
> performance for that security

Maybe you got that the other way around since a lot of vulnerabilities or staged attacks have been found with MD5 making it a unsafe choice for security applications.

> a good-quality 64-bit hash function should be ample

Doesn't seem like a wise choice given that the MD5 algorithm which used 128 bit has been compromised.

IMO since many still sites still use the MD5 checksum to check the integrity of downloaded files, the situation with MD5 isn't as bad as it seems.

> in Java is that Java provides no way to signal to the operating
> system to read files without going via the file cache

File cache?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A bit more explanation here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I want to insert byte array in database schema as follows

Where is this byte array coming from? If you are reading the contents of a file into a byte array which you are then trying to insert into the database, better use the methodsetBlob(int, InputStream, long) to avoid reading into a temporary byte array.

If it is a standalone byte array which you are trying to insert into the database, use the method specified above by wrapping the given byte array into a ByteArrayInputStream.

Something like:

byte[] bArr = /* grab the byte array */;
ByteArrayInputStream bIn = new ByteArrayInputStream(bArr);
/* relevant code */
pStmt.setBlob(paramPos, bIn, bArr.length);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Checking out that huge chunk of code for Javascript errors is quite a herculean task.

To ease your development, I would recommend that you carry out your development testing in Firefox and make use of the excellent addon "Firebug" which provides features like Javascript error notifications, debugging facility and much more. If there are any Javascript errors, the error console will point out to you the exact line on which the error has occurred.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Actually there are two reasons why a thread won't receive an answer. The first reason of no effort being put in by the poster is already explained in detail in the above post.

The second reason why a thread isn't replied to would simply be that no one knows the answer to that query! Though not very frequent, there are certain API specific questions [e.g. jQuery related queries in the Javascript sub-forum] which are best answered in the specific forums meant for them [e.g. the jQuery message board].

Also queries which involve sifting through loads of code are sometimes avoided by members. To fix this, try to localize the issue and come up with sample snippets which reproduce the problem at hand.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

On the mentioned web page there are no frames, only inline frames; they are different things and also handled differently.

In the second URL you posted, the function invoked on a link click is loadintoIframe() while for the first URL you posted, the function invoked is getPages() . Changing the function call in the first page to javascript:loadintoIframe('myframe','text17.html'); seemed to work. Maybe invoking the loadintoIFrame function twice, once with 'myframe' and the next time with 'myframe2' might solve the issue at hand.

Don't use the javascript: i.e. javascript pseudoprotocol, it's not required. When developing with Firefox, make sure you use the Firebug addon which adds capabilities like javascript debugging and many other goodies. Your web page doesn't have a DOCTYPE declaration which makes the browser go in quirksmode which loosely means that the rendering engine won't know which HTML specification to follow when rendering the markup.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can apply trim() method on the given string to trim leading and trailing whitespaces. Also since str forms a part of the URL, make sure you URL encode the string so that special characters are taken care of [e.g. &, ; etc.].

One question though: How did a newline character manage to find its way into a text field?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The check for email == undefined is superfluous since a value of text form field, if it exists will never be `undefined' or `null' but always a empty string if nothing was entered. You should rather check the return value of getElementById() so that you don't end up trying to access the `value' property of something which doesn't exist. Also the above validation can be easily bypassed by entering just whitespaces. Maybe a trim is in order?

function validate() {
  var e = document.getElementById('emailId');
  if(!e) return false;
  var txt = trim(e.value); // here trim() is a custom function
  if(txt === '') {
    alert('Please enter an email id.');
    return false;
  }
  return true;
}

./sos

kanaku commented: he owned me +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Reading the Base64 article along with some sample implementation should give you a start; if you still have a query, post a specific question.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i came on this web site thinking i could get genuine help .

...which most people here get, really.

> within minutes of posting a question you mark it solved and
> forget about it

Only a moderator or the one who posted the thread can mark the thread as solved.

> how do i unsubscribe from this useless site.

AFAIK, just stop visiting the site and all your woes will be gone.

But as a concluding note, I hope you do realize that the question you posted has got absolutely *nothing* to do with Javascript programming; something this forum is meant for. Instead of trying to understand why your query was not resolved you blame the forum for not providing proper help? If you can't be patient and modest when receiving *free* help, I am sorry to say that you would be returned the same attitude on almost every message board out there.

BTW, this seems to be a browser issue which can be easily fixed by posting in a proper sub-forum or getting a different browser like Firefox 3 to see if the problem really persists. For the time being I am marking this thread as unsolved and moving it to an appropriate sub-forum.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nailing down the problem would be very difficult given that we can't reproduce the scenario here. Maybe looking into something along the lines of a Javascript debugger which helps you step thru your application and at the same time show the HTML markup which was dynamically rendered might work out for you. Look for Firebug, a Firefox addon for the above mentioned features; it might just help you out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> is this... your homework?

Seems that way; anyways without a decent effort, getting any kind of help is difficult.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> It's RegEx() NOT RegExe()

It's `RegExp' not `RegEx'.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the array() method of ByteBuffer class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Only limitation I found .... in parameter which has default value must
> be the last one in the param list

AFAIK, this is not a limitation but a logically sound decision. If this wasn't the case, it would be difficult to distinguish between an invocation which uses default parameter values and one which doesn't.