jsp #Servlet.jsp

#Servlet.jsp
---------------------------------------------Çıktı Alma---------------------------------------------
PrintWriter yazici = request.getWriter();
yazici.write("Hello World !");
yazici.flush();

---------------------------------------------Parametre Alma---------------------------------------------
String ad = request.getParameter("ad");

---------------------------------------------URL Yönlendirme 1---------------------------------------------
Response.sendRedirect(String URL);

---------------------------------------------URL Yönlendirme 2---------------------------------------------
request.getRequestDispatcher(String resource).forward(request,response);

jsp #Form Operations

Get Parameter From Form.jsp
<%= request.getParameter("SOYAD")%>

<%String deneme = request.getParameter("SOYAD")%>
Form.jsp
<form accept-charset="utf-8" action="kayit.jsp" method="POST">
        <table>
            <tr>
                <td><b>Adınız :</b></td>
                <td><input type="text" name="adi"/></td>
            </tr>
            <tr>
                <td><b>Soyadınız :</b></td>
                <td><input type="text" name="soyadi"/></td>
            </tr>
            <tr>
                <td><b>Yaşınız :</b></td>
                <td><input type="text" name="yasi"/></td>
            </tr>
            <tr><td colspan="2" align="center"><input type="submit" value="Kaydet" /></td></tr>
        </table>
    </form>

jsp #Function.jsp

#Function.jsp
<%!
    int faktor(int n)
    {
        if (n == 1) {
            return n;
        }
        else {
            return n * faktor(n - 1);
        }
    }
    %>
    <%
        out.println("15 in faktoriyeli... " + faktor(15));
    %>

jsp #Redirection.jsp

#Redirection.jsp
String redirectURL= "kullaniciArayuz.jsp";
response.sendRedirect(redirectURL);

jsp #Cookie Operations

Delete.jsp
request.setCharacterEncoding("UTF-8");
String saklanan_cerez= "Cerez_kullanici";
Cookie killCookie = new Cookie(saklanan_cerez,null);
killCookie.setMaxAge(0);
killCookie.setPath("/");
response.addCookie(killCookie);
response.sendRedirect("index.jsp");
Create.jsp
//Çerezi oluşturduk. Çerez_kullanici diye getirebileceğiz artık.
Cookie cookie = new Cookie ("Cerez_kullanici", URLEncoder.encode((adi+" "+soyadi),"UTF-8"));

//Çerezin süresini belirledik.
cookie.setMaxAge(10000);

//çerezi bilgisayarda oluşturuyoruz. kaydediyoruz yani.
response.addCookie(cookie);
Control.jsp
request.setCharacterEncoding("UTF-8");
String saklanan_cerez= "Cerez_kullanici";
String bulunan_cerez_ad=null;
Cookie cookies [] = request.getCookies ();

for (int i = 0; i < cookies.length; i++){
    if (cookies [i].getName().equals (saklanan_cerez)){
        bulunan_cerez_ad = URLDecoder.decode(cookies[i].getValue(),"UTF-8");
        break;
    }
}
if(bulunan_cerez_ad==null)
    response.sendRedirect("index.jsp");

jsp #Session Operations

Delete.jsp
HttpSession httpSession = request.getSession(true);
httpSession.invalidate();
Create.jsp
HttpSession anasayfa = request.getSession(true);
anasayfa.putValue("kullanici_giris", "gecerli");
response.sendRedirect("./kullanicianasayfa.jsp");
Control.jsp
HttpSession httpSession = request.getSession(true);
if(httpSession.getValue("kullanici_giris")!="gecerli")
{
    response.sendRedirect("index.jsp");
}

jsp #Character Encoding.jsp

#Character Encoding.jsp
request.setCharacterEncoding("UTF-8");

jsp 元信息页面

元信息页面

info_page.jsp
<c:forEach var="meta" items="${pageModel.meta.entrySet()}">
	<c:out value="${meta}"/>
</c:forEach>

<!--
TEST2:

	destinations=org.dd4t.contentmodel.impl.KeywordImpl@1e242541

	robots=INDEX, FOLLOW

	og:type=article

	og:title=Landing Completa

	websection=org.dd4t.contentmodel.impl.KeywordImpl@6de89c6a

	promotion=org.dd4t.contentmodel.impl.ComponentImpl@572a5c94

	twitter:card=summary

	breadcrumb=Yes

	og:url=http://webdevfr.nh-hotels.com/fr/offres/content/copia/index2.html

	og:locale=fr

	loginProgram=org.dd4t.contentmodel.impl.KeywordImpl@5709dddc

	description=Landing Completa

	loginChannel=org.dd4t.contentmodel.impl.KeywordImpl@48c4c328
	-->



		
	

jsp 从其他portlet创建操作URL

从其他portlet创建操作URL

page.jsp
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>

<liferay-portlet:actionURL portletName="aragmultioptionsalesonlineportlet_WAR_aragmultioptionsalesonlineportlet" var="actionUrl">
    <liferay-portlet:param name="action" value="start_payment" />
</liferay-portlet:actionURL>

jsp 在javascript文件中使用portlet命名空间

在javascript文件中使用portlet命名空间

script.js
  var NAMESPACE = A.one('carrello-namespace').getData('value');
  var PORTLET_NAMESPACE = NAMESPACE.replace(/^_/, '').replace(/_$/, ''); // used when setting the portletId of a resourceURL
page.jsp
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<carrello-namespace data-value="<portlet:namespace/>"></carrello-namespace>