java

Is it possible to download a binary file from JSP?

I think is it quite possible, but I'm not sure. I don't have the possibility to use servlet directly, so I'm forced to use JSP ( long history, short time, you don't want to hear ) So I think something like the following will do: // PSEUDO-CODE: // source.jsp Download your file <a href="file.jsp?xyz">MyDocument.doc</a> // file.jsp ...

changing return type of method gives java.lang.NoSuchMethodError

I changed the return type of one method in an interface in a library. Previously it was void and I modified it to return an object. I did not change the code in my module as I did not want to do anything with the returned object(it was for a different module) I compiled my module with the new library jar and ran unit tests which ran fine...

Can JAXB parse large XML files in chunks

I need to parse potentially large XML files, of which the schema is already provided to me in several XSD files, so XML binding is highly favored. I'd like to know if I can use JAXB to parse the file in chunks and if so, how. ...

Problem with JDICplus embedding IE in Java

I am building a Java Swing application that needs to support both an embedded browser and ActiveX. The easy way to do this seemed to be to use JDICplus, which just embeds IE in your application. That would have covered both requirements. I also need to overlay some buttons on top of this browser view so the user can navigate between vie...

Seeking explanation for Auto-Casting

So I just spent around an hour trying to unveil and resolve a very strange bug, one that I have never seen before. I am more or less asking for potential causes of this seeming random cast from enum to String rather than "please fix my code for me". The gist of the problem is as follows: I have an interface, call it IFoo, within this ...

writing a Comparator for a compound object for binary searching

I have a class, and list of instances, that looks something like this (field names changed to protect the innocent/proprietary): public class Bloat { public long timeInMilliseconds; public long spaceInBytes; public long costInPennies; } public class BloatProducer { final private List<Bloat> bloatList = new ArrayList<Blo...

Part of path returned from Directories Only JFileChooser is sometimes duplicated

In my application, I want the user to be able to select a directory to store stuff in. I have a text field that I'm using to display the directory they've chosen. If they just click on a directory (don't browse it), everything is fine. However, if they double click on the directory and look inside it, the directory name is duplicated. E...

Servlets and Tomcat

Hi, I'm working on an application. I have a servlet (writeDataBase.class) that writes some information in a database. This is working fine. My folder structure looks like: webapps/HelloWord/web-inf/classes. In folder 'classes' is where the file writeDataBase.class is placed. web.xml looks like: <servlet> <servlet-name>HelloWord</serv...

missing something obvious in JMX console insertion

I'm following the directions for launching my hello world JMX bean and jboss complains with the following: nested throwable: (java.lang.NoSuchMethodException: com.testPackage.jmx.TestJmxMBean.<init>()) I know I'm missing something REALLY obvious, but can't spot what it is. Why would it be looking for an init method? the class extends...

Map database column1, column2, columnN to a collection of elements

In legacy database tables we have numbered columns like C1, C2, C3, C100 or M1, M2, M3, M100. This columns represent BLOB data. It is not possible to change anything it this database. By using JPA Embeddable we map all of the columns to single fields. And then during embedding we override names by using 100 override annotations. Recen...

In Java, throwing an exception when a network connection is lost during a WebService Call (similiar to WCF CommunicationException)

Hey guys, I'm dealing with an auto-generated WebService stub in Java (generated using JAX-WS RI). My actual service is a .Net program exposing its webservice using the WCF basicHttpBinding. How should I be dealing with Communiction problems during the actual WebService call. (i.e. the way in WCF on the client you would wrap your call...

java: datainputstream: do read calls take up processor time while waiting for data?

If I call read() on a DataInputStream, will it take up CPU cycles waiting for data or does it yield the current thread and get woken up by an interrupt signaling that data has arrived? My motivation for asking the question is to determine whether or not a stream reader needs to be in its own thread or not. A blocking read that takes up...

Why won't my Facelets loop variable go out of scope?

Hi! I know this looks like a lot of text, but I think it's a pretty simple concept I'm missing. I'm writing a web application with Facelets. I've got a custom tag rq:request-list that takes a list of requests as a parameter and outputs a lovely table to display them. So far, so good. rq:request-list starts out like you'd expect: <!--...

What's the most efficient method of continually deleting files older than X hours on Windows?

I have a directory that continually fills up with "artefact" files. Many different programs dump their temporary files in this directory and it's unlikely that these programs will become self-cleaning any time soon. Meanwhile, I would like to write a program that continually deletes files in this directory as they become stale, which I'...

Google AppEngine Session Example

I just enabled Session in my Google AppEngine/Java + GWT application. And how do I use it? How do I get session ID and play will all good stuff from it? Are there any real examples of simple login page where I'm just entering LoginName and Password, then it goes to the server over RPC call, authenticates against database and sends Sessio...

problem compiling a junit test class with ant

Hello, I am having issues integrating junit with a working ant build.xml file. My test class is in the same directory as my source classes. As I am learning how to use ant, I simply want to compile all the source and the test classes. I am using eclipse and the junit test classes work fine when execute through eclipse. Which means the ...

Use Different Password for entity manager in auto-generated Netbeans code

I am using the NetBeans IDE along with Java. I do want to distribute a database password/login in persistence.xml, but allow it to be set by the user/installing person in a config. The NetBeans IDE created a persistence.xml file for my connection that contains all of the database connection information and auto generates the code below:...

Java: Why can't I cast this to an Object?

This is bizarre... I thought every object in java had Object as an ancestor. I have a ClassA that extends my ClassB and implements Runnable. After creating ClassA I cannot cast it to an Object. Assume getClassA returns a ClassA instance. I am doing Object obj = getClassA(); I also tried Object obj = (Object) getClassA(); I get...

Scala equivalent of Java java.lang.Class<T> Object

The question is best explained by an example: In Java for a JPA EntityManager, I can do the following(Account is my Entity class): Account result = manager.find(Account.class, primaryKey); In Scala, my naive attempt is: val result = manager.find(Account.class, primaryKey) But when I try to use Account.class in Scala, it seems to n...

EJB vs Spring + POJO

What advantages does EJB have to be stacked with Spring? Why couldn't I just use Spring Entity Manager, Security, and POJOs to do what EJB does? ...