java

How to differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from a client?

Is there any way (in Java Servlet) to determine whether a HTTP POST or GET request is a result from a submission from a HTML form or otherwise? ...

Is it possible to make an eclipse p2 provisioning mechanism running *locally* ?

Eclipse 3.4[.x] - also known as Ganymede - comes with this new mechanism of provisioning called p2. "Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in general in this article on the Sun Web site. Eclipse has an extended wiki section in which p2 details are presented. ...

How can I identify references to Java classes using Perl?

I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file that is being searched (based on its path). For example find all valid referen...

Best way to go about serializing and deserializing an object without losing its listeners?

I have a serializiable object with listeners registered. Currently the list of listeners is stored in the object as transient. When the object is serialized and then deserialized, obviously the listeners are no longer registered. What would be the safest and best way to go about re-registering the listeners automatically once the object...

What are possible reasons for java.io.IOException: "The filename, directory name, or volume label syntax is incorrect"

I am trying to copy a file using the following code: File targetFile = new File(targetPath + File.separator + filename); ... targetFile.createNewFile(); fileInputStream = new FileInputStream(fileToCopy); fileOutputStream = new FileOutputStream(targetFile); byte[] buffer = new byte[64*1024]; int i = 0; while((i = fileInputStream.read(buf...

Servlet for serving static content

I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use (details). I am therefore looking to include a small servlet in the webapp to serve its own static content (images, CSS, etc.). The servlet should ha...

How to get real request URL in struts with tiles?

When you use tiles in struts and do request.getRequestURL() You get url to /WEB-INF/jsp/layout/newLayout.jsp instead of real URL that was entered/clicked by user, something like /context/action.do. In new struts versions, 1.3.x and after, you can use solution mentioned on javaranch and get real url using attribute ORIGINAL_URI_KEY at...

Distributed Processing: C++ equivalent of JTA

I'm developing a mission-critical solution where data integrity is paramount and performance a close second. If data gets stuffed up, it's gonna be cata$trophic. So, I'm looking for the C/C++ version of JTA (Java Transaction API). Does anyone know of any C or C++ libraries that supports distributed transactions? And yes, I've googled it...

Dealing with command line arguments and Spring

When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring? ...

When exactly plugin.xml files from dependencies of my plugin are loaded ?

Hello, I vahe eclipse rcp app. In my plugin A I use 3rd party plugin B. In plugin B there is plugin.xml with some extensions. In my plugin A I have added some extensions to extensions defined in plugin B, and it works. Now I tried to overwrite some values in some extensions from B in plugin A. Now, when I run app sometimes it uses old v...

SVNkit cannot create SVNRepoitory

I am trying to run a diff on two svn urls using SVNkit. The problem is that I get the error when diff.doDiff is called. org.tmatesoft.svn.core.SVNException: svn: Unable to create SVNRepository object for 'http://svn.codehaus.org/jruby/trunk/jruby/src/org/jruby/Finalizable.java' at org.tmatesoft.svn.core.internal.wc.SVNErrorManager....

Last Resource Optimization

I'm writing a Resource Adaptor which does not support two phase commit. I know there is an optimization technique called: "Last Resource Optimization". On JBoss your XAResource class should implement LastResource in order to have the optimization. My question is: how this can be done in WebLogic, WebSpehre, Glassfish, etc... ...

Storing objects for locating by x,y coordinates

I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle. For small sets of objects (~100) the naive approach of simply storing them in a list, and iterating through it, is relatively quick. However, f...

With Apache HttpClient, why isn't my connection timeout working?

My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set _moHttpClient.setHttpConnectionFactoryTimeout(30000); it looks almost like my timeout is not being picked up. Is there anywhere else I need to set a timeout to ensure this behaviour does not re-occ...

Double generic constraint on class in Java: extends ConcreteClass & I

Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint ? class Class1<I,T> where I : Interface1, Class2 : I I'm trying to do it like this: class Class1<I extends Interface1, T extands I & Class2> But the compiler complains about the "Class2" part: Type parameter cannot...

JAXB 2 in an Oracle 10g Webapp

I have a web application that uses JAXB 2. When deployed on an Oracle 10g app server I get errors as soon as I try to marshal an XML file. It turns out that Oracle includes JAXB 1 in a jar sneakily renamed "xml.jar". Does anyone know how I can force my webapp to use the version of the jaxb jars that I deployed in web-inf/lib over that...

Translate algorithmic C to Python

I would like to translate some C code to Python code or bytecode. The C code in question is what i'd call purely algorithmic: platform independent, no I/O, just algorithms and in-memory data structures. An example would be a regular expression library. Translation tool would process library source code and produce a functionally equival...

Java utility to validate string against NMTOKEN

I have some application code which generates XML documents, which are then validated against an XML Schema. The schema makes use of NMTOKEN types, and occasionally, the generated XML contains string values which are illegal NMTOKENs (e.g. they contain spaces or weird punctuation). The Xerces schema validation catches it OK, of course, b...

Is Java the best language for Mobile App Devlopment?

I was wondering what are the benefits of using anything else but Java for Mobile Application Development. ...

Workaround for Spring/Hibernate due to non-standard behaviour of UNIQUE constraint in MS SQL

There is a UNIQUE database constraint on an index which doesn't allow more than one record having identical columns. There is a piece of code, managed by Hibernate (v2.1.8), doing two DAO getHibernateTemplate().save( theObject ) calls which results two records entered into the table mentioned above. If this code is executed without ...