java

Customizing jsp pages

I would like to let users customize pages, let's call them A and B. So basically I want to provide a hyperlink to a jps page with big text box where a user should be able to enter any text, html (to appear on page A), with ability to preview it and save. I haven't really deal with this sort of issues before and would appreciate help...

should i use the web framework for implementing a bunch of external links that likely won't change?

i'm building my webapp using the wicket java web framework. there is one page that i'm building right now contains 20+ external links, a lot of them are pointing to the wikipedia pages. i'm currently hardcoding the url for all these links in the html page. i could definitely add these links by using the framework (wicket has a class fo...

solving this NullPointerException on java's binarySearch

I'm solving sphere's online judge shortest path problem. This bit of code is giving me trouble: int sourceIndex = Arrays.binarySearch(citiesIds,source); int destinationIndex= Arrays.binarySearch(citiesIds, destination); double [] distancesFromSource = g.distancesFrom(sourceIndex); int destinationDistance = (int)distancesFromSource[de...

Java: Converting String to and from ByteBuffer and associated problems

I am using Java NIO for my socket connections, and my protocol is text based, so I need to be able to convert Strings to ByteBuffers before writing them to the SocketChannel, and convert the incoming ByteBuffers back to Strings. Currently, I am using this code: public static Charset charset = Charset.forName("UTF-8"); public static Cha...

How to use the "classes" parameter of JavaCompiler.getTask()?

I'm trying to understand JavaCompiler.getTask(). I understand all the parameters except for the second to last one called classes. The Javadoc read: class names (for annotation processing), null means no class names but I don't understand what they mean. I found plenty of websites referring to JavaCompiler online, but none of them ...

Are there any Java open source projects with both integration and unit test suites?

I am looking for an open source Java project containing two reasonably complete test suites: a suite of integration tests and a suite of unit tests, for the same code. Note that I am only interested in developer tests, written with JUnit or TestNG. I ask this because I often see people saying that having both unit and integration tests...

How can I know when the text of an editable JComboBox has been changed?

I have an editable JComboBox where I want to take some action whenever the text is changed, either by typing or selection. In this case, the text is a pattern and I want to verify that the pattern is valid and show the matches that result in some test data. Having done the obvious, attach an ActionHandler, I have found that, for typing...

Calculating permutations using a Java annotation

I'm interested in calculating permutations for parameters for something like this: public class Movie() { @Selection(minimum=1,maximum=10) public Integer setLength() {} @Selection(minimum=1.1,maximum=5.5) public Double setCost() {} } So I can write something like List getPermutations(); so that I could get a list of eve...

What's the proper way to access an EJB3 Bean from within a Tapestry Page class?

I want to use an EJB3 from within my Tapestry Page class, I can do JNDI lookup for it, but it will me much convenient to use EJB injection or Tapestry IoC. Is that possible? ...

Avoiding instanceof when checking a message type

I have the following situation where a client class executes different behavior based on the type of message it receives. I'm wondering if there is a better way of doing this since I don't like the instanceof and the if statements. One thing I thought of doing was pulling the methods out of the client class and putting them into the mes...

What's a good FOSS java servlet session replication solution

I work on a very high volume public website running on Tomcat 5.5. Currently we require stickiness to a particular server in order to maintain session. I'd like to start replicating session, but have had trouble finding a good FOSS solution. I've written my own Manager (using memcached as the store) but am having trouble dealing with ...

Which libraries have been ported to different programming languages?

Since I am working with different Platforms and programming languages, I found there are many good libraries that are ported with different programming language than its original. For example JUnit and Log4j which has been ported into several different languages. Sometimes if I am already used to working with these libraries, I would fin...

where can i find javax.swing.*; package API?

where can i find javax.swing.*; package API? ...

How to analyze memory fragmentation in java?

We experience several minutes lags in our server. Probably they are triggered by "stop the world" garbage collections. But we use concurrent mark and sweep GC (-XX:+UseConcMarkSweepG) so, I think, these pauses are triggered by memory fragmentation of old generation. How can memory fragmentation of old generation be analyzed? Are there ...

How to evalute prototype js files through rhino script engine in Java

I am having problems evaluating a script.js file which is dependent of prototype.js. When i am trying to evaluate the script.js file through rhino script engine in java i got Script Exception like "TypeError: $H is not a function, it is java.lang.String.". How do I evaluate the files and how to include prototype.js and to define the prot...

Dependency among log4j appenders

I'm writing a custom log4j appender, and I want to rely on another configured appender as a fallback, in case my (Database) appender fails. How can I guarantee order of construction of the appenders? My appender's activateOptions() method tries to access another appender and fails because it's not constructed/registered yet. ...

How to schedule the code execution?

I am working on a web application where I need to schedule some code. I am using the quartz for that. Now the problem is I want it to work after every day, or say 24 hours. Please let me know how to do this. I have not done this before and I'm using the sample code from the scheduler API. ...

DB2 AS400 Java function always returns same value

Hello, I am writing a user defined function to DB2 on AS/400 in Java and the strangest thing happen.. I am always getting the same result from the function even when i am changing it, even if i am dropping it and create it again and even when i specify NOT DETERMINISTIC.. Does any one have ever encountered a behavior like that? ...

Property file string length limitation (JAVA)

Hi %, playing around with a property file i figured that there seems to be a limitation of 40char to save in a single property. I do the following: File configFile = new File("config.properties"); Properties props = new Properties(); props.put( "cc_server", "sort_of_a_long_string_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

How do you pass parameters to Hibernate's subselect tag?

The example at the end of hibernate section 5.1.3 does not show an example on passing parameters. There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level, although some DBMS do not support views properly, especially with updates. Sometimes you want to use ...