java

Why are Data Transfer Objects an anti-pattern?

I've recently overheard people saying that DTOs are an anti-pattern. Can someone please explain why? What are the alternatives? ...

HttpURLConnection.getResponseCode() returns -1 on second invocation

I seem to be running into a peculiar problem on Android 1.5 when a library I'm using (signpost 1.1-SNAPSHOT), makes two consecutive connections to a remote server. The second connection always fails with a HttpURLConnection.getResponseCode() of -1 Here's a testcase that exposes the problem: // BROKEN public void testDefaultOAuthConsum...

Is there a framework or cocoa API for playing video?

In short, I want to create a simple video player which can play some major video formats like quicktime *.mov, for example. What I need is: video playback (at least the most major formats would be great) play, pause need information about where the movie currently is (how many seconds passed, or how much percent) I'm targeting the ma...

Creating/Accessing Maven repository in SVN through NetBeans 6.7 *Revised*

EDIT: Ok... so I've gathered that SVN shouldn't really be used for this... which makes sense, I suppose (why version individual files when the version should be a separate jar?). So we should use an internal server to host a repository management tool like Nexus (etc), and access that over http to pull down and put out dependencies. We ...

Running servlet class from another class

I just got a servlet class working in Eclipse. I was testing it by deploying it using App Engine, and it would prompt me to run as a Web Application. Now I want to run this code from another class. So I made another class and put "TestServlet ts = new TestServlet();" in the main function. When I run it nothing happens. Do I have to ...

JPA POJO as Data Object

What is the best practice in using JPA Entities? Since JPA entities are just POJOs, is it considered appropriate to use the object as a data object in other parts of the system or should I convert them to another data object? Is it acceptable to use the JPA Entity POJOs in other parts of the system unrelated to JPA? ...

Programmatically login to website from Java application

Hello Folks, I am using Apache's HttpCommons 3.1 package to login to a website. The website is jsp page with the form using j_security_check along with j_username and j_password. From a browser, I would do the following: o to the Login.jsp page fill in user name and password click on login button With the valid username and passw...

Parsing CSV input with a RegEx in java

I know, now I have two problems. But I'm having fun! I started with this advice not to try and split, but instead to match on what is an acceptable field, and expanded from there to this expression. final Pattern pattern = Pattern.compile("\"([^\"]*)\"|(?<=,|^)([^,]*)(?=,|$)"); The expression looks like this without the annoying esc...

C# SLN file approach in Eclipse (Java)

How does Eclipse handle excluding Java files in the project?? In C# the list of files in the project is handled in the sln file - There seems nothing similar in Eclipse!! Any ideas? ...

Wrong SQL for view object using Hibernate Annotations

I'm working on a hibernate entity mapping for a database view; when I do a criteria query against it, hibernate is generating bad SQL. Any help figuring out what the problem is with my mapping would be greatly appreciated! I have two mapped entities which I am trying to grab from a database view; the view has no other columns, just the ...

Presentation (Brown bag) ideas for a J2EE team

I need to give a brownbag to my dev co-workers. The team is a typical Java/J2EE team, mostly using the current technologies (Grails, Spring, Hibernate, EJB, Caching, Webservices, Messaging). I want to talk about something that we aren't using yet. Part of my reason for giving the presentation is to learn it myself too. And I don't care...

how to pass java beans to jsp page for jqQrid to display using json?

we are trying to use jqGrid with our jsp front end and java back end. this page is displaying a grid of contacts : jQuery(document).ready(function(){ jQuery("#list").jqGrid({ datatype: 'json', url:'gridContactDrv.jsp', mtype: 'GET', height:300, width:600, colNames:['First Name','Last Name', 'Company', 'Prima...

How can I know whether an instance of a class already exists in memory?

How can I know whether an instance of a class already exists in memory? ...

Anonymous inner class in groovy

I am looking into the groovy-wicket integration and lack of anonymous inner classes seems to be a problem when writing the event handlers. Is there a groovier way of writing this code import org.apache.wicket.PageParameters import org.apache.wicket.markup.html.basic.Label import org.apache.wicket.markup.html.link.Link import org.apache....

Library to embed 3D view in a swing app ?

I'm currently searching for a 3d library that I could embed in a Swing application. This library doesn't necessarily have to be a huge thing as I mainly intend to give a 3D representation of some shapes, and certainly rotate around them. My main concern is to get something as easy to set up and to deploy as possible. Do you have any c...

Any Way to Read JAAS Configuration File from Memory

We use JAAS in a heavily loaded web server. The configuration file is loaded from a file, System.setProperty("java.security.auth.login.config", "/config/jaas.config"); During profiling, we noticed that the configuration is loaded from file for every login attempt. This is an I/O operation we try to avoid. Is there anyway to store th...

Problems Building my java app using JOGL in Netbeans

I'm using Netbeans 6.7.1 and I have an application which uses the JOGL libraries. I can run my application just fine, but when I try to build it, I get this error: C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\RAGEUI\nbproject\build-jogl-template-impl.xml:12: The following error occurred while executing this li...

Pasting a Screen shot into a text area on a web page

Is it possible to take a screen shot (using the Print Screen) and paste it from the System Clipboard directly into a web pages text area field (which I would create)? Do I need a browser plug-in? Can Flash do this? **The solution only has to work in Internet Explorer. ...

Multipart tiff and EXIF metadata

In the tif format, when you add EXIF meta data it creates an new IFD (tif-direcory) and stores the exif metadata as fields. So when parsing a tif file with a single image and exif data is easy. But you can get multipart tiffs, where a tif can contain more then one image, the question is can each of these images have EXIF data? Does this...

Process M slow calculations on N threads in Java

I need to run N slow calculations (where N is a fairly large number) and would like to do so on M threads since the slow calculations have a good deal of IO wait time. I have put together a small example that works well for the case that all calculations succeed. However, if a calculation fails the desired behavior is to stop processin...