java

Please help me figure out what's wrong with this web proxy code

I want to write a web proxy for exercise, and this is the code I have so far: // returns a map that contains the port and the host def parseHostAndPort(String data) { def objMap // this has host and port as keys data.eachLine { line -> if(line =~ /^(?i)get|put|post|head|trace|delete/) { println line ...

How to execute an URL using Android?

I'm making a App to send SMS trough VOIP providers from betamax... To send I just need to execute the url https://www.12voip.com/myaccount/sendsms.php?username=w​&password=x&from=y&to=z&text=some%20text My app already creates the URL, but i cant understand how to execute...i think i have to make an http request....bu...

Transitioning Away from Flash

I create fullscreen interactive demos in Flash and have recently been looking to migrate to a new language. My Flash demos are basically software prototypes and operate in a projector EXE, outside of the browser. I want to leave Flash for a variety of reasons, including: Poor quality control in the Flash player Hardware acceleration is...

Should Java Thread IDs always start at 0?

I am working on a mutual exclusion assignment, but when I started I noticed my application's thread ID's start at 9. It doesn't change when I compile and execute it again. Is there some problem I'm missing, or can Java Thread IDs start at an arbitrary number? This question is related. For those interested, here is a class from Herlih...

JSF: attach rich:toggleControl to radio buttons or select items.

Has anyone had any success attaching a rich:toggleControl component to a radio button component (h:selectOneRadio) or alternatively any of its children select items (in this case s:enumItem). Basic code example: <h:selectOneRadio value="#{backingValue}"> <s:enumItem enumValue="VAL_1" itemLabel="Value One" /> <s:enumItem enumValue...

Natural sort order string comparison in Java - is one built in?

I'd like some kind of string comparison function that preserves natural sort order1. Is there anything like this built into Java? I can't find anything in the String class, and the Comparator class only knows of two implementations. I can roll my own (it's not a very hard problem), but I'd rather not re-invent the wheel if I don't hav...

What is the most efficient way to replace many string tokens in many files in Java?

What I want to accomplish is a tool that filters my files replacing the occurrences of strings in this format ${some.property} with a value got from a properties file (just like Maven's or Ant's file filtering feature). My first approach was to use Ant API (copy-task) or Maven Filtering component but both include many unnecessary depend...

How do I determine the IP address of a web client (for a JSP)?

I would like to find out the ip address of the client that is visiting my web pages. Content of JSP page: <% out.print( request.getRemoteAddr() + "<br>"); out.print( request.getRemoteHost() ); %> Output: 0:0:0:0:0:0:0:1 0:0:0:0:0:0:0:1 ...

HQL left join problem: Path expected for join!

Hi, I am new at Hibernate, and I have a question regarding HQL Lejt join. I try to left join 2 tables, patient and provider, and keep getting "Path expected for join! " erroron the second table. Appreciate it if anybody can help on this issue! Here is the mapping of the 2 tables/classes: patient.hbm.xmL: <?xml version="1.0"?> <!DOC...

How is the java memory pool divided?

I’m currently monitoring a Java application with jconsole. The memory tab let you choose between: Heap Memory Usage Non-Heap Memory Usage Memory Pool “Eden Space” Memory Pool “Survivor Space” Memory Pool “Tenured Gen” Memory Pool “Code Cache” Memory Pool “Perm Gen” What is the different between them ? ...

Java: A good introduction to J2EE platform for noobs

The question says it all; what are some good introductory resources for getting a good overview of J2EE framework(preferably ones with examples)? ...

Multiple Inheritance in java.

Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. But my questions is why java is not allowing multiple inheritance like C++ when there is no ambiguity (and hence no chances of diamond problem) while inheriting from m...

Hibernate - How to cascade delete on detached objects

I have a hibernate object that gets detached and transferred to a thick java swing client using EJBs. The object is then modified in some way and returned to the server where the server then updates the modified object to the database. Everything works well for properties that change, but I am having a problem on how to delete a many-to-...

Converting from Waffle/Pico to Struts2/Guice

Hi all, I've been tasked with converting an application which was developed by myself in the Waffle Framework using PicoContainer as a DI mechanism into our new "stack" which is to use Struts2 as a framework with Guice as the DI mechanism. Does anyone out there have any helpful pointers as to how to do this with minimal pain and at the...

Java/JAXB error in Matlab when using unmarshal function

Hi, I'm running into a problem that I think is related to updating JAXB to the latest version. I'm running a marshal command that returns: ??? Java exception occurred: javax.xml.bind.MarshalException - with linked exception: [java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String] at com.sun.xml....

Intellij IDEA way of editing multiple lines

I've seen this done in TextMate and I was wondering if there's a way to do it in IDEA. Say I have the following code: leaseLabel = "Lease"; leaseLabelPlural = "Leases"; portfolioLabel = "Portfolio"; portfolioLabelPlural = "Portfolios"; buildingLabel = "Building"; What is the best way to append '+ "foo"' to every line? Column mod...

ice:selectOneMenu sending the wrong value

Hi there, I have multiple drop down menus with my JSF/ICEFaces application that update each others so depending on the selection of one the contents of others update. The problem is that the menu is sending the wrong value. It seems it sends the value before instead of the current one! not sure why! Any ideas? Thanks, Tam <td> ...

Advantages and Disadvantages of J2EE vs. Servlets

What are the primary reasons for using the J2EE (EJB's) over just a simple servlet implementation? I am working on developing a new project that will primarily be a web service that must be very fast and scalable. Sorry for any confusion, Although I am experienced in Java, I am very new to the Java Web world, and may not be asking thi...

Best way to manually pull a spring bean?

How do I pull a spring bean manually? I have a rather large web application, and in a given service, a transient object requires access to a bean that is machine specific (database connection info.) Since the application runs in a cluster, this transient object (which can bounce between servers) always needs to grab the correct connectio...

Determining deterministic thread execution of a Java program

I wrote a very simple toy program to complete the execution of a task inside a thread as per the timing requirements specified by a user. The code and the sample output is below. What happens is that everytime you run the code, the task completion times would be within a + delta range of the time specified by the user. For e.g if the use...