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

Most likely the Ajax result is being cached; append a random tidbit to your URL, preferably something like timestamp to have a distinct URL for each request to prevent this caching. If you are using an URL like /YourApp/Upper append it with /YourApp/Upper?t=timestamp .

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

There can be an indefinite amount of time between the sending of request by 'n' number of users, not to mention you need to remember who has sent a reply. There is anyways only a single servlet instance; for each user request a new thread is allocated from the container thread pool and the service() method of the Servlet is called.

As far as the "how" part is concerned, it would be difficult to explain the entire solution here. One naive solution would be to use a database to maintain the counter for an operation; after 'n' number of users have requested an operation, you invoke that operation.

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

Paste the entire servlet code which you are using.

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

...when rock-n-roll for really rock-n-roll. ;-)

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

Maybe her point was that it's a long standing vBulletin bug which hasn't been fixed till now...

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

> We are planning to make a commercial GUI based software (for both desktop and
> mobile) targeting individual users

IMO, Adobe AIR has the slickest desktop UI out there but suffers from the lack of mature libraries for almost anything when compared to Java/.NET. Personally, I find Swing applications to be kind of sluggish. If you decide to go the Java route, SWT/JFaces is something you should look into.

> Which one has best Rapid Application development tools?

Eclipse and Visual Studio are probably the best IDE's out there, the difference being, Visual Studio requires a license.

> What are licensing costs w.r.t development IDE, client tools/framework etc as well
> as royalty based costs associated with distribution of software

AFAICT, anything created using Java + open source tools/frameworks doesn't require you to have a license or pay any sort of royalty. You'd require a license to develop using Visual Studio but distributing applications created using Visual Studio doesn't require you to pay any sort of royalty; though I'd confirm this in the appropriate forum (C# forum) since I don't develop using Visual Studio.

If you are interested in developing using MS toolchain but feel deterred by the licensing costs, you might want to look at Mono and MonoDevelop.

> What would be the best database option available for such software

Database for what? Does you software require being connected to a centralized server for …

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

Daniweb has an IRC channel. Read me.

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

> So you mean to say I'm lying ?

*facepalm*; sarcasm detection.....failed. :-)

> Its surely not anything to do with latest FF release

A couple a things we'd like to confirm:
- Have you tried flushing the browser cache?
- Does this happen only with *nix + FF or with *nix + any browser?
- Does programmingforums look the same way?

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

doGet method maps to the code executed when your servlet receives a "GET" HTTP request. doPost method maps to the code executed when your servlet receives a "POST" HTTP request. These methods are internally called by the `execute` method of your servlet (a lifecycle method) based on the HTTP method of the request received.

If you have specifically created a servlet which handles only POST requests (uploading etc.), you'd normally override the doPost method. Any other HTTP method used to access your servlet would result in a "method not supported" exception (well technically it isn't *any* other method but you can ignore the difference for the time being).

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

Because Servlet/JSP is just a specification, the programming language still is Java. You don't learn a framework, you learn the language. There are a gazillion specifications/frameworks out there, you can't be possibly thinking of learning them all, do you?

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

Yes, absolutely.

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

From what I've heard, calling native code using JNI is a real PITA. Look into alternatives like JNA and Swig for easing this integration task.

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

> Does this mean that i need to do this for every servlet? Which is not efficient.

Yes, it's not efficient. The best approach when dealing with database resources would be using the connection pooling capabilities offered by your container. In case of application servers like Glassfish, Jboss etc. look into the application server documentation for creating a connection pool and exposing it over JNDI using the admin console of that app server.

In case you are using a simple container like Tomcat, Jetty etc. look into the documentation provided to get a list of configuration files which need to be changed/created to expose a connection pool over JNDI.

In case you are required to programatically manage your connection pools, look into the discussion present in this thread and post if you still have issues.

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

> But, whenever derived class object is created, memory is assigned to base class
> members too

Yes, memory is assigned for all those member variables of the base class but there is no *separate* base class object created. The fields and methods which can be inherited are *inherited*. When you extend an existing class, you end up with a class which has everything that the super class has along with the members/methods declared for your new class. AFAICT, the concept of super classes is just a logical abstraction language designers have come up with to facilitate re-use, polymorphism etc. Also, why should an object of class A be created when I have specifically asked the runtime to create an object of class D?

> we can access the base class fields using super. Isn't super a reference to the
> base class object

A quick quiz; what does the following snippet print:

package gone.to.heaven;
class MyClass {
  public static void main(final String[] args) {
    MyClass c = new MyClass();
    System.out.println(c.superToString());
    System.out.println(c.toString());
  }
  public String superToString() {
    return super.toString();
  }
}

In case you were wondering, it prints the same thing both the times which is gone.to.heaven.MyClass@123456 .

Another quick quiz; does the following piece of code compile?

class MyClass {
  public void doSomething() {
    Object obj = super;
  }
}

No, it doesn't, because there is *no* `super` object which can be assigned to `obj`. `super` is a language feature/abstraction which …

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

To find out which JAR a given class belongs to, use a service like GrepCode. It tells you all the possible JAR files which has that particular class along with providing download for the same. For e.g. here's the grepcode result for the JAR file which uses the class XmlRpcClient.

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

The way I see it, there is no such thing as the "base object" in memory. For the given code snippet, there are only 3 custom object instances in memory. One of type B, C and D each; no A instance.

public class MemTest {
    public static void main(String[] args) {
        D d = new D();
        d.doIt();
    }
}

class A {}

class B {}

class C {}

class D extends A {    
    private C c;    
    private B b;    
    public D() {
        super();
        c = new C();
        b = new B();
    }    
    public void doIt() {
        System.out.println("HI");
    }
}

If you don't call `super.finalize()` inside the overridden `finalize` method of your subclass, the finalization of your subclass instance would complete and the space will be reclaimed *without* the finalize of the super class be invoked. This might be undesirable in cases where the `finalize` method of the super class is responsible for releasing scarce resources held by it (e.g. file handles).

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

AFAICT, the container has no way of knowing that it has to switch to HTTPS given that the forwarding happens within the code executing on the server. A resource is just a resource and by itself, it has no way of knowing whether it has to be served over a normal channel or a secure channel. Also, I think the configuration placed in the web.xml which relates to external requests made by the client and not internal forwards done.

Instead of doing a forward, try redirecting to that resource. It if still doesn't work, post your web.xml configuration along with the relevant piece of code you are using.

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

> But why will it decide to call the finalize() of D and C before A ?

AFAICT, as per the specification, the Java programming language makes no guarantee regarding the order in which finalize method is called on the "finalize eligible" objects.

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

> So is it necessary to successful software engineering or just option?

Absolutely necessary if you are working with a dynamically typed language like Python, Ruby etc. where values have types, variables don't. In the absence of unit tests, aggressive re-factoring becomes risky due to the lack of compile time checks and you end up with breaking existing code if you are not careful.

Not really necessary when working with statically typed languages like Java which offer decent compile time type safety. Changing method signature, class name, method name etc. results in compile time errors. Changing logic still requires proper verification but there's nothing which a decent testing round can't uncover. Though I must admit the turnaround time for testing a new/changed functionality is pretty short when it comes to unit testing.

The greatest pitfall when advocating unit tests is that it ends up giving developers/managers a false sense of security. Unit tests are not magic; they end up testing code the way you have "written" it to be tested. Countless times I have seen code bases littered with "unit tests" which did nothing more then instantiating the class to be tested and invoking random methods here and there.

Discipline is of prime importance when it comes to writing unit tests. I strongly recommend junior team members/programmers/unit testers being mentored by someone who *knows* his stuff to avoid turning the entire application unit test code base into a big pile of useless ****. :-)

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

Have you tried to understand the client examples posted on the official XML-RPC site? IMO, something like client.execute("System.listMethods", new ArrayList()) or client.execute("system.listMethods", new ArrayList()) should do the trick.

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

This is because the getObject() methods returns an Object and the Object class doesn't have the methods `getName` and `getAge`. You either need to cast the object returned by the `getObject` method to `Data` or "generify" your List class so that it accepts a type parameter just like the ArrayList class of JDK.

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

Post a "compilable" and "short" piece of code which demonstrates your problem.

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

> How have I changed, hehe? :)

You look more...mature? ;-)

Joking aside, your photos at the event are certainly different from the ones in your avatar and profile.

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

Hi ~s.o.s~,

i still have "Cannot forward after response has been committed" error, even i have changed the code accordingly. Can help me take a look and advise me what is wrong with my code? =( Thanks.

~s.o.s~,i really thank for your help.

<%
            if (request.getAttribute("login") == null) {
                RequestDispatcher dispatcher =
                        request.getRequestDispatcher("/login.jsp");
                dispatcher.forward(request, response);
            }
            if (request.getAttribute("cash") == null) {
                RequestDispatcher dispatcher =
                        request.getRequestDispatcher("/login.jsp");
                dispatcher.forward(request, response);
            }
%>

You still haven't made those changes; like already mentioned if both 'login' and 'cash' are not present, you end up doing a `forward` twice. Replace the second `if` with an `if..else` and it should work out fine.

Also, try rewriting your code. Put the forwarding logic in a Servlet and have three conditional checks instead of the two present right now. Create three JSP's; no_cash.jsp, no_login.jsp and normal.jsp. Inside the servlet, write something along the lines of:

protected void doGet(HttpServletRequest req, HttpServletResponse res) {
  if(noLogin) {
     // forward to no_login.jsp
  } else if(noCash) {
    // forward to no_cash.jsp
  } else {
    // forward to normal.jsp
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It seemed like a fun event though it was unfortunate that not many could show up due to personal/geographical reasons. BTW, Dani, you sure have changed a lot. :-)

Ok. So I recognize
- Davey
- Dani
- WASDted
- Tekmaven

Ditto here. After trying to read the name tags attached, I thought I saw Toba/Blud/Aia in the crowd, though I could be mistaken. ;-)

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

When it comes to Derby, LAST has a special meaning. Instead of using 'LAST' as your column alias, use something like LNAME; it should work.

SELECT admin_lname as lname from admin
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That query you posted doesn't have any use of 'AS'? Post the query which doesn't work for you.

> I will have to figure out how to replace 10.5.3.0 with the new version

Use the new 'bin' folder when starting the server and use the new client libraries when accessing the server using JDBC.

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

So, which line exactly has the NPE? Also, have you taken a look at the generated servlet for this JSP?

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

I personally feel that the design is a bit weird:
- A class called MyArray which has member variables as arrays of all types
- Constructor accepting an array of type T (a specific type) along with accepting a `type` parameter?

Regarding the code; byteData = input won't work because input is an array of type T which in turn can be anything which extends Number (Float, Integer etc.) whereas byteData is an array of byte. A very similar reasoning with the `get` method; switching on `type` which is a value obtained at runtime just won't cut in. Generics is implemented using erasure; all the type hints you specify are compile-time only. Hence any use of generics which relies on the values of variables at runtime won't work.

How about something simple like:

class WrapperTest<T extends Number> {
    
    private T[] array;
    
    public WrapperTest(T[] source) {
        array = source;
    }
    
    public T get(int idx) {
        return array[idx];
    }
    
}

WrapperTest<Integer> wt = new WrapperTest<Integer>(new Integer[] { 1, 2, 3 }); // OK
WrapperTest<String> st; // won't work; String doesn't extend Number

Knowing the specific requirement in this case will help those reading this thread suggest a better alternative (memory/time efficient) if one exists.

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

Yes, it's the same major version I'm using (10.5.1.1). Paste your table creation script with the "exact" query you are trying to execute; I might just give it a try. For the time being, download 10.5.1.1 instead of using 10.5.3.0 and try out your script on that version. If it works, then you'd have to take this to the Derby forums.

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

Have you tried this on some other *nix distribution like Fedora, Gentoo etc? If they manifest the same problem, it can be confirmed that this isn't a Ubuntu specific problem and more so a problem with the Java implementation for *nix. If the same issue doesn't show up, then you are better off asking the same question in Ubuntu official forums since this might be something "Ubuntu specific".

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

Though I haven't used them, Apache PDFBox and iText seem promising.

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

IMO this question would be more appropriate on the Lucene mailing list; much better chance of getting a quick answer. Anyways, have you read up on the Javadocs of the given class/method; there is a possibility that the contract defines the existence of duplicates?

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

> but is there java code that is equivalent to this

Yes, look into the `forward` method of the `RequestDispatcher` interface. Read this.

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

Ensure that the required JARs are on the runtime classpath. You can download the required JNDI JARs from here.

Also, paste the entire stacktrace along with the tutorial you are referring to for others reference.

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

Decide a preference for your NULL checks; should the NULL check for `login` be performed before the NULL check for `cash` or vice versa. Use ELSE IF instead of just IF for the second conditional check.

When you forward, you are effectively saying that the forwarded page now has the responsibility of rendering the response. Forwarding to a page effectively "commits" /finalizes the response. Forwarding twice i.e. forwarding after the response has been committed results in an IllegalArgumentException as per the servlet specification.

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

Difficult to say anything without looking at the JSP in consideration. You can also try taking a look at the generated servlet for your JSP (process_jsp.java).

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

I guess the difference between read/unread links would take some err... time to come back. :-(

For those interested, I've created a small greasemonkey script which differentiates between read/unread links by changing the style of the link text. The attachment shows how the Java forum looks in my browser.

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

> Most ad blockers simply hide the ads, but they don't stop them from being downloaded

But Adblocker plus + NoScript don't work that way. Given that they are Firefox addons, they never request the blocked URL.

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

> so i want the logging to be the crosscutting concerns.i.e as i read the xml and
> display the data,the logging also happens

In layman's terms, a cross-cutting concern is simply any task or requirement which doesn't belong to any single layer and yet is required by all/some of the layers. For e.g. logging is a cross cutting concern because even though layers require that their processing be logged, it per-se isn't a responsibility of any of the layers. The business layer is concerned with implementing the business logic, the DAO layer is concerned with data access etc. Or it can be said that logging is a concern which "spans" across layers.

Fundamental to the concept of AOP is the concept of weaving, wherein the AOP implementation "weaves" aspects into your code. AFAIK, there are three ways of doing this:

  • Compile time weaving: wherein you use a special compiler to modify your existing code based on the aspects written.
  • Load time weaving: wherein you weave the aspects into your classes as they are being loaded, typically by specifying an external JVM agent implementation.
  • Runtime weaving: The approach adopted by frameworks like Spring wherein proxy classes are created to implement AOP. This is the most limited approach to AOP for obvious reasons; e.g. you can intercept on public method calls. Typical enterprise applications which use the Spring framework for assembling their components adopt this approach.

That being said, the implementation in your specific case …

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

> I just don't really know what I would have to do to make this instantiation legal

Ensure that the Main class and the Parent class are placed in the same package.

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

Which version of Derby DB are you using? I can make those statements work perfectly fine with Derby 10.5.

BTW, is the name of your table actually "table"?

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

`yourapp` is the name of your web application. You need to create a controller/servlet which accepts some input parameters and generates the images on fly which are then sent to the client. A simple example would be:

public class ImageServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException {
		String graphType = request.getParamter("type");
		// read other data like graph parameters
		BufferedImage img = generateImage(graphType);
		response.setContentType("img/png");
		OutputStream os = response.getOutputStream();
		// write data from BufferedImage to the servlet output stream
	}
}

In you deployment descriptor, map this Servlet against the path "/img". You can then use this servlet like:

<img src="/MyWebApplication/img?type=first" /><br />
<img src="/MyWebApplication/img?type=second" /><br />
<img src="/MyWebApplication/img?type=third" /><br />

Oh and when posting code the next time, use code tags. Failure to do so would result in your post being ignored by the regulars here; read forum rules for more details.

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

As far as the theory is concerned, Pagination simply means fetching the data in chunks or "pages" rather than fetching it all at once. The obvious advantages are reduced server/database load since only records that are required to be displayed/processed are retrieved. Pagination becomes a necessity when dealing with user requests/queries which fetch thousands of records due to the unacceptable time delay in fetching the records & displaying/rendering them.

There is also a concept of client side pagination which involves fetching the entire data *but* displaying only a section of that data to the client. The advantages of this approach are purely cosmetic (displaying data to user as and when required) and it still suffers from the performance problems mentioned above.

As far as implementation is concerned, you can refer this article for ideas.

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

Your OS/CPU architecture limits the maximum heap size you can allocate for your JVM process. Read this.

The setting for heap size depends on the IDE which you are using but for eclipse, see this.

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

> I want to know how to check gracefully whether 2 sets are distinct

Try using the Collections.disjoint() method for this.

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

1. Write your own retainAll() wrapper method which performs a NULL check since the one present in AbstractCollection doesn't.
2. Manually perform a NULL check

if(anotherSet != null && set.retainAll(anotherSet)) { // something }
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As a servlet developer you need to make up your mind -- whether to do the processing in the servlet and use it for sending a response to the client OR add/update request/session/application scoped parameters and let some other managed component (another servlet/jsp page) handle the processing/response creation.

The HTTP servlet specification creates an abstraction over the HTTP request/response model. Once response is sent to the client, it can't be *revoked* and a new one be sent. When you say `out.println()`, you are effectively pushing the HTTP response to the client or more specifically "committing" the response (assuming that your output buffer is already full). After that, any attempts at `forwarding` your request to some other resource for processing gives an IllegalArgumentException.

Does your server log show any exception stack trace when you make your request?

javaAddict commented: You know your craft +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>> String l = Doc +"\\"+ file;

The problem is with this line. Windows uses backslash (\) as the file separator whereas *nix uses forward slash (/) as the file separator. The simplest solution here would be to *not* manually create file names/path but use a method which automatically gives you a list of File objects in a directory.

File dir = new File(baseDirPath);
for(File f : dir.listFiles()) {
  if(!f.delete()) {
    System.out.println("Failed to delete file: " + f);
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How are you getting your connection object? As long as you are using a DataSource based connection pooling implementation to get your connection, it shouldn't be a problem when it comes to interacting with any number of databases.