java

How to best use JTidy with a Spring servlet container?

I have a Java servlet container using the Spring Framework. Pages are generated from JSPs using Spring to wire everything up. The resulting HTML sent to the user isn't as, well, tidy as I'd like. I'd like to send the HTML to Tidy right before it's sent to the client browser. I'll set it up to work in development and be turned off in ...

How do I blur an image?

I'm trying to implement a blurring mechanic on a java game. How do I create a blur effect on runtime? ...

When to use a List over an Array in Java?

In Java, when would it be preferential to use a List rather than an Array? ...

Is Hadoop right for running my simulations?

have written a stochastic simulation in Java, which loads data from a few CSV files on disk (totaling about 100MB) and writes results to another output file (not much data, just a boolean and a few numbers). There is also a parameters file, and for different parameters the distribution of simulation outputs would be expected to change. T...

Mail for Blackberry's - multiple content attachments

Hi - We'd like to send a single email which has "multiple contents" attached. Scenario is that we'd like one content to be displayed if the email is read using a Blackberry and another content displayed if the email is read in a desktop email client. (Blackberry content would be just text, other devices should read the HTML content in...

Sun TLP for SL-500 course

Hi, I'm gonna do a Sun TLP (Technical Learning Profiles) exam so I can later instruct a SL-500 Sun course. The problem is, I have no idea what kind of questions are going to be presented, since the course is rather conceptual and not that practical. Can anyone shed some light on the questions they may ask for this particular course? ...

Calculate SHA1 or MD5 hash in iReport

How would one calculate an SHA1 or MD5 hash within iReport at report execution? I need to compare a pre-calculated hash against a database driven field (string). Using iReport 2.0.5 (Old) and Report Engine is embedded into a commercial application. ...

Better way to write this Java code?

public void handleParsedCommand(String[] commandArr) { if(commandArr[0].equalsIgnoreCase("message")) { int target = Integer.parseInt(commandArr[1]); String message = commandArr[2]; MachatServer.sendMessage(target, this.conId, message); } else if(commandArr[0].equalsIgnoreCase("quit")) { // Tell the...

Pie Chart sections out of order in JasperReports

I am creating a pie chart using a JRBeanCollectionDataSource. I create that with an ArrayList whose contents are ordered specifically. When JasperReports uses JFreeChart to generate the Pie, the content order is remixed in no apparent ordering. JasperReports 3.5.3 JFreeChart 1.0.11 Java 1.6 ...

Servlet "newspring" is not available

Trying to set up a new spring project and im having this issue where I get this error (HTTP Status 404 - Servlet newspring is not available) when I navigate to a page that I expect to get routed through to a controller. web.xml <servlet> <servlet-name>springapp</servlet-name> <servlet-class>org.springframework.web.servlet.Dispatcher...

In Groovy SwingBuilder, how do I attatch a closure to a JTable that fires when a cell is selected?

I have a JTable being constructed via Groovy's SwingBuilder. I'd like to attach a closure to the table that fires when a cell is selected, but I can't seem to find the right hook. How do I do that? ...

Creating temporary JMS jms topic in Spring

I'm trying to refactor some legacy code to use Spring to handle the jms connections to a mainframe service. I need to connect create a temporary topic for the mainframe service reply and set that as the message.setJMSReplyTo(replyTo); in the message before I send the message. Can anyone provide examples of this? I have not found anythin...

Android - Tabs, MapView, activities within tabs

Hi folks, We're in the process of writing an app that has 4 tabs: Map, People, Places, Events. The People, Places, and Events in the App show up as Icons on the map. By default the People, Places, and Events tabs each show a listview, custom rendered, displaying all the People, Places, and Events respectively. Now, right now each o...

Updating JSF datatable based on selectOneMenu values

Hi - I am attempting to create a JSF page where the user selects values in two selectOneMenu components. The values in these selections will then be passed to a SQL query to update a table displayed on the page. I've bound each of the selection items to an appropriate variable in the backing bean, but after changing the value selected...

Cleaning up code breaks binary compatibility

I'm working on a project which is being used by a number of people I don't know. We've done a fairly good job of bringing down the CheckStyle warnings and the thing is about a low as its going to get without breaking binary compatibility. The majority of the remaining warnings are caused by constants (public static final) missing the fi...

QuickTime HTTP Basic Authentication on Safari 4

I am using Mac OS X Leopard 10.5.8, which is running Safari 4.0.3. My cross platform Java app has an embedded native web browser with its own internal web server. Whenever the browser tries to serve up a file that needs quicktime (mov, mp4, m4v, etc) i get a username/password credential dialog. I can see every request coming through and ...

What's wrong with my random wandering algorithm?

I've created a 2 dimensional 'grid' for a game world I'm creating in Java. I'm having a problem with the 'wander' mode algorithm I've created. I noticed a problem that the objects would seem to favor the bottom right corner of the grid. I changed the algorithm and thought it was fixed. Today, while stress testing, I noticed that the p...

when write of OutputStream write bytes(internally), then why read of InputStream returns int????

MyWriter.java (execute this before MyReader.java) import java.io.*; import java.net.*; import java.util.* ; public class MyWriter { public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(1234) ; System.out.println("Server started...\n\n") ; Socket s = ss.accept() ; Output...

How to change the look of a disabled JButton in java

I am making a game and when I disable a button with setEnabled(false); the buttons turn grey which clashes with the other colors in the game. Is their a way to change the color of the button when it is disabled? ...

Safely casting long to int in Java

What's the most idiomatic way in Java to verify that a cast from long to int did not lose any information? This is my current implementation: public static int safeLongToInt(long l) { int i = (int)l; if ((long)i != l) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } ...