java

How do you specify the root context in your <web-app> tags in web.xml?

I would like specify the root context of my Java Web Application in my WAR file. How can I do this using valid web-app xml in web.xml file? Oh, yes I would like to do this in an Application Server agnostic way. Thank you in advance, Rob ...

How do I send and receive an integer array from client to server in Java socket programming?

I'm having a problem sending a job (an integer array) from client to server in two different packages over a socket connection. Any ideas please? I can explain further if my question is not clear enough. ...

Using JMS, is there any way to store messages on intermittently disconnected clients and forward them to a broker when a network is available?

I am considering an architecture where I have clients that are intermittently connected to a network. I would like to store messages created on these clients in a JMS queue when the network is not available and have these forwarded to a central message broker when the clients are on the network. (The user has control over the network, e....

How can I preload web app classes in the JVM on start up?

In our web apps the first load of some pages takes a small but noticeable extra about of time due to class loading. Does anyone have any clever ways of preloading web app classes in the JVM on start up? Update: What we do now is store a bunch (700) of full class names in a db table. We read the table at startup and do Class.forName()...

How can I find repeated characters with a regex in Java?

Can anyone give me a Java regex to identify repeated characters in a string? I am only looking for characters that are repeated immediately and they can be letters or digits. Example: abccde <- looking for this (immediately repeating c's) abcdce <- not this (c's seperated by another character) ...

JFrame title repaint

In my JFrame it loops to do some task, I want to see the status in the JFrame title, so I have something like this : frame.setTitle("Current status [ "+Auto_Count_Id+"/"+Auto_Count_Total+" ]"); But it's not repainting as I need it to. So I tried the following : <1> SwingUtilities.invokeLater(new Runnable() { public v...

When will an EOFException occur in JAVA's streams

I am working with a DataInputStream and had a question about EOFExceptions. According to java docs: Signals that an end of file or end of stream has been reached unexpectedly during input. This exception is mainly used by data input streams to signal end of stream. Note that many other input operations return a specia...

Byte array of unknown length in java

I am constructing an array of bytes in java and I don't know how long the array will be. I want some tool like Java's StringBuffer that you can just call .append(byte b) or .append(byte[] buf) and have it buffer all my bytes and return to me a byte array when I'm done. Is there a class that does for bytes what StringBuffer does for S...

[java] how do i programmatically change file permissions?

In java, i'm dynamically creating a set of files and i'd like to change the file permissions on these files on a linux/unix file system. I'd like to be able to execute the java equivalent of chmod. Is that possible Java 5, if so, how? I know in Java 6 the File object has setReadable()/setWritable() methods. I also know i could make a...

firefox cache hash key generation algorithm bug

There is a bug in Firefox (even in the new betas and in minefield releases) which prevents the caching of certain files because of the algorithm for creating a key in their cache hash. Here is a link to the source code of the function. I want to ensure that all of my site's files can be cached. However, I do not understand why their...

Grab most recently played iTunes song using Java

What is the easiest way to get the information about the last song played in iTunes into a Java program? I have looked at JACOB and iTunes COM but they seem like overkill. If that's the only way to go, could anyone provide a good example next to the first google result? A 'hack' method is acceptable as well! Thanks! ...

Get the VK int from an arbitrary char in java

How do you get the VK code from a char that is a letter? It seems like you should be able to do something like javax.swing.KeyStroke.getKeyStroke('c').getKeyCode(), but that doesn't work (the result is zero). Everyone knows how to get the key code if you already have a KeyEvent, but what if you just want to turn chars into VK ints? I'...

How To Convert a UniDimensional Array to a Bidimensional Array (Java)

I already have the code for how to convert a bidimensional one into a dimensional one, but I don't know how to do it vice-versa. Here's my code: package laboratorio9; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int A[][]; int B[]; int...

Which language to use to write a Speech Recognition software?

I want to write a basic Speech Recognition software which can convert speech to text. I wanted to know which language is most suited to write such a software. Is Java suited for this job? edit : Thank you all for the responses. I want to build a tool for a college project. I don't want to write it from scratch. Just want to demo the pow...

How do i get remainder and quotient in single value in java?

Hi : I want to know how to get remainder and quotient in single value in java. Example 3/2 i should value as 1.5. If i use "/" operator, getting only quotient and for "%" operator, getting only remainder value. How do i get both at a time? ...

Possible to port legacy servlet to framework one component at a time?

Hello all, I have heard that you can run an ASP.NET application and ASP.NET mvc application side by side so that you can port existing code over one piece at a time. I was wondering if you could do this with a java framework? I have a legacy servlet application that I am currently in the process of refactoring. I am thinking about turn...

Identifying ajax request or browser request in grails controller

Hi I am developing a grails application which uses lot of ajax.If the request is ajax call then it should give response(this part is working), however if I type in the URL in the browser it should take me to the home/index page instead of the requested page.Below is the sample gsp code for ajax call. <g:remoteFunction action="list" con...

Can someone point me to a good Canny edge detector implementation in Java ?

There is no JAI implementation of this. ...

How to display line graph using JFreeChart in jsp?

HI All: I am using the below to diplay the line graph. when i run the below code, i am getting the window but it is blank and not displaying the graph. Please help me and also tell me how to diplay the line graph in html page using below code. Code : import org.jfree.chart.; import org.jfree.chart.plot.PlotOrientation; imp...

What does the "J" in JApplet mean?

What does the "J" in JApplet mean? ...