java

DIY Form handling, PRG, Validation

I would like to implement form handling for web apps. I'd like to implement PRG (post-redirect-get), as I believe it is the way to go in form handling (plays very nicely with reload and back button). However, I'm seeing that it complicates validation. Basically, when you post, you have the form state (as post parameters). However, if yo...

Java extend enum

Is something like this possible in Java. I want to take an existing enum and add more elements to it enum A {a,b,c} enum B extends A {d} /*B is {a,b,c,d}*/ ...

How to specify Http Request timeout parameter on Java servlet container

Hi, I'm trying to understand where I can configure a request timeout for all requests arriving to a servlet of mine (or all of my servlets)? Is that, as I think, a container property? Also, how does this affect different browsers? Do they all comply to the parameter the container dictates? Or maybe the request timeout time isn't even so...

Selenium - Could not start Selenium session: Failed to start new browser session: Error while launching browser

I am new to Selenium. I generated my first java selenium test case and it has compiled successfully. But when I run that test I got the following RuntimeException java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: Error while launching browser at com.thoughtworks.selenium.DefaultSelenium.s...

Refactoring List<Foo> to FooList

I have a number of collections of classes which I need to refactor into new classes. I'm using Java with either Eclipse or Netbeans. Currently I create the new class FooList with a delegate List<Foo> and then follow all the places where the code fails to compile. Is there a way to do this without breaking the code (and preferably a singl...

storing names and other information

I am creating a prison system where I need to store the names and because I need to print out all the prisoner information in one of the methods. I want to make it remember and store information such as name, id and crimes etc. How can I go about doing this? About the posted answers, I don't think it needs to be something that complica...

Unit test proper data structure creation

How would one test whether data structure built properly? I'm implementing kind of modified radix tree, and been wondering how do you check if your data structure builds up correctly. Consider a tree of TreeNode {String, Int} nodes. You always want to append new child to deepest node of value equal to 0, as in following example: Root,...

C# for Java/*nix programmers.

I am mainly a java programmer, using linux/os x for as long as i remember. I am extremely comfortable in emacs and usually prefer doing things through command line. I need to create a internet explorer addon for our next project. I need to intercept url ie is about to download and if they meet certain criteria pass it to our application...

Coding for cellphones

I have a old LG MG280 cellphone that I'd like to code some simple things for. It has Java support, but I know that it is not simply making a Java ME application. It has to follow some specific specs otherwise the app will not run. Does anyone know what those specs are? ...

GregorianCalendar

I am doing an assignment and it involves using the GregorianCalendar. The specs say I need to use setLenient(false); how do I do this? I also need to set a constant date (1/1/2009) so that the first day of my program is always that. It also says to access the day, month and year through this: get(1) //returns the year get(2) // returns...

Tree component in JSF

Hi What is a good tree component in JSF. I also want the user to be able to select one (using radiobutton) or more than one node (using checkboxes) from that tree component. Is there any existing component that meets my need? thanks Vikas ...

Java Subclassing, Possibly want to much???

I want something similar to protected, where only a class which implements the "protected" field and anything that subclasses it can access it. So, I want to be able to declare a variable in the base class as "private," but still be able to access it from a subclass. Perhaps this is against he very nature of the subclass, private, and/o...

java.lang.OutOfMemoryError: Java heap space

When i execute the project in Netbeans 6.5, while viewing the reports (jasper reports) jasperviewer opens, but not fully. and in output window it throws exception like this: Exception occurred during event dispatching: java.lang.OutOfMemoryError: Java heap space at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:58) at ...

how to grant an applet permission for the resource accesses it needs?

hi, i have a problem with define permission for my applet that would to spacial resource access like get user.name property or file system command like create,read, write directory or files... the applet must write any data -ex. images- that received from a web application in such files in temp directory with using user.name to make ...

Disable plugin contributions in eclipse RCP Application

Hi - I frequently had this problem and didn't find a solution yet: Whenever I write a new eclipse RCP based application and include plugins from the eclipse platform, I 'inherit' UI contributions from some of those plugins. Most of this contributions (Menu entries, keyboard shortcuts, property pages) are useful but sometimes I'd rather ...

Is it possible to run OSGi components within Weblogic 10.3?

Is it possible to run OSGi components within Weblogic 10.3? From what i have read it is not possible but im asking just to be 100% sure. There is no option to swap out WL 10.3 so there is no need to list any other application servers or OSGi containers. Thanx ...

How to manage M threads (1 per task) ensuring only N threads at the same time. With N < M. In Java

I have a queue of task in java. This queue is in a table in the DB. I need to: 1 thread per task only No more than N threads running at the same time. This is because the threads have DB interaction and I don't want have a bunch of DB connections opened. I think I could do something like: final Semaphore semaphore = new Semaphore(N...

Best way to get geo-location in Java

What is the best way to get geo-location in Java (freely if possible)? Update: Not from a GPS device. Basically how Firefox 3.5 / HTML 5 does it ...

Forth Interpreter in Java

Here I found a Simple Forth Interpreter implemented in Java. However I don't understand the significance of it if I want to use it? What could be the advantage of the Forth Interpreter: If the final compiled code to be executed by the JVM is still "Byte code" what would we the Forth Interpreter be doing? Will it help in writing effici...

private final static attribute vs private final attribute

In java, what's de difference between: private final static int NUMBER = 10; and private final int NUMBER = 10; both are private and both are final, the difference is the static attribute. What's better to use? ...