java

Spring Dispatcher Servlet not working

I am trying to create a a simple Spring dispatcher Servlet as a base for my application. I want to initialize logging and security in the controller and then redirect the user to my application. I have tried several examples from the net, but it is not working. Please share with me a complete code so that I could try it. I do not want a...

Generate Ant build file

I have the following project structure: root/ comp/ env/ version/ build.xml build.xml build.xml Where root/comp/env/version/build.xml is: <project name="comp-env-version" basedir="."> <import file="../build.xml" optional="true" /> <echo>Comp Env Version tasks</echo> ...

Javafx with JMF

Hello, good Afternoon, I do not speak English, but I have a problem: I can't play videos with JMF using JavaFX for my GUI. I need the RTP JMF API and I'm getting this error: Unable to handle format: MPEG, 352x240, FrameRate=29.9, Length=126720 Unable to handle format: mpegaudio, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed,...

Using Jakarta HttpClient to mimic a POST network request

I try to mimic a network request send by a closed source application. The following is the network request snapshot captured from the closed source application : - Http: Request, POST /%5bvUpJYKw4QvGRMBmhATUxRwv4JrU9aDnwNEuangVyy6OuHxi2YiY=%5dImage Command: POST - URI: /%5bvUpJYKw4QvGRMBmhATUxRwv4JrU9aDnwNEuangVyy6OuHxi2YiY=%5dIma...

Does a Java class get loaded if I access MyClass.class.getName()?

I want to explicitly initialize some classes during the initialization of my application using Class.forName, but in order make that code survive refactorings, I want to use this: Class.forName(MyClass.class.getName()); I wonder: Wouldn't the class be loaded as soon as the getName method is executed thus making Class.forName unnecessa...

java annotations: library to override annotations with xml files

Java has annotations and that is good. However, some developers feel that it is best to annotate code with metadata using xml files - others prefer annotations but would use metadata to override annotations in source code. I am writing a Java framework that uses annotations. The question is: is there a standard way to define and parse m...

Android Framework?

Are there any frameworks out there which make it even more easy than it is to build Android applications and would you be interested in one? ...

Writing methods in jasper report?

I am creating a jasper report.In that I want to write one method which takes integer and does some process and returns a string.I dont know how to write methods in jasper report.Is it possible to write?Can any one help me in this I am using iReport3.6.0. Sample code : <textField> <reportElement x="400" y="10" width="80" height="15"...

Hibernate: Clean collection's 2nd level cache while cascade delete items

I have a problem Hibernate does not update 2nd level cache for a collection of items which are subject of cascade removal. Details Assume we have an object Parent which has Parent.myChildren collection of Child objects. Now we have also object Humans with Humans.myAllHumans collection and all Parent and Child objects are in that collec...

Set properties from .properties file in .jar on JVM startup

How can I setup the JVM to automatically load a .properties file in .jar on the classpath on JVM startup? I do not want to configure the properties on the commandline (with -D) but have them in a .properties file. Is there a way to configure this with the help of Maven? ...

Java - TreeSet and hashCode()

I have a quick question about TreeSets and hashCodes. I have a TreeSet and I'm adding objects to it, before I add an object, I check to see if it exists in the TreeSet using the contains method. I have 2 distinct objects, each of which produce a distinct hashCode using my implementation of the hashCode method, example below: public int...

J2EE:error in displaying ERROR page

i have created a jsp contains <% int i=10; if(i==10) throw new ArithmeticException("ItsMyGenExcepetion"); %> i have made entry in web.xml <error-page> <exception-type>java.lang.ArithmeticException</exception-type> <location>/errordisplay.jsp</location> </error-page> i have my errordisply.jsp contains <%@ page isErrorPage...

Order of JAR loading inside EAR's APP-INF/lib

Will adding a MANIFEST.MF file with Class-Path attribute to META-INF directory inside EAR influence the order of loading of JARs located in APP-INF/lib under WebLogic 8.1? ...

How can I know if tomcat is running behind Apache?

In production we run tomcat behind apache, in development bare tomcat. How can I know inside the Servlet class if it is running behind apache or not? ...

Handling Errors (e.g. OutOfMemoryError) within servers

What is the best practice when dealing with Errors within a server application? In particular, how do you think an application should handle errors like OutOfMemoryError? I'm particularly interested in Java applications running within Tomcat, but I think that is a more general problem. The reason I'm asking is because I am reviewing...

Traversing tree made from DefaultMutableTreeNode tree

We have a tree structure implemented using the DefaultMutableTreeNode specified in Java. Is there any way of traversing it, that is inbuilt? If not, please suggest other techniques. ...

Message to a client from the server

Hi, I have to design a client/server system emulated on a website running Ruby on Rails that should work like this: a page is requested by a web browser and once it's opened the server can push messages to it I know this is not possible "naturally" but I was thinking of a sort of "java applet" that is running on that page, listening on...

Ctrl-Delete in JTextField

How can I get JTextFields to allow Ctrl-Delete and Ctrl-Backspace when editing text? In various other programs, these key combinations can delete an entire word in one go. From what I can tell, the default behaviour of a JTextField allows the user to use CTRL to jump over an entire word when using left and right keys, and to select an ...

Locking strategy with PropertyChangeListener

I've defined a class with a number of "observable" properties. Internally the class contains a single thread that performs I/O; e.g. public class Foo { private final PropertyChangeSupport support; private State state; public Foo() { this.support = new PropertyChangeSupport(this); } public synchronized State getState() { retur...

What are best development practices for multi JRE version support?

Our application needs to support 1.5 and 1.6 JVMs. The 1.5 support needs to stay clear of any 1.6 JRE dependencies, whereas the 1.6 support needs to exploit 1.6-only features. When we change our Eclipse project to use a 1.5 JRE, we get all the dependencies flagged as errors. This is useful to see where our dependencies are, but is not u...