Cheatography
https://cheatography.com
Imports in HTML
<%@ page import="packageName.Class" %> |
<%@ page import="java.text.DecimalFormat" %> |
<%@ page import="java.sql.*" %> |
<%@ page import="java.util.*" %> |
<jsp:include page="date.jsp" flush="true" /> |
Data Typs
All Java Datatyps ( Integer, String, etc. ) |
ResultSet rsName; // rsName.getString("Name"); |
Date Handling
Date createTime = new Date(); |
"" + date.toString() + "" |
<p>Today´s Date: <%= ( new java.util.Date() ) %> </p> |
Function/Methode Deklaration
public methodName( String methodParameter ) { method Operation } |
|
|
JSP-Variable Deklaration between HTML
<%! String variableName; %> |
<%! float functionName(String functionParameter){ function Operation } %> |
JSP-Allocation between HTML
JSP-Output between HTML
<form action="<%= request.getRequestURI() %>" method="post"> |
<% out.print("<a href='checkbox.jsp'>Zurück</a>"); %> |
Request Operationen: // GET und POST
request.getParameter("checkBoxName"); |
String [] variableName = request.getParameterValues("checkBoxName"); |
Response Operationen:
response.sendRedirect("redirectPageName.jsp"); |
response.addCookie( cookie ); |
|
|
Sessions Deklaration
session.setAttribute("IndexName", "IndexValue"); |
session.setMaxInactiveInterval(time); |
Sessions Usage
session.getAttribute("IndexName", object value); |
session.getId(); |
session.getAttribute(); |
session.getAttributeNames(); |
session.removeAttribute(); |
session.getCreationTime(); |
session.getLastAccessedTime(); |
session.isNew(); |
Enumarations
Enumeration e = request.getParameterNames();
String name, wert;
while( e.hasMoreElements()) {
name = e.nextElement().toString();
// name = (String) e.nextElement();
wert = request.getParameter(name);
if ( !name.equals("submit") && !wert.equals(""))
out.println(name + ":" + wert + "<br>");
}
|
|
|
Cookies Deklaration
Cookie cookie = new Cookie("IndexName", IndexValue);
cookie.setMaxAge(246060); // 24 Stunden
response.addCookie( cookie );
|
Cookie Usage
Cookie[] cookies = request.getCookies();
for(int i = 0; i < cookies.length; i++){
Cookie c = cookies[i];
if(c.getName().equals("name")){
out.println("Name= " + c.getValue() );
}
}
|
Compare
== | != | etc. |
user.equals(user_f) |
Comments
<!-- comment --> // HTML Comment |
<%-- comment --%> // JSP Comment |
Exception
catch(Exception e){
e.getMessage();
}
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
More Cheat Sheets by Kemmojoo