template page meggunakan sitemesh | java php laravel linux mysql sql bootstrap html css query java php laravel linux mysql sql bootstrap html css query: template page meggunakan sitemesh

Sabtu, 23 Juni 2012

template page meggunakan sitemesh

Buat project web menggunakan eclipse JEE

File > New > Dynamic Web Project



Buat file index.html pada WebContent

[sourcecode language="html"]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Just my code</title>
</head>
<body>
<h5>Template page menggunakan sitemesh</h5>
</body>
</html>[/sourcecode]

Kemudian jalankan Myweb, klik kanan project Myweb pilih Run As > Run On Server, pada tipe server pilih Basic > J2EE Preview > Finish ..

Kemudian akses web menggunakan alamat http://localhost:8080/Myweb

Download Sitemesh dan JSTL library

Q> sitemesh-2.4.1.jar dan jstl-1.2.jar kemudian letakan (copy) di folder lib project.

Q> Buat folder sitemesh pada WebContent
Q> Buat file main.jsp pada folder sitemesh

[sourcecode language="html"]<%@taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>My Web - <decorator:title /></title>
</head>
<body>
<h2>This about my web ;D</h2>
<hr>
<h4><decorator:title /></h4>
<br/>

<decorator:body />
</body>
</html>[/sourcecode]

Q> Buat file decorators.xml pada folder WEB-INF

[sourcecode language="xml"]<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/sitemesh">
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>[/sourcecode]

Q> Tambahkan config untuk sitemesh di web.xml

[sourcecode language="xml"]<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>[/sourcecode]



Q> Donwload apache-tomcat-6.0.35 > ekstrak di suatu direktory
Q> Masukkan tomcat ke dalam eclipse, menu Window > Show View > Server
Q> Klik kanan > Add server , pilih Apache > Tomcat 6.0 > browse tempat ekstract file apache tomcat tadi.
Q> Start tomcat.
Q> Jalankan lagi Myweb , http://localhost:8080/Myweb



Q> Selesai ;D ,, met ber-sitemesh

Tidak ada komentar:

Posting Komentar

saifiahmada.com adalah blog belajar programming Indonesia, membahas lengkap materi bahasa pemrograman: code HTML, CSS, Bootstrap, Desain, PHP, MySQL, coding Java, Query, SQL, dan dunia linux