Vorlesungen
  Download     DBS     Sprachen     Oberflächen     File Formats     Impressum     Datenschutz  
1. Sem
2. Sem
3. Sem
4. Sem
5. Sem
iOS
Webprogrammierung
Web-Technologien
Wahlpflicht-SoSe
Wahlpflicht-WiSe
IEA-2019
Projektwochen
Allgemein:
Startseite
Vorlesungen
Labore
Sinnvolle Programme
Lineare Regression
GUI-Entwurfsarbeit
Single-Format
Design Pattern-Termine
Observer1
Bsp2
Json-Array
Json-Dialogelemente
Webtechnologien

jsp-snippets

Imports
<%@ page import = "java.util.* " %>
<%@ page import = "java.io.* " %>
<%@ page import = "java.text.* " %>
<%@ page import = "java.lang.reflect.* " %>deklaration
<%! int n=0; %>

scriptlet
<%
int i=0;
out.println("Dieses Wizzard kostet 5,80 Dong");
%>


expression
<%= value %>

Kommentar
<%-- jsp comment --%>


JSON
<%@ page import = "java.util.* " %>
<%@ page import = "java.lang.reflect.* " %>


<%!

private String getJSonArray(Object[] objs) {
StringBuilder sb = new StringBuilder();
if (objs.length==0) {
return "[]";
}
sb.append("[ " );
int n = objs.length;
for(int i=0; i<n; i++) {
sb.append(getJSon(objs[i]));
if (i<n-1) {
sb.append(", ");
} // if
} // for
sb.append(" ]");
return sb.toString();
}
private String getJSonArraylist(ArrayList objs) {
StringBuilder sb = new StringBuilder();
if (objs.size()==0) {
return "[]";
}
sb.append("[ " );
int n = objs.size();
for(int i=0; i<n; i++) {
sb.append(getJSon(objs.get(i)));
if (i<n-1) {
sb.append(", ");
}
} // for
sb.append(" ]");
return sb.toString();
}



private String getJSon(Object obj) {
StringBuilder sb = new StringBuilder();
try {
Class c = obj.getClass();
Field[] fields;
fields = c.getDeclaredFields();
// { {"name": "Meier59", "mnr":12345}
sb.append("{");
int n=fields.length-1;
for(int i=0; i<n; i++) {
Field field = fields[i];
sb.append("\"");
sb.append(field.getName());
sb.append("\":");
String s=field.getType().toString();
if (s.indexOf("String")>0) {
sb.append("\"");
sb.append(field.get(obj));
sb.append("\"");
}
else {
sb.append(field.get(obj));
}
if (i<n-1) {
sb.append(", ");
}
}
sb.append("}");
}
catch ( IllegalAccessException e) {
}
return sb.toString();
}

%>IntNumber
<%!
Integer getIntNumber(String str_zahl) {
try {
int zahl = Integer.parseInt(str_zahl);
return new Integer(zahl);
}
catch (NumberFormatException e) {
return null;
}
} // getIntNumber
%>


getDoubleNumber
<%!
double getDoubleNumber(String str_zahl) {
try {
double zahl = Double.parseDouble(str_zahl);
return zahl;
}
catch (NumberFormatException e) {
return Double.NaN;
} // try
} // getDoubleNumber Abfrage: if (Double.isNaN(Zahl)) {..}
%>


Print
out.println();


DateFormat
SimpleDateFormat date = new SimpleDateFormat("HH: mm:ss");
String uhrzeit = date.format(new Date());
out.println(uhrzeit);getParam
String str_zahl = request.getParameter("key");


getParams
String[] dummies = request.getParameterValues("themen");
if (dummies==null) {
ok=false;
}
else {
for( String item : dummies) {
// action
}
}






php-snippets
css-snipptes