java

how to conditionally show jsp content to logged in users with Spring security

I want to show content to any user that is logged in and to hide if they are not logged in. I'm using jsp's and spring security. Obviously a home grown solution is easily done. But what's the cleanest standard way of achieving this? Spring security tags don't seem to have nice way that will allow for the addition of new roles in the ...

JPA Logging in WebLogic 11g (10.3.1)

How do you enable debug logging for OpenJPA when running an application in WebLogic 11g? I tried the steps given by http://stackoverflow.com/questions/792741/logging-jpa-sql-with-weblogic-10-3, but no OpenJPA log statements appear in the server log. I have also poured over the WebLogic documentation regarding the configuration of loggi...

Handling an invalid security certificate using Matlab's urlread command

I'm accessing an internal database using Matlab's urlread command, everything was working fine until the service was moved to a secure server (i.e. with an https address rather than an http address). Now urlread no longer successfully retrieves results (It gives an error: "Error downloading URL. Your network connection may be down or you...

Seam cache provider with ehcache null

Hi every one, I'm trying to configure seam/ehcache following the tutorial from jboss page: http://docs.jboss.org/seam/2.1.2/reference/en-US/html/cache.html I put the ehcache.1.2.3.jar in project.ear/lib and injected CacheProvider as especified, but the CacheProvider always return null. The documentation doesn't show any aditional conf...

any good books on scalable web applications (Java/Ajax/REST)?

Are there any good books on the subject worth reading and still up-to-date with current technologies? I'm mostly interested in back-end architecture and things I should consider choosing clustering and database solution as I plan to use GWT for the front-end therefore won't be able to control a lot there. I'm looking for a book which w...

Writing Standard Input and waiting for Standard Output

Hi, I'm trying to create a Thread that keeps netsh windows command-line tool open so I can execute netsh commands without open it every single time. The thing is, once I've created the Thread, just the first command call works... the subsequent calls seems to have no effect. Here is my code: public class NetshThread implements Runnabl...

jsf Trinidad: Change tr:table header

Hi. I have a tr:table with the rowSelection property set to "single". It draws a extra column with a radio buttons inside. But I want to change the text displayed at that column's header. I don't find any property that allow me to accomplish this. I guess I should overwrite some properties file but I haven't found anything on this topic ...

Sharing Session object between different web applications

Okay this is the problem I have a Java application running on top of Apache Tomcat & I have this other application too with its own war file running on the same server. Now I want to authenticate user once & pass that session to the other application. We can say cross domain session sharing on same Apache Tomcat .. how should I go abo...

jaxb unmarshal abusable by crafted xml when using default sax parser?

So in my current project I use the JAXB RI with the default Java parser from Sun's JRE (which I believe is Xerces) to unmarshal arbitrary XML. First I use XJC to compile an XSD of the following form: <?xml version="1.0" encoding="utf-8" ?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://...

Is there a substitute for xdoclet that supports generics?

I have an old EJB (2.1) project that uses xdoclet (1.2.3) to generate the EJB interfaces. Unfortunately xdoclet makes it impossible to use generics in the method signatures. Is there a substitute or other way to to allow generics in the parameters? Here is the minimum type of generics use I'm looking for: public Object ejbMethod(Coll...

How to improve the builder pattern?

Motivation Recently I searched for a way to initialize a complex object without passing a lot of parameter to the constructor. I tried it with the builder pattern, but I don't like the fact, that I'm not able to check at compile time if I really set all needed values. Traditional builder pattern When I use the builder pattern to creat...

equals and hashcode in Hibernate

How should model class's equals and hashcode be implemented in Hibernate? What are the common pitfalls? Is the default implementation good enough for most cases? Is there any sense to use business keys? It seems to me that it's pretty hard to get it right to work in every situation, when lazy fetching, id generation, proxy, etc are take...

Gracefully finalizing the SoftReference referent

I am using a search library which advises keeping search handle object open for this can benefit query cache. Over the time I have observed that the cache tends to get bloated (few hundred megs and keeps growing) and OOMs started to kick in. There is no way to enforce limits of this cache nor plan how much memory it can use. So I have in...

What are the differences between Servlet 2.5 and 3?

I'm rolling J2EE code that adheres to Servlet 2.5 and am wondering what the major differences are between 2.5 and 3. Pointers to official Sun docs and personal experiences most appreciated. If I shouldn't be concerning myself with 3 for the time being, just say so. Thanks! ...

Basic animation in Java for a screensaver app of sorts

I was assigned to make an animated screensaver as a programming project for my Advanced Programming course. The objective is to have several moving components inside an undecorated, fullscreen frame, but I'm going step-by-step and doing it one component at a time. Here's my source code so far: http://pastebin.com/dc722188 Feel free to...

Mock object and Spring annotations

I am using Spring annotations in my code to do the DI. So lets say I have a class class1 that depends on another class class2, I define class1 as below: @Component public class class1 { @Resource private interface2 object2; } class2 is an implementation of interface2. Now lets say I want to mock class2 and pass it to class1, I don...

AES difference between iPhone (Objective-c) and Java

Hi all, I have been tearing my hair out all day trying to solve this... I have an objective-c client running on the iPhone, connecting to a Java server. The iPhone is encrypting data using AES but I cannot decrypt it on the server. I am using a known passphrase and message (single string) and am generating the byte array on the iPhone...

change notification on domain objects (Hibernate/Java)

Is there a solution available to subscribe for domain object changes for Hibernate or any other mainstream O/R mapping framework? For example if I have a table in a database called "Apple" I'd like to be able to say "notify me when any Apple object changed" or "notify me when field "colour" of any Apple object changed". Of course I'd exp...

Direct memory access to the network card in java

Some modern network cards support Direct Memory Access for improved performance. How can I utilize this feature from Java? Does the JVM provide this automatically, or do I need to do an allocateDirect on the ByteBuffers that I am using to talk to that NIC? Does anyone have documentation that discusses this? ...

Java enum to mysql enum in prepared statement.

Hi. With the regular statement (just statement) I can put java enums into the queries and it works just fine. With prepared statement I can't do this ? ...