String.replaceAll() case-insensitive(ignore case)
String username = “ABC abc /?%”;
username.replaceAll(“(?i)[^a-z0-9 _.@-]“, “”); // ignore case
String.replaceAll() case-insensitive(ignore case)
String username = “ABC abc /?%”;
username.replaceAll(“(?i)[^a-z0-9 _.@-]“, “”); // ignore case
Struts2: Accessing Session Variables in JSP’s
참조: http://j2eewebprogrammer.blogspot.com/2009/06/struts2-accessing-session-variables-in.html
Struts 2 places named objects including the session onto the OGNL stack.
Struts2는 session을 포함한 named objects를 OGNL 스텍에 놓는다.
Action:
extends ActionSupport implements SessionAware
setSession("user", user);
JSP:
<s:property value="%{#session.user.firstName}"/>
Request parameter : #parameters['attrName '] Request attribute : #request.attrName Session attribute : #session.attrName Application Attribute : #application.attrName
참조: http://www.ubuntugeek.com/how-to-install-java-runtime-environment-jre-in-ubuntu.html
== Currently Ubuntu has the following Java packages
sun-java6-bin – Contains the binaries
sun-java6-demo – Contains demos and examples
sun-java6-doc – Contains the documentation
sun-java6-fonts – Contains the Lucida TrueType fonts from the JRE
sun-java6-jdk – Contains the metapackage for the JDK
sun-java6-jre – Contains the metapackage for the JRE
sun-java6-plugin – Contains the plug-in for Mozilla-based browsers
sun-java6-source – Contains source files for the JDK
——–방법 1———–
[Ubuntu 11.04]
$ sudo add-apt-repository “deb http://archive.canonical.com/ natty partner”
$ sudo apt-get update
=== Install JRE
$ sudo apt-get install sun-java6-jre sun-java6-plugin
=== Install JDK
$ sudo apt-get install sun-java6-jdk
——-방법 2———-
== Install JRE on ubuntu 11.04 (Natty) using PPA : http://www.ubuntugeek.com/install-jre-in-ubuntu-11-04-natty-using-ppa.html
참조:
Open the terminal and run the following commands
$ sudo add-apt-repository ppa:ferramroberto/java
$ sudo apt-get update
$ sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
=== Testing Java Runtime Environment
$ java -version
firefox 검색창에 아래 내용을 입력하고 엔터키를 누르면
Java(TM) Plug-in 을 확인할 수 있음
about:plugins
Collection emps =
sqlUtility.select(EmpInfo.class, ”select * from emps”);
...
public static <T> Collection<T> select(Class<T>c, String sqlStatement) {
Collection<T> result = new ArrayList();
/* run sql query using jdbc */
for ( /* iterate over jdbc results */ ) {
T item = c.newInstance();
/* use reflection and set all of item’s fields from sql results */
result.add(item);
}
return result;
}
public static <T> T writeAll(Collection<T> coll, Sink<? super T> snk){
T last;
for (T t : coll) {
last = t;
snk.flush(last);
}
return last;
}
Sink<Object> s;
Collection<String> cs;
String str = writeAll(cs, s);
class Foo implements Comparable<Object> {...}
...
Collection<Foo> cf = ...;
Collections.max(cf); // should work
public static <T extends Comparable<? super T>>
T max(Collection<T> coll)
In general, if you have an API that only uses a type parameter T as an argument, its
uses should take advantage of lower bounded wildcards (? super T). Conversely, if
the API only returns T, you’ll give your clients more flexibility by using upper bounded
wildcards (? extends T).
참조: http://www.xefer.com/2006/12/switchonstring
public enum Day
{
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY,
NOVALUE;
public static Day toDay(String str)
{
try {
return valueOf(str.toUpperCase());
}
catch (Exception ex) {
return NOVALUE;
}
}
}
---------------------------------
switch (Day.toDay(str))
{
case SUNDAY:
case MONDAY:
case TUESDAY:
// etc ...
default:
// any non-Day value
}
참조: http://stackoverflow.com/questions/1751844/java-convert-liststring-to-a-joind-string
apache commons lang package
org.apache.commons.lang.StringUtils
String join(Collection collection, String separator)