Java EE 7 WebSocket example

1. Createa a Java EE Web application called MyWebSocket for example. 2. In index.html:

2. Create a class Called WebSocketEndpoint. Here the most important annotations are @ServerEndpoint, @OnOpen, @OnClose and @OnError, in these methods you put whatever you want to get executed when these

3. The bean which will produce our fake data….

JSF simple ajax example

Here is a simple AJAX example in JSF (run on Glassfish). Just to note: for sending the value to the bean you use the execute attribute of f:ajax, and for displaying the output from the beans’s getter, you use the render attribute. 1. pom.xml

2. The xhtml page:

Hello from Facelets

3….

[ubuntu] installing Oracle java

unzip the java package into a folder under /opt/ sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/64/jdk1.8.0_77/bin/java” 1 sudo update-alternatives –set java /opt/java/64/jdk1.8.0_77/bin/java sudo update-alternatives –install “/usr/bin/javac” “javac” “/opt/java/64/jdk1.8.0_77/bin/javac” 1 sudo update-alternatives –set javac /opt/java/64/jdk1.8.0_77/bin/javac

[java] check password against DB

To check the password against the database encoded value is simple, but it is not supported out of the box. You’ll have to convert the generated hash into hex format [code language=”java”] byte[] encoded = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < encoded.length; i++) { sb.append(Integer.toString((encoded[i] & 0xff) +…

Java 8 straming API examples

For this list:

AveragingDouble

Will produce:

Joining

Will produce:

Other Streaming API Examples Filter Here is an example of filtering:

Map

MapToInt

Count

Distinct

Limit

 

List of HTTP status codes

The following is a list of Hypertext Transfer Protocol (HTTP) response status codes. This includes codes from IETF internet standards as well as other IETF RFCs, other specifications and some additional commonly used codes. The first digit of the status code specifies one of five classes of response; the bare minimum for an HTTP client…