java

How to perform string Diffs in Java?

I would need to perform Diffs between Java strings. I would like to be able to rebuild a string from the original string and diff versions. Does anyone has done this in Java? What library do you use? String a1; // This can be a long text String a2; // ej. above text with spelling corrections String a3; // ej. above text with spelling co...

Webservices client and ssl

Hi I have a Java client that calls a web service at the moment using the Http protocol. When i try to use the Https protocol i keep getting this error java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big. Any ideas what could be up? Thanks Damien ...

How do I sort a list of integers using only one additional integer variable?

How to sort list of values using only one variable? EDIT: according to @Igor's comment, I retitled the question. ...

Can a web service return a stream?

Hi all, I've been writing a little application that will let people upload & download files to me. I've added a web service to this applciation to provide the upload/download functionality that way but I'm not too sure on how well my implementation is going to cope with large files. At the moment the definitions of the upload & downlo...

Maven dependency exclusion for War file, but inclusion for tests

I have a maven POM file for a web service. For one of the dependencies I have to specify several exclusions for jar files that are already kept at a higher-level in the web-application server (accessible to all web-applications, not just this particular one). One example of such exclusion is the JAR containing my JDBC driver. Example (w...

Different layouts and i18n in JSP application

I have a bunch of JSP files and backend in Tomcat. I have 3 different versions of JSP with same logic inside but with different layouts. So if I change some logic I have three JSP file to fix. What is the proper soution for such a scenario? I thought of some XML and XSLT stack: backend gives only data in XML and than for each layout I h...

Do you prefix your instance variable with 'this' in java ?

And... we have another QAW (Quality Assurance War) on our hand. After reading the more generic "What kind of prefix do you use for member variables?" question, I tried to argue with my QA department about the advantages to always add 'this' before instance (or member) variables in java code. They are not convinced. I know there is a si...

What is the best way to generate XML Binding Code from a DTD?

Most Java-XML binding frameworks and code generators need XML Schema Defintions. Can you suggest the best way to generate binding code from DTD. I know that the XJC in JAXB 2 supports DTD but it is considered experimental. In the spirit of Stack Overflow, one suggestion per answer please - to be voted up or down instead of duplicated ...

How do you force a maven MOJO to be executed only once at the end of a build?

I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run. Using: if (!getProject().isExecutionRoot()) { return ; } at the start of the execute() method means my mojo gets executed once, however at the very beginning of the build - before all other child modules. ...

What is the list of JConnect error-codes?

I have recently changed an application from storing the database username and password in a configuration file (gasp password stored in plain text in a config file, I know, I know). The application now asks the user to type in her username and password before it can continue. The new version of the application now has to interrogate th...

How can I discover resources in a Java jar with a wildcard name?

I want to discover all xml files that my ClassLoader is aware of using a wildcard pattern. Is there any way to do this? ...

Are there any emulator for the JTAPI API?

We want test the JTAPI feature of our application. Are there any emulator for JTAPI available? The testing with real hardware is a little diffcult. ...

How can I get access to the HttpServletRequest object when using Java Web Services

I'm using Java 6, Tomcat 6, and Metro. I use WebService and WebMethod annotations to expose my web service. I would like to obtain information about the request. I tried the following code, but wsCtxt is always null. What step must I take to not get null for the WebServiceContext. In other words: how can I execute the following line to ...

Ant and the available task - what if something is not available?

When I use the task, the property is only set to TRUE if the resource (say file) is available. If not, the property is undefined. When I print the value of the property, it gives true if the resource was available, but otherwise just prints the property name. Is there a way to set the property to some value if the resource is not avai...

Problem with synchronizing on String objects?

I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh about every 10 seconds on this page. One area of improvement that we found we could make with this function was to cache the responses from the...

"loader constraints violated when linking javax/xml/namespace/QName class" from webapp on Oracle 10g

We have a web application that can be deployed on many application servers, including Oracle 10g. On that platform, however, we are having classpath issues. The webapp uses JAXB 2, but Oracle 10g ships with JAXB 1, and this was causing errors. To get around those we configured Oracle to prefer classes in our webapp, but now we are get...

How do I submit multiple models in Struts 2?

I have a JSP that allows users to dynamically create additional form fields to create multiple objects. Perhaps I want to allow users to be able to submit as many line items as they want when submitting an invoice form. How do I create a Struts 2 Action that will be able to take in an ArrayList populated with objects created from those ...

How to serialize an object into a string

I am able to serialize an object into a file and then restore it again as is shown in the next code snippet. I would like to serialize the object into a string and store into a database instead. Can anyone help me? LinkedList<Diff_match_patch.Patch> patches = // whatever... FileOutputStream fileStream = new FileOutputStream("foo.ser"); ...

Show weights in JgraphT

I have implemented this Graph: ListenableDirectedWeightedGraph g = new ListenableDirectedWeightedGraph( MyWeightedEdge.class); in order to show what the class name says, a simple listenable directed weighted graph. I want to change the label of the edges and instead of the format return "(" + source + " : " + target + ")"; I wa...

Server-side DataTable Sorting in RichFaces

I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header. <rich:datascroller for="instanceList" actionListener="#{pageDataModel.pageChange}"/> <rich:dataTable id="instanceList" rows="10" value="#{pageDataModel}" ...