java

What is the purpose of java.math.MutableBigInteger?

java.math.MutableBigInteger is only available from inside the package. It inherits from java.lang.Object and there is only one subclass (SignedMutableBigInteger) which is only availible from inside the package. ...

Is there a method that calculates a factorial in Java?

I didn't find it, yet. Did I miss something? I know a factorial method is a common example programm for beginners. But wouldn't it be usefull to have a standard implementation for this one to reuse? I could use such a method with standard types (int, long...) and with BigInteger / BigDecimal, too. ...

Java Reflection getDeclaredMethod() with Class Types

I'm trying to understand Java reflecton and am encountering difficulties when working with non-Integer setter methods. As an example, how can I resolve the "getDeclaredMethod()" call below? import java.lang.reflect.*; class Target { String value; public Target() { this.value = new String("."); } public void setValue(Strin...

how to submit a form that will have dynamically (unknown) number of fields

I am trying to submit a form to a servlet (java). The form has a bunch of questions, each question has 4 radio buttons and the user selects one of them. I do not know the number of questions that will be in the form. It could be 10, 15, 12...depends on some other criterias. My question is what is the best way to retrieve the list of ...

Servlet Filters and the OSGi HttpService

I'm working on an OSGi-based application that uses org.osgi.service.http.HttpService which does not support the use of Servlet Filters. Before I realised that I wouldn't be able to use Servlet Filters I was planning to apply a couple of existing Filters. These Filters set the appropriate HTTP headers to: prevent caching of responses c...

TreeMap construtor

Hi. I'm having some problems with TreeMap constructors. I have a class with 2 TreeMaps<Client> inside it. A tree sorted by name and another sorted by number.(client class : String name, int number, ...) private TreeMap<String, Client> nameTree; private TreeMap<Integer, Client> numberTree; How do i build the constructors for this class...

Java anonymous class that implements ActionListener?

I was recently doing a programming assignment that required us to implement in code a program specified by a UML diagram. At one point, the diagram specified that I had to create an anonymous JButton that displayed a count (starting at one) and decremented each time it was clicked. The JButton and its ActionListener both had to be anonym...

JSF Richfaces frontend performance tuning

I've developed a web application using MyFaces 1.2.6 and Richfaces 3.3.1GA (just upgrated). Despite the ease of use, I found out that Richfaces components are very slow. I also found out that they didn't really take advantage of the browser caching mechanism, they keep sending some lousy JS file every request and other things. I really ...

byte[] to string to byte array conversion did not work fine in java

I have a byte array initialised like this: public static byte[] tmpIV = {0x43, (byte)0x6d, 0x22, (byte)0x9a, 0x22, (byte)0xf8, (byte)0xcf, (byte)0xfe, 0x15, 0x21, (byte)0x0b, 0x38, 0x01, (byte)0xa7, (byte)0xfc, 0x0e}; If I print it it gives me 67 109 34 -102 34 -8...

How to get request locale in OGNL?

Hi, I want to know how to get request locale in OGNL? For now I use <s:set var="locale" value='#session.WW_TRANS_I18N_LOCALE?#session.WW_TRANS_I18N_LOCALE.toString():"zh_CN"'/> This must assume that the initial value is "zh_CN". So I need to know how to get request locale in OGNL. Thx ...

Web hosting with Java

I'm looking for a new web hosting service; currently I'm using GoDaddy's Economy plan, but it offers only PHP server-side scripting. For my next project it looks like I'm gonna need to use Java. Currently I pay ~60 USD per year for both the domain and the web hosting plan. What web hosting service supports Java and isn't much more exp...

Call subclass constructor from abstract class in Java

public abstract class Parent { private Parent peer; public Parent() { peer = new ??????("to call overloaded constructor"); } public Parent(String someString) { } } public class Child1 extends parent { } public class Child2 extends parent { } When I construct an instance of Child1, I want a "peer" to ...

How to send a username between web service requests?

Basically the problem is this: There is a stored database procedure that takes a username as an argument and produces some XML data depending on it. It is called by a method with no arguments in an unsecured web service (let's call that web service WSA). There is also another web service (let's call it WSB) which is supposed to call WSA....

In Java what exactly does File.canExecute() do?

I have created a plain file which does not have execute permission but when I create a Java File object using this file's path/name and then call File.canExecute() I get true as the result, whereas I would expect this method call to return false. Can someone explain what I'm missing here? Solaris: $ touch /tmp/nonexecutable $ ls -l /t...

Connect PHP code to Java backend

I am implementing a website using PHP for the front end and a Java service as the back end. The two parts are as follows: PHP front end listens to http requests and interacts with the database. The Java back end run continuously and responds to calls from the front end. More specifically, the back end is a daemon that connects and ma...

How do I optimize this method for breaking a string in chunks?

Here's the method. I want to know if I am violating any best practices here or if I am doing something wrong as far as the language is concerned. private List<String> breakStringInChunks(String text, int chunkSize) { List<String> chunks = new ArrayList<String>(); String temporary = ""; int numberOfChunks = text.l...

Is Struts 2 available as an OSGi bundle?

I have a server application that consists of multiple OSGi bundles, some mine, some third-party. One of the bundles provides a web frontend using Struts. The necessary Struts libraries live inside the web front-end bundle. Now I want to add a second bundle that provides another web front-end, with different dependencies and a very diffe...

Are the names of default actions in Swing component's ActionMap standardized?

Say I have a standard Swing component like JSlider, but I want to slightly adjust the input map. Default input maps and action map are installed by look and feel, and I want to reuse some of the actions already available in ActionMap. To do that, I need to put ActionMap entry's key into the value of an InputMap's entry. I can easily loo...

How can I decode data with Base64 in IPhone

Hi My friend is using Base64 encoding standard in java. I am using IPhone how can I decode the data. and viceversa. There is org.apache.commons.codec.binary.Base64.decodeBase64 in java Thanks Deepak ...

How to guarantee Java instance control (without enum) in world of serialization?

In a world before Java 1.5 (so no enum) and with my object being serialized, how can I enforce proper instance control? I'm talking about a class like this, where, as far as I can tell, I'm not sure that instance0 and instance1 will always be the only instances. import java.io.Serializable; public final class Thing implements Serializ...