java

Java servlet and authentication

Hi all, I have a small application with 3-4 servlets and a basic module that provide me authentication like: public class Authentication { public boolean isUserAuthenticated(){ .... } } Is there a way to check the authentication using my class BEFORE every other servlet calls, without have to add code in each of them? I'...

Executing .app folder from Java?

Is there a reasonable way to execute a .app directory directly from Java instead of digging down to find the binary? I've got an app with some preferences that include external programs for opening various things, it'd be nice if on OSX the user could just select the .app folder. I could look for the .app extension and handle it differ...

How to automate a build of a Java class and all the classes it depends on?

I guess this is kind of a follow-on to question 1522329. That question talked about getting a list of all classes used at runtime via the java -verbose:class option. What I'm interested in is automating the build of a JAR file which contains my class(es), and all other classes they rely on. Typically, this would be where I am using cod...

How can I stop a Cruise Control build or change the config to cause long running builds to time out?

Is there any way to stop an active Cruise Control build short of stopping and restarting Cruise Control? I'm running Cruise Control Dashboard version 2.7.2. If there is no way to stop an active build, how can I cause long running builds to timeout? Is this something I should configure in Cruise Control or in Ant? Background It looks l...

Memory overhead of Java HashMap compared to ArrayList

I am wondering what is the memory overhead of java HashMap compared to ArrayList? Update: I would like to improve the speed for searching for specific values of a big pack (6 Millions+) of identical objects. Thus, I am thinking about using one or several HashMap instead of using ArrayList. But I am wondering what is the overhead of Ha...

Printing all variables value from a class

Hi, I have a class with information about a Person. Something like: public class Contact { private String name; private String location; private String address; private String email; private String phone; private String fax; public String toString() { // Something here } // Getters and setter...

skip jsf lifecylce phase

Hi, How do I short circuit the jsf lifecycle so that the response is rendered before any model updates? In the diagram of page 59 of this document JSF Spec V1.2 RevB, it shows that you can skip from the "Apply Request Values" phase directly to the "Render Response" phase. How do I do this? I've got a PhaseListener hooked in, but not s...

SocketTimeoutException on Solaris 9 not being thrown

I have a connection that should recieve a heartbeat every two minutes. However occasionally something happens and the network goes bad. For some reason Solaris believes that the connection is still alive, No IOException is raised locally, however one is raised remotely. I have set a timeout on the socket, and when debugged from a Windo...

How to copy polygon using mouse click?

How to make a copy of a polygon using mouse click (e.g. when the mouse click, a menu pop up showing menu for copy). I have problem to differentiate a mouse click, to draw or to copy. I created a method where when the user pressed the mouse, the method will check if the mouse pressed inside existing polygon or outside. If it outside pol...

HTML JTextPane newline support

I'm using a JTextPane to edit HTML. When I enter newlines in the GUI component and call getText() on the JTextPane, I get a string with newline characters. If I then create a new JTextPane and pass that same text in, the newlines are ignored. Why doesn't JTextPane insert a <br> tag when a newline is entered? Is there a good workaroun...

Is there any way to access another package without the public modifier?

Let's say I have packages: com.mycomp.packone com.mycomp.packtwo Is there any way for me to access protected members of a class in packone from a class in packtwo, but not allow public users to do so? The only way I can think of is with protected access and using a subclass. But that just pushes the problem into the subclass, because ...

WebSphere MQ Message Listener Threads

Hi, I am trying to figure out how WSMQ handles message listeners and threads. If I have one instance of a message listener, and have many queues, does each listener create a new thread for each queue? Or will there be one thread for the listener? Any insight will greatly help, thank you. ...

java.awt.Desktop.open doesn’t work with PDF files?

It looks like I cannot use Desktop.open() on PDF files regardless of location. Here's a small test program: package com.example.bugs; import java.awt.Desktop; import java.io.File; import java.io.IOException; public class DesktopOpenBug { static public void main(String[] args) { try { Desktop desktop = null; ...

What's the easiest way to extract the JPG data from an MP3 header in java?

I wrote a JSP that hands my Flash front-end an XML file that describes the contents of my mp3 folder, but am stuck trying to parse the individual file headers for the album art that is embedded therein. Can anyone recommend a good library that has something straight forward that in pseudo code would look like... String mp3FilePath = "/m...

Java setClip seems to redraw

I'm having some troubles with setClip in Java. I have a class that extends JPanel. Within that class I have overridden the paintComponent method. My paintComponent method looks something like this: paintComponent { //draw some lines here Rectangle whole = g2.getClipBounds();//g2 is my Graphics2D object Rectangle part = <s...

Not able to run my jar file on Windows

I have these files board.class and x4.class (x4.class has main() method). To jar these files, I wrote jar cf x4.jar *.class and got a x4.jar file. I copied this x4.jar file to my Desktop (on windows Vista) and double-clicked it. I am getting this error: Failed to load Main-Class manifest attribute from C:\Users\eSKay\Desktop...

CopyOnWriteArrayList throwing CurrentModificationException

I'm occasionally getting a ConcurrentModificationException when I iterate over a list. A Google search informs me that it's probably because I'm altering that list in another thread while iterating over it and that to make this problem go away I should use java.util.concurrent.CopyOnWriteArrayList.... ... except I already am. Apparent...

Copy polygon to new location

How can I copy a polygon to a new location. I use e.isPopupTrigger() to select the polygon, but I dont know how to copy it. Is the function of copy similar to the function of translate? e.g. polygon.translate(x,y)? Thanks. EDITED: //this code doesnt work :-( if(e.getSource() == Copy){ Polygon copyPolygon = new Polygon(); copyPo...

Axis: faultString: org.xml.sax.SAXParseException: Premature end of file.

I have deployed a webservice using servletexec configured with IIS and i can successfully access webservice using anonymous account. But when I enable Windows Integrated Authentication I am getting following error. - ntlm authentication scheme selected - Discarding unexpected response: HTTP/1.1 100 Continue AxisFault faultCode: {http...

Howto Get application port through MXBean

given a application: http://localhost:8080/myapp/ is it possible to enquire JVM through MBean/MXBean in which port the current application code is accepting requests? and also the appcontext (myapp)? ...