java

Looking for a simple, secure session design with servlets and JSP

I'm working on an intranet-only web application (J2EE) that requires some basic security features. There will be relatively few authorized users for the site, but I still need to implement some sort of secure session. The basic flow I'm looking at is visit site => log in => use site => log out when done (or automatically log out when th...

Subclipse can't rename file (OS X)

I can't perform any Subversion operations on my Eclipse project as Subclipse can't rename a file. The error is: Caused by: org.tigris.subversion.javahl.ClientException: svn: Cannot rename file '/Users/damianharvey/Sites/Odyssey3.5/OdysseyEDIJAXB/src/com/locuslive/edi/edifact/d95b/coreor/.svn/tmp/entries' to '/Users/damianharvey/Sites/Od...

Checking a local TCP port is not open in Java

Is there a simple way to make sure that a local port is not already open. Some TCP socket servers (eg Grizzly) don't seem to do this check by default. When this check is missing, the server appears to start and respond, but the client code is just connecting to an old server that wasn't shutdown. This can be very bad! Is there a simp...

Java PDF Library that works on GAE?

Since GAE has severe restrictions like - "A Java application cannot use any classes used to write to the filesystem"... Is there a good Java PDF library that can write the PDF to memory for streaming to the cloud? ...

Error in java swing application in Mac

Hi I have created a swing application using java 1.5 and i created a distributable jar of that file. I can run the jar in windows OS and linux OS but when i run in Mac it gives me error. I checked I am using java 1.5 version. I think the program asks for java 1.6 version. How to resolve the problem. Thanks Sunil Kumar sahoo ...

Counting the number of common chars in a string and a vector of strings

My problem is how to count but not count the same character twice. Like comparing 'aba' to 'are' should give 1 as result since it has only one char in common. This is where I got so far: public int sameChars (Vector<String> otherStrs){ int result = 0; String original = "aba"; for (int h= 0; h< otherStrs.size(); h++) { ...

Linking Apache to Tomcat with multiple domains.

Okay, so I've been working for a while on this, and have been searching, but so far I have not found any answers that actually answer what I want to know. I'm a little bit at the end of my rope with this one, but I'm hoping I can figure this out sometime soon. So I have Apache 2 installed and serving up standard webpages, but I also ha...

How would I robustly log binary or XML using slf4j/log4j/java.util.logging?

After doing logging for many years I have now reached a point where I need to be able to postprocess the log files with the long term goal of using the log files as a "transport medium" allowing me to persist objects et. al. so I can replay the backend requests. In order to do so I need to persist objects into a loggable form. The reco...

Fast algorithm for searching for substrings in a string

I'd like an efficient algorithm (or library) that I can use in Java to search for substrings in a string. What I would like to do is: Given an input string - INSTR: "BCDEFGH" And a set of candidate strings - CAND: "AB", "CDE", "FG", "H", "IJ" Find any CAND strings that match as substrings within INSTR In this example I wo...

Pure NetBeans doesn't work...

I had system: ubuntu-9.04-amd64. I installed IDE NetBeans 6.5 from official default repositories. Everything worked correctly. But now, I decided to use ubuntu-9.10-desktop-amd64. I formated parts of my hard with: (/ and /usr). /home remains as before. I've correctly installed ubuntu-9.10, correctly (probably) installed IDE NetBeans ...

Using Jython From Eclipse Plugin

I am having a tough time getting jython to work properly when run from an Eclipse plugin. I have a simple object factory that loads a python module conforming to a Java Interface. All of this works fine in standalone mode. However, when I package this as an eclipse plugin, I get a different error based on a few variables: Given that ...

Slider control in Android...is SeekBar really my best/only option?

I'm using SeekBar as a slider because I can't find anything else, but I have to do so much hacky work because it doesn't allow me to set a minimum value or go in between ints. So, any time I need a slider to start at a value other than 0 or return a floating point number, I have to set a max value that doesn't describe the true max valu...

Is it better to have code duplication and have it be very simple/readable, or have no duplication (using generics) but be much more complicated?

In general I come across this a lot. Some of my co-workers prefer very simple, easy to read classes even if that means that there is some code duplication, whereas I do everything in my power to avoid code duplication, even if it means making more a complicated architecture. What is the best practice? I work exclusively in Java. ...

suggest a link with such concepts implemented - java and mysql

i need to write a program in java that will connect to a mysql database and execute some sql queries and display the result. suggest me a link with similar implementation / discussion of such concepts for guidance. ...

Reading to get back into Java development?

I haven't done much Java development in about six years or so. I may have the need soon to port a C# application to Java so as to make it run on both Windows and the company standard flavor of Linux (for reasons I can't discuss). The thing I want to know is, what is the best reading material to brush up on changes to Java since then, so ...

IllegalStateException shutting down webapp with PicoContainer

I have a Java webapp that's using PicoContainer for dependency injection. When I shut down the app, I sometimes get the following stack trace repeated a few times in my error log: 2009-11-18 17:32:29,352 ERROR [/] - Session event listener threw exception java.lang.IllegalStateException: Cannot stop. Current container state was: STARTE...

Exception while compiling: wrong version 50.0, should be 49.0

I am working an application with JXL API and when i tried compiling using eclipse IDE, it's working fine and the same is not compiling when i am trying to compile in Command prompt and showing the below exception.. Extract.java:6: cannot access jxl.read.biff.BiffException bad class file: C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext\jxl...

A more efficient approach to Verbal arithmetic / Alphametics?

Perhaps most of you know the Send + More = Money. Well, I'm currently learning java and one of the exercises is I have to solve HES + THE = BEST. Now, so far I can/should use if-for-while-do loops, nothing else. Although I'm sure there are different methods to solve it, that's not the point of the exercise I'm going through. I have to b...

Teaching javax.mail, javax.activation to recognize mime type of mail attachment in web application

Im sending mails from a web application running on a glassfish server, which was quite easy with the java mail API. I'm starting now to attach files (mainly pdf and odt) to the mail, which works to, but the mime type of the attachment is not correctly set (application/octet-stream). I tried to attach the file with: MimeBodyPart mimeBod...

Using Hibernate Criteria API To Query Many-To-One Relationships with Projections

Hi I am trying to use Criteria API in following scenario: I have two tables, Schedule and Route (with their classes and mappings). Route has many-to-one relationship with Schedule. Route has an integer property sequence. Now I need to fetch all those Schedule objects whose associated Route objects fulfill the following condition: r...