java

How to enable Logger.debug() in Log4j

While trying to execute the following lines only the last two statements are displayed("Here is some ERROR" and "Here is some FATAL") and the first three statements are not displayed.I had just started to learn this topic, can anyone tell why is this happening? logger.debug("Here is some DEBUG"); logger.info("Here is some INFO")...

How do I detect unicode characters in a Java string?

Suppose I have a string that contains Ü. How would I find all those unicode characters? Should I test for their code? How would I do that? For example, given the string "AÜXÜ", I'd like to transform it to "AYXY". I'd like to do the same for other unicode characters, and I would hate to have to store them in a translation map of some sor...

JAXB appending unneeded namespace declarations to tags

I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:i...

How to use Ajax JQuery in Spring Web MVC

Hello All.. I am using spring web mvc for my application. I have 1 dropdown list in my JSP View, coming from following request called savegroup.htm <bean name="/savegroup.htm" class="com.sufalam.mailserver.presentation.web.GroupSaveController"> <property name="sessionForm" value="true"/> <property name="command...

Springframework 2.5 SimpleMessageListenerContainer message received callback?

I have been reading up on the SimpleMessageListenerContainer to ease the pain of subscribing to a topic asynchronously. However, I cannot find a way to trigger a callback or loop through the messages that the container has received. Can someone point me in the right direction (documentation, examples, etc)? ...

Implementing article revision history for Java based web application

Any ideas of how best i can implement article revision history for a Java based web application and save it in AuditLog StackOverflow already has such a feature allowing one to see the differences from one version to another, almost like SVN clients. This is more of a design than implementation question. addition: How would one displa...

algorithm for list identification and parsing

I have data which in theory is a list, but historically has been input by the user as a free form text field. Now I need to separate each item of the list so that each element can be analysed. Simplified examples of my data as input by users: one, two, three, four, five one. two. three, four. five. "I start with one, then do two, ma...

Java, MyFaces 1.1, Tobago and How to create resusable web components

Assume you want to create some form of web-dialog that allows you to do something. For instance querying for some information by filtering some selection criterias. This dialog might consist of a couple of textboxes, labels, comboboxes and buttons. Now you notice that exactly THIS dialog needs to be used in different places. However, th...

Examples of GoF Design Patterns

I am learning GoF Java Design Patterns and I want to see some real life examples of them. Can you guys point to some good usage of these Design Patterns.(preferably in Java's core libraries). Thank you ...

Exclude entity bean attributes from hibernate query?

I'm new to this hibernate/jpa stuff so bear with me.. I've generated an entity bean and it works fine, but I would like to add some extra attributes to it and this causes hibernate to complain that the extra attributes aren't in the table's field list.. Is there a keyword to exclude these attributes from hibernate's query?? ...

cutting audio files based on a keyword

Hi, I have a audio file(s) that need to be cut and broken up into multiple audio files based on a keyword. For example, lets say the keyword is "CUT" if we had an wav file called "original.wav" with the following audio, "Hello , is this CUT the time is CUT My name is CUT The balance is" and the token audio cut.wav which contains the...

How to compile java code?

Hi, I have a bunch of java files and I am running the following code in an attempt to compile them. "\Program Files\Java\jdk1.6.0_16\bin\javac" Main.java And I am being shown this error message Main.java:3: package colourtiler.patternsdoes not exist import colourtiler.patterns.draw; The code it isreferring to is located in the fo...

How do I check that a session object contains a particular key/value entry

I want to check if a certain key/value pair has been set. How do I check if a an entry with key named "keyName" exists. Sample code or a pointer to an example would be appreciated. ...

Android project won't build when editing a resource file

I have an Android 1.5 project in Eclipse and whenever I merely have an xml resource file open the build dies with an error. E.g. if I have the res\layout\main.xml open as the active document it won't build and throws the following error: Error in an XML file: aborting build. res\layout\main.xml:0: ERROR Resource entry main is already de...

How to write into input stream in java

Suppose i execute a command in java using the exec() function and i store the reference in a Process . How do i write into the input stream of that process Process P = Runtime.getRuntime().exec("cmd /c start telnet"); System.out.println("done running .."); OutputStream output = P.getOutputStream(); BufferedOutputStream out = new Buff...

Specify a character value as an offset from a constant in Java

I am looking to get a random letter using something like char ch = 'A' + randomNumber ; // randomNumber is int from 0 to 25 But that gives "loss of precision" compilation error (same if randomNumber is only a byte). I guess with Unicode the above is a gross oversimplification. But how should I do it ? This works but seems a bit clum...

Get Size of HTTP Response in Java

Hi, I would like to know how much data was sent in response to a certain http-request. What I currently do is this: HttpURLConnection con = (HttpURLConnection) feedurl.openConnection(); //check the response for the content-size int feedsize = con.getContentLength(); The problem is, that content-legnth is not always set. E.g. w...

Auto formatting code

Our team has recently inherited code which is extremely disorganized. As a result, my team leader has decided to enforce a policy of auto-formating of code prior to saving a file. We have even found an option in Eclipse (The IDE of our choice) that auto-formats the code automatically before each save action. Personally I am against it...

How do I share data between a jsp page and servlet

I have several .jsp pages and several servlets. I need to save some information to a session variable. In the jsp page I simply refer to session.get...() or session.set...() Without explicitly declaring an HttpSession object. But in the servlet the proper rules of programming apply and I have to create an object first. My conc...

What is the difference between business class and domain class? What is meant by persistent classes?

What is the difference between business class and domain class? What is meant by persistent classes? ...