Trail: Custom Networking
http://download.oracle.com/javase/tutorial/networking/TOC.html
// Create a JList that displays strings from an array
javax.swing.JList myList = new javax.swing.JList(data);
javax.swing.ListModel model = myList.getModel();
jList1.setModel(model);
//javax.swing.JList myList = new javax.swing.JList(Planets.values())
public interface TimeClient {
public void setTime(int hour, int minute, int second);
public void setDate(int day, int month, int year);
public void setDateAndTime(int day, int month, int year,
int hour, int minute, int second);
}
public interface Marker {
}
java.io.Serializable.
public class DataStructure {
private static final int SIZE = 15;
private static int[] arrayOfInts = new int[SIZE];
public DataStructure() {
for (int i = 0; i < SIZE; i++) {
arrayOfInts[i] = i;
}
}
public int getSIZE() {
return SIZE;
}
public static int getValueOfArray(int index) {
return arrayOfInts[index];
}
public void printEven() {
InnerEvenIterator iterator = new InnerEvenIterator();
while (iterator.hasNext(getSIZE())) {
System.out.print(iterator.getNext() + " ");
}
}
//Inner Class
/* private class InnerEvenIterator {
private int next = 0;
public boolean hasNext() {
return (next <= SIZE - 1);
}
public int getNext() {
int valueNext = arrayOfInts[next];
next += 2;
return valueNext;
}
} */
public static void main(String[] args) {
DataStructure ds = new DataStructure();
ds.printEven();
}
}public class InnerEvenIterator {
private int next = 0;
public boolean hasNext(int S) {
return (next <= S - 1);
}
public int getNext() {
int valueNext = DataStructure.getValueOfArray(next);
next += 2;
return valueNext;
}
}public class ClassesandObjects{
public static void main(String[] args){
int x = 3;
passMethod(x);
System.out.println("After invoking passMethod, x = " + x);
}
public /*static*/ void passMethod(int p){
p = 10;
System.out.println("Invoke passMethod, x = " + p);
}
}ClassesandObjects.java:4: non-static method passMethod(int) cannot be referenced
from a static context
passMethod(x);
^
1 error
if (aNumber >= 0)
if (aNumber == 0) System.out.println("first string");
else System.out.println("second string");
System.out.println("third string");
aNumber is 3?if ... ;
else ...;
la mot cau lenh
for statement?for ( ; ; ) {
}
The three expressions of the for loop are optional; an infinite loop can be created as follows:
for ( ; ; ) { // infinite loop
// your code goes here
}
/* IfElseDemo */
int testscore = 76;
char Grade = 'H';
if (testscore >= 90){
Grade = 'A';
} else if (testscore >= 80){
Grade = 'B';
} else if (testscore >= 70){
Grade = 'C';
System.out.println("Grade in loop = " + Grade);
} else if (testscore >= 60){
Grade = 'D';
} //else {
// Grade = 'F';
// }
System.out.println("Grade " + Grade);
}
E:\Java\Learn>javac HelloWorldApp.java
HelloWorldApp.java:70: variable Grade might not have been initialized
System.out.println("Grade " + Grade);
^
1 error
class InstanceofDemo {
public static void main(String[] args) {
Parent obj1 = new Parent();
Parent obj2 = new Child();
System.out.println("obj1 instanceof Parent: " + (obj1 instanceof Parent));
System.out.println("obj1 instanceof Child: " + (obj1 instanceof Child));
System.out.println("obj1 instanceof MyInterface: " + (obj1 instanceof MyInterface));
System.out.println("obj2 instanceof Parent: " + (obj2 instanceof Parent));
System.out.println("obj2 instanceof Child: " + (obj2 instanceof Child));
System.out.println("obj2 instanceof MyInterface: " + (obj2 instanceof MyInterface));
}
}
class Parent{}
class Child extends Parent implements MyInterface{}
interface MyInterface{}Parent obj2 = new Child(); khong hieu cho ni, Sao khong dung Child obj2 = new Child();
Order Confirmation
Thanks for ordering Hello JAVA World!
<project name="copydir" default="Copydir" basedir=".">
<property name="src" value="WEB-INF" />
<property name="dist" value="dist" />
<target name="Copydir">
<copydir src="${src}"
dest="${dist}"
includes="**/*.*"
excludes="**/web.xml"
/>
</target>
</project>
/PORTLET-NAME/
build.xml
/docroot/
icon.png
view.jsp
/css/
/js/
/WEB-INF/src/ (Java Source) //not created by default
liferay-display.xml
liferay-plugin-package.properties
liferay-portlet.xml
portlet.xml ()
web.xml
<portlet>
<portlet-name>my-greeting</portlet-name>
<display-name>My Greeting</display-name>
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>My Greeting</title>
<short-title>My Greeting</short-title>
<keywords>My Greeting</keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
GET / HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: www.ft.com
Connection: Keep-Alive
GET / HTTP/1.1
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip
Accept-Encoding: deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: www.ft.com
Connection: Keep-Alive
GET / HTTP/1.1
Accept: */*
Accept-Language: en-us A
ccept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Host: www.ft.com
Connection: Keep-Alive
Liferay khùng quá! Như thế này: tạo 1 portlet JSP-Portlet, deploy chạy được rồi
Sau đó vào Control Panel Liferay deactive đi, rồi xóa folder JSP-Portlet trong webapp
Lại tạo portlet JSP-Portlet, deploy vào, báo “OK”, vào lại không thấy đâu, phải vào CP liferay đẻ active lại
Chắc là vẫn lưu giá trị trong CSDL, nhưng mà đã xóa folder rồi, khùng quá
Co van de voi link, localhost:8080/view_1.txt khong duoc
chắc là do liferay quản lý hết folder webapp