java

wildcard characters in struts-config, version 1.1

My application is using struts 1.1. I'm trying to group URL forwards, using wildcards. For example, if the action is like this: action path="/edit/product" type="classname" forward name="success" path=".myapp.main" action Replacing the first line above with action path="/edit/*" type="classname" doesn't work. Any...

Applet - 'java.lang.NullPointerException: null pData' when browser closed

I have one user who gets an error message when he closes his browser. This only happens when he has visited a page which contains my applet. It seems to have been registered as a bug at Sun but that was many years ago. He is using Java 1.6 and IE7. Has anyone seen this before and know a solution or work-around? java.lang.NullPointerExc...

Eclipse class version bug

In eclipse 3.4 I'm trying to do some performance tests on a large product, one of the included libraries is the vecmath.jar (javax.vecmath package) from the Java3D project. Everything was working fine and then when trying to run it yesterday I get this exception/error not long after starting it up: java.lang.UnsupportedClassVersionErro...

Cleanest way to find objects matching certain criteria in a java.util.List?

I could write myself a helper class that does this when given a functor, but I was wondering if there's a better approach, or if there's something already in the standard library (seems like there should be). Answers I've found on StackOverflow are all for C# which doesn't help me. Thanks ...

Can anyone explain thread monitors and wait?

Someone at work just asked for the reasoning behind having to wrap a wait inside a synchronized. Honestly I can't see the reasoning. I understand what the javadocs say--that the thread needs to be the owner of the object's monitor, but why? What problems does it prevent? (And if it's actually necessary, why can't the wait method get ...

Using Apache commons FileUpload

This just won't work. The problem is that I do not know enough to even know what is supposed to happen. I can't debug this code. I'd like to store upload to temporary folder "temp" and then to move them to "applets". Please help? The servlet is obviously being accessed, but I can't find the uploaded files... Thanks in advance. Form (wh...

declare JSP taglib directives in web.xml

Hi, I seem to remember reading that it's possible to declare taglib directives such as: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> in web.xml. This eliminates the need to duplicate this directive in every JSP file where the taglib is used. Could someone tell me how these directives can be added to web.xml? Chee...

Migrating Java UNO code from OpenOffice 2.4 to 3.0

I had a nifty small tool written to convert spreadsheets to plain text. Since it was my private hacker tool, it relied on OpenOffice 2.x to read the files. But when I installed OpenOffice 3 and tried to get it get it to run, I failed miserably, because I'm either missing some JAR files or half the classes have been replaced. I'm includ...

How to transform time value into YYYY-MM-DD format in Java

long lastmodified = file.lastModified(); String lasmod = /*TODO: Transform it to this format YYYY-MM-DD*/ ...

How to get the system HTTP proxy configuration in Java

Is it possible to get the system proxy configuration in Java? In the Java Control Panel, you can set a proxy configuration. How can I access to that proxy configuration in order to open URL connections behind a proxy? ...

ant filtering - fail if property not set

I've got a ant build.xml that uses the <copy> task to copy a variety of xml files. It uses filtering to merge in properties from a build.properties file. Each environment (dev, stage, prod) has a different build.properties that stores configuration for that environment. Sometimes we add new properties to the Spring XML or other config...

Creating friendly urls to dynamic resources in struts2

I have a struts2 application with a single page that may show one of a number of values stored in a database. The application is for a school with many departments and each department has many programs. The department page is accessed using a url like this department.action?id=2 and the DepartmentAction will load the Department with i...

How to sanity check a date in java

I find it curious that the most obvious way to create Date objects in Java has been deprecated and appears to have been "substituted" with not so obvious to use lenient calendar. So... How do you check that a date given as a combination of day, month and year is a valid date? For instance a date 2008-02-31 (as in yyyy-mm-dd) would be in...

Catching window.print() from SWT Browser

Hi, I 'm exploring for a browser solution / API that has the following features: Must support the nowadays default web technologies Must support client side XSLT Must support executing arbitrary Javascript on the pages it loads Must be able to catch events from the web page targeted to the browser or OS (I am specifically interested in...

Java Timestamp valueOf

I came across a code snippet like this: Timestamp expiryDate = Timestamp.valueOf(dateStr + " " + "23:59:59.000"); Here dateStr is a string entered by the user in a form, in the format yyyy-mm-dd. Now the behavior of Timestamp.valueOf is such that it converts non-existent dates into appropriate proper dates. Say 31st June 2008 into 01s...

Resetting the time part of a timestamp in Java

In Java, given a timestamp, how to reset the time part alone to 00:00:00 so that the timestamp represents the midnight of that particular day ? In T-SQL, this query will do to achieve the same, but I don't know how to do this in Java. SELECT CAST( FLOOR( CAST(GETDATE() AS FLOAT ) ) AS DATETIME) AS 'DateTimeAtMidnight'; ...

Hibernate returns invalid results with composite key.

I'm getting the strangest results. I have a class with a composite key. If i do the following query: from LOVEJB l order by l.canonicalId desc my results are not ordered by the 'canonicalId' column I asked for. Instead, the canonical id result is like: 823 823 822 823 ,,, Can someone give me some pointers on how should I tr...

Java: What is java.awt.Component.getName() and setName() used for?

What is java.awt.Component.getName() used for? It always seems to be null in the applications I build with netbeans. I'm thinking of storing some help text per component in it -- I don't want to use the tooltip, I have another panel where I'll show the help text. ...

Convert Word doc to HTML programmatically in Java

Hi, I need to convert a Word document into HTML file(s) in Java. The function will take input an word document and the output will be html file(s) based on the number of pages the word document has i.e. if the word document has 3 pages then there will be 3 html files generated having the required page break. I searched for open source/...

Java: Any way of squirreling an object about a Component somewhere in the Component?

As a followup to my question about the java.awt.Component.getName() property, I'm wondering if there is a way of squirreling an arbitrary object somewhere in a Component, similar to the tag property in .NET? This would be really handy for any code that does work to a component but doesn't necessarily know what that component is. For ex...