java

How can a webservice be secured with authentication when called from ajax client side ?

How do I protect a webservice if it is called from ajax ? Update: I realize that my question didn't reflect what I intended to ask. I don't want user to be able to do the request by pointing to it with its webbrowser but only in the context of my app. ...

Java: examples of very hard to track-down bugs

Hello All, Related to this question, http://stackoverflow.com/questions/570353/hardest-types-of-bugs-to-track, does anyone have any examples of real-world code that introduces extremely hard-to-identify bugs, e.g a Heisenbug? If you wanted to deliberately introduce a difficult bug, what would you do? ...

Is it possible to invoke a javaScript server side ?

greetings all i was wondering if it's possible to send some javaScript code in the response of a controller meaning that i want to invoke a javaScript but not from the jsp (from server side) something like: var d = new Date(); var gmtHours = -d.getTimezoneOffset()/60; var tz=gmtHours; window.location="page?tz="+tz; what do you think g...

Why does exist WeakHashMap, but absent WeakSet?

Hi! From J. Bloch A ... source of memory leaks is listeners ... The best way to ensure that callbacks are garbage collected promptly is to store only weak references to them, for instance, by storing them only as keys in a WeakHashMap. So, why there isn't any WeakSet in java collection framework? Thanks. ...

Minimize loops in reference to read/write operations

Hi, the last thing I want to minimize today is code that contains while and do-while loops. Here is the original: class Vereinfache3_edit { public static void main(String [] args) { int c1 = Integer.parseInt(args[0]) ; int c2 = Integer.parseInt(args[1]) ; int c3 = Integer.parseInt(args[2]) ; ...

Spring MVC 3 AJAX

I'm taking my first steps to explore Spring MVC 3 (annotation driven) and the JSON functionality that it supports. 1) In my JSP page I want to click a link that retrieves JSON $("a[class=simple2]").click(function() { $.getJSON("checkName.html", function(contacts) { alert(contacts); }); return false; }); ...

List versus ArrayList

Ok so I know that Set, List and Map are interfaces but what makes the first line of code any better than the second line? List myArr = new ArrayList(); ArrayList myArr = new ArrayList(); Thanks. ...

Exceptions with Anonymous threads

Hi all, im trying to surround my code with exceptions all over so I wont have any memory leaks. I tried the following code, and for some reason the exception isnt being handled and i get runtime error. some code: try { methodA(); } catch (Throwable th) { MsgProxyLogger.error(TAG, th.g...

Help In Verifying Implemented Algorithms for Integers [Part 1]

Hi Guys, I have been asked to implement the following algorithms. I have done them according to my knowledge and would like you guys to help me by verifying them if am right. They are simple methods to sort arrays of integers The following code contains the methods: public class Algorithms { // Use this class to pass a compar...

Java Repaint on MouseMoved causes lag

Hi, I'm trying to make my java app repaint each time the mouse has been moved to update the screen when the user moved over a diagram ( -> display the name of the diagram ) and when the user does not move over a diagram ( -> do not display any name of a diagram ). But this causes a huge lag when running the application ( I see the scree...

Multiple software licenses across a project

How does one go about including multiple licenses in software? For example, I'm working on a project that I would license as GPLv3. I'd like to include some libraries from the Apache Commons (Apache license 2.0). These libraries are distributed with both NOTICE.txt and LICENSE.txt, which to my understanding must be included in my projec...

Java StackOverflowError while recursively building an array from a binary search tree.

I'm trying to balance a BST by first building an array (inorder) and then rebuild the entire tree from my array. I have: public void toArray(E[] a) { toArray(root, a, 0); } /* * Adds all elements from the tree rooted at n in inorder to the array a * starting at a[index]. * Returns the index of the last inserted element + 1 ...

Flash to Java port of this code (maybe getTransform) /box2d

var ldirection = wheel.GetXForm().R.col2.Copy(); ldirection.Multiply(engineSpeed); how i can do this in java code? Thanks ...

How to reactive a cancelled futuretask in thread pool ?

I use ThreadPoolExecutor to run some actions, at some time I cancelled some future tasks and stored it into a list to arrange some other tasks to do, and after that I want to reactive the saved cancelled future tasks. But the problem is when I submit the task into the pool, it would not be executed, looks like the cancelled or done flag...

JSoup - Select all comments

Hey, I want to select all comments from a document using JSoup. I would like to do something like this: for(Element e : doc.select("comment")) { System.out.println(e); } I have tried this: for (Element e : doc.getAllElements()) { if (e instanceof Comment) { } } But the following error occurs in eclipse "Incompatible condi...

How to quickly navigate between Java class method definitions in a large class without the 'Find' dialog in Eclipse?

I use what I think is a typical layout in Eclipse: my workspace contains the Project Explorer on the left and the Java editor window taking up most of the screen, with the small console window at the foot of this editor pane. When I open a very long Java class, containing a large number of method definitions, in the editor pane, it can ...

enabeling comet in glassfish server

i am getting following error #|2010-10-31T19:13:38.127+0530|SEVERE|glassfish|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=Thread-3;|StandardWrapperValve[Grizzly Cometd Servlet]: PWC1406: Servlet.service() for servlet Grizzly Cometd Servlet threw exception java.lang.IllegalStateException: Make sure you have enabled Com...

opensource javaEE project for learning

I have been learning javaEE and MVC pattern for a while from books and tutorials. but I wish to see how is coded a real world JavaEE projects. by real world project I mean a full application which is using by other people. maybe an opensource project like an e-commerce, a forum or a cms, I know many for php but none for javaEE. will be...

Adding Spring bean using annotations : placing it & initializing properties values

I've gleaned that adding the context:component-scan will enable adding any jar with bean annotated as @Bean to the spring configuration, but , while getting lost in the Framework reference... How can I add that bean as interceptor on specific channel? How can bean properties be initialized if there's no element in the context.xml to ...

SSL securing site on Google App Engine

How can I make sure that users cannot access http address on google appengine at all? Now usesrs can use https or http to access site, but is there any way to force users using http protocol to https url? ...