java

Java Programming - Spring and JDBCTemplate - Use query, queryForList or queryForRowSet?

My Java (JDK6) project uses Spring and JDBCTemplate for all its database access. We recently upgraded from Spring 2.5 to Spring 3 (RC1). The project does not use an ORM like Hibernate nor EJB. If I need to read a bunch of records, and do some internal processing with them, it seems like there are several (overloaded) methods: query, que...

Unhandled exceptions with Java scheduled executors

Hi, I have the following issue and I would like to know what exactly happens. I am using Java's ScheduledExecutorService to run a task every five minutes. It works very well. Executors completely changed the way I do thread programming in Java. Now, I browsed Java Doc for information about what would be the behavior in case the schedul...

XSS and Applet/Param HTML Keywords

I have a Web application and have run a XSS scan on it and it reports that one of my pages that has a Java applet in it could potentially be open to XSS. The test managed to assign a javascript alert box to the following HTML code: <param name='id' value='' onMouseOver=alert(40041)> My question is - Is this a valid test? Will doing ...

Promotion in Java?

The rules for promotion is "when operands are of different types, automatic binary numeric promotion occurs with the smaller operand type being converted to the larger". But the operands are of same type for example, byte=byte+byte // Compile time error... found int.. So why is it so? ...

How to Pass hidden variable using displaytag

I am developing application using spring web mvc.. For displaying purpose i am using displaytag library.. Here is the code for that : <display:table uid="intf" name="${model.interfacesList}" id="interfacesList" pagesize="5"> <display:column property="id" title="ID" /> <display:column title="Name" property="name"/> <display:col...

Where I can find Axis WSDL2Java file?

I downloaded Axis 1.4 ( http://www.nic.funet.fi/pub/mirrors/apache.org/ws/axis/1%5F4/ ) and I wanted to use WSDL2Java, but I didn't find such a file from package, but there are refrences to this file ( http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL ) in their site. Where I can get that ...

How can I listen to Windows events from a Java app?

I have a process written in C++ that raises a named event using CreateEvent. Is there a java implementation of the WaitForSingleObject function? Is there a better way to pass events between a C++ or .NET process and a Java process? (I am aware of the option to use JNI to wrap whatever calls I want. I am looking for a library that alrea...

Why getToolTipText is never called?

I have got a JComponent. The paintComponent Mehtod is overridden. I mentioned that tooltips were not occuring reliable. Sometimes they were displayed and sometime they didn't. Now I dont't see tooltips anymore on this component. I overwrote getToolTipText(MouseEvent e) to specify the contents of the tooltips. But the methods getToolTipTe...

extract data from .xls file

I want to extract data from a Excel file and store them into a access database, how to do this? ...

Detect underlying cause for java.io.FileNotFoundException

FileNotFoundException is thrown on all sorts of occasions - not necessarily only when the file name is invalid, but also when e. g. permissions do not allow a file to be created or read: java.io.FileNotFoundException: \\server\share\directory\test.csv (Anmeldung fehlgeschlagen: unbekannter Benutzername oder falsches Kennwort) at jav...

Understanding context.xml in tomcat 6

Hi! I created a mainly empty dynamic web project in eclipse. It has no servlets no jsp files The web.xml is <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocatio...

Java Generics - vanishing type information?

OK - I know that Java generics can be a minefield for the unwary, but I just came across a non-intuitive (to me anyway) behavior that I was wondering if anyone can explain: First of all, here's a class that compiles: public class Dummy { public List<? extends Number> getList() { return new ArrayList<Number>(); } public ...

Eclipse plug-in - Finding source parts location

I am writing an Eclipse plug-in that should modify the source code in the Java editor. How can I figure the location of the source section like class declaration imports class fields methods and so. ...

Is the Default Servlet a (de facto) standard?

Related to this question, is the idea of a default servlet that serves static content a standard (even if a de facto one) across servlet containers, or does its use restrict deployment to Tomcat / Jetty? For example, [1] shows this method for getting the default dispatcher: final RequestDispatcher rd = getServletContext().getNamedDis...

Strategy in java to clean up / remove unused map elements

Hi, I'm implementing a "manager" in my web app that can be called to set and get which web site context the current thread is in (we white label our site so the web site context represents which site we're on) I'm trying to work out what the best strategy to do this, currently I'm implementing the store of Threads to WebSiteContexts...

Hibernate N+1 from select across multiple tables

Given the following hibernate query: String sql = "select distinct changeset " + "from Changeset changeset " + "join fetch changeset.changeEntries as changeEntry " + "join fetch changeEntry.repositoryEntity as repositoryEntity " + "join fetch repositoryEntity.project as project " + "join fetch changeset.author as cha...

Java floating point arithmetic

Hello I need to do some floating point arithmetic in java as shown in the code below: public class TestMain { private static Map<Integer, Double> ccc = new HashMap<Integer, Double>() { { put(1, 0.01); put(2, 0.02); put(3, 0.05); put(4, 0.1); put(6, 0.2); put(10, 0.5); put(20, 1.0); pu...

Too many open file handles

I'm working on a huge legacy Java application, with a lot of handwritten stuff, which nowadays you'd let a framework handle. The problem I'm facing right now is that we are running out of file handles on our Solaris Server. I'd like to know what's the best way to track open file handles? Where to look at and what can cause open file ha...

SimpleDateFormat and locale based format string

Hi, I'm trying to format a date in Java in different ways based on the given locale. For instance I want English users to see "Nov 1, 2009" (formatted by "MMM d, yyyy") and Norwegian users to see "1. nov. 2009" ("d. MMM. yyyy"). The month part works OK if I add the locale to the SimpleDateFormat constructor, but what about the rest? I...

Using groovy AST Transform for modifying java

Would it be possible to use groovy ast transformations code to manipulate java classes? If yes, please give an example. If no, please specify why. ...